tibix
12/13/2017 - 1:45 PM

.vimrc (with powerline)

Vim config file with powerline included

"  My vimrc config "
" added support for powerline "
set  rtp+=/Library/Python/2.7/site-packages/powerline/bindings/vim/
set runtimepath^=~/.vim/bundle/ctrlp.vim
set laststatus=2
set t_Co=256
"  Normal vim config "
"  Color Scheme "

"  Syntax "
syntax on

"  Spaces and tabs "
set tabstop=4
set softtabstop=4
set expandtab

"  UI elements "
set number
set showcmd
set cursorline
filetype indent on
set wildmenu
set lazyredraw
set showmatch

"  Searching  "
set incsearch
set hlsearch

"  Folding  "
set foldenable
set foldlevelstart=10
set foldnestmax=10

nnoremap <space> za

set foldmethod=indent

"  Moving  "
nnoremap j gj
nnoremap k gk
nnoremap B ^
nnoremap E $

nnoremap $ <nop>
nnoremap ^ <nop>

nnoremap gV `[v`]

"  tmux cursor  "
if exists('$TMUX')
    let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
    let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
    let &t_SI = "\<Esc>]50;CursorShape=1\x7"
    let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif

"  Autogroups  "
augroup configgroup
  autocmd!
  autocmd VimEnter * highlight clear SignColumn
  autocmd BufWritePre *.php,*.py,*.js,*.txt,*.hs,*.java,*.md
                \:call <SID>StripTrailingWhitespaces()
  autocmd FileType java setlocal noexpandtab
  autocmd FileType java setlocal list
  autocmd FileType java setlocal listchars=tab:+\ ,eol:-
  autocmd FileType java setlocal formatprg=par\ -w80\ -T4
  autocmd FileType php setlocal expandtab
  autocmd FileType php setlocal list
  autocmd FileType php setlocal listchars=tab:+\ ,eol:-
  autocmd FileType php setlocal formatprg=par\ -w80\ -T4
  autocmd FileType ruby setlocal tabstop=2
  autocmd FileType ruby setlocal shiftwidth=2
  autocmd FileType ruby setlocal softtabstop=2
  autocmd FileType ruby setlocal commentstring=#\ %s
  autocmd FileType python setlocal commentstring=#\ %s
  autocmd BufEnter *.cls setlocal filetype=java
  autocmd BufEnter *.zsh-theme setlocal filetype=zsh
  autocmd BufEnter Makefile setlocal noexpandtab
  autocmd BufEnter *.sh setlocal tabstop=2
  autocmd BufEnter *.sh setlocal shiftwidth=2
  autocmd BufEnter *.sh setlocal softtabstop=2
augroup END

" toggle between number and relativenumber "
function! ToggleNumber()
    if(&relativenumber == 1)
        set norelativenumber
        set number
    else
        set relativenumber
    endif
endfunc

" strips trailing whitespace at the end of files. this "
" is called on buffer write in the autogroup above "
function! <SID>StripTrailingWhitespaces()
    " save last search & cursor position "
    let _s=@/
    let l = line(".")
    let c = col(".")
    %s/\s\+$//e
    let @/=_s
    call cursor(l, c)
endfunction