vimrc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. " start plugins
  2. execute pathogen#infect()
  3. " set black color scheme
  4. colorscheme torte
  5. " enable syntax processing
  6. syntax enable
  7. " number of visual spaces per TAB
  8. set tabstop=4
  9. " number of spaces in tab when editing
  10. set softtabstop=4
  11. " number of space when using > or <
  12. set shiftwidth=4
  13. " tabs are spaces
  14. set expandtab
  15. " show line numbers
  16. set number
  17. " show relative line numbers
  18. set rnu
  19. " show command in bottom bar
  20. set showcmd
  21. " don't highlight current line
  22. set nocursorline
  23. " load filetype-specific indent files
  24. filetype indent on
  25. " visual autocomplete for command menu
  26. set wildmenu
  27. " don't autocomplete on first tab press
  28. set wildmode=list,full
  29. " redraw only when necessary (faster macros)
  30. set lazyredraw
  31. " highlight matching brackets
  32. set showmatch
  33. " search as characters are entered
  34. set incsearch
  35. " fold based on indent
  36. set foldmethod=indent
  37. " foldlevel when window is loaded
  38. set foldlevelstart=1
  39. " fold based on indent level
  40. set foldmethod=indent
  41. " disable the mouse
  42. set mouse=
  43. " toggle relative line nums when focus is gained/lost
  44. :au FocusLost * :set norelativenumber
  45. :au FocusGained * :set relativenumber
  46. " map C-n to toggle line nums
  47. function! NumberToggle()
  48. if(&relativenumber == 1)
  49. set norelativenumber
  50. else
  51. set relativenumber
  52. endif
  53. endfunc
  54. nnoremap <C-n> :call NumberToggle()<CR>
  55. " set shell to zsh on linux (if it exists)
  56. if !(has("win32") || has("win16") || has("win32unix"))
  57. if filereadable("/bin/zsh") && $SHELL=="/bin/zsh"
  58. silent! set shell=/bin/zsh
  59. endif
  60. endif
  61. " swap files are rotated every 10 keystrokes
  62. set updatecount=10
  63. " backspace is used to remove previous characters, indents, and newlines
  64. set backspace=indent,eol,start
  65. " Map Ctrl-Backspace to delete the previous word in insert mode.
  66. imap <C-BS> <C-W>
  67. " make an undo file to allow undoing after closing a file
  68. set undofile
  69. set undodir=~/.vim/undodir
  70. " set Makefiles with tabs not spaces
  71. autocmd FileType make setlocal noexpandtab
  72. " write w/ privileges when Vim isn't started as root
  73. cmap w!! %!sudo tee > /dev/null %
  74. " toggle background
  75. function! ClearBG()
  76. highlight Normal ctermbg=none
  77. endfunction
  78. function! BlackBG()
  79. highlight Normal ctermbg=black
  80. endfunction
  81. " leader
  82. " space is Leader
  83. map <space> <leader>
  84. " compare current buffer to saved file
  85. function! s:DiffWithSaved()
  86. let filetype=&ft
  87. diffthis
  88. vnew | r # | normal! 1Gdd
  89. diffthis
  90. exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
  91. endfunction
  92. com! DiffSaved call s:DiffWithSaved()
  93. " map the comp buff function above
  94. noremap <Leader>d :DiffSaved<CR>
  95. " <Leader>l formats a line
  96. noremap <Leader>l Vgq
  97. " remove trailing whitespace and return to start position
  98. " remove lighlight if in nvim
  99. if has('nvim')
  100. noremap <Leader>w :%s/\s\+$//<CR>:nohl<CR>``
  101. else
  102. noremap <Leader>w :%s/\s\+$//<CR>``
  103. endif
  104. " plugins
  105. " show recently opened files
  106. noremap <Leader>m :MRU<CR>
  107. " Start Geeknote
  108. noremap <Leader>g :Geeknote<CR>
  109. " show undo tree
  110. noremap <Leader>u :UndotreeToggle<CR>
  111. " syntastic/YCM
  112. if exists(':SyntasticStatuslineFlag()')
  113. set statusline+=%#warningmsg#
  114. set statusline+=%{SyntasticStatuslineFlag()}
  115. set statusline+=%*
  116. let g:syntastic_always_populate_loc_list = 1
  117. let g:syntastic_auto_loc_list = 1
  118. let g:syntastic_check_on_open = 1
  119. let g:syntastic_check_on_wq = 0
  120. endif
  121. " YouCompleteMe
  122. let g:ycm_global_ycm_extra_conf = '/home/josh/.vim/bundle/ycm_extra_conf.py'
  123. " autoclose suggestion windows
  124. let g:ycm_autoclose_preview_window_after_insertion=1
  125. " colors
  126. highlight YcmWarningSection ctermfg=Yellow
  127. highlight YcmWarningSign ctermfg=Yellow
  128. highlight YcmErrorSection ctermfg=Red
  129. highlight YcmErrorsign ctermfg=Red
  130. " vim-airline
  131. " place the airline bar above the command line
  132. set laststatus=2
  133. " neovim
  134. if has('nvim')
  135. " Esc clears search highlight
  136. nnoremap <silent> <esc> :noh<cr><esc>
  137. " Esc returns to normal mode in terminal mode
  138. tnoremap <C-w> <C-\><C-n><C-w>
  139. endif