vimrc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. " redraw only when necessary (faster macros)
  28. set lazyredraw
  29. " highlight matching brackets
  30. set showmatch
  31. " search as characters are entered
  32. set incsearch
  33. " fold based on indent
  34. set foldmethod=indent
  35. " foldlevel when window is loaded
  36. set foldlevelstart=1
  37. " space is Leader
  38. map <space> <leader>
  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. "caps switching functions - unused
  62. "" function to check for running instances of vim on Linux
  63. "function! UnixCapsControl()
  64. " silent! let running = system('echo $(pgrep -c vim)')
  65. " if(running <= 1)
  66. " silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Caps_Lock'
  67. " endif
  68. "endfunction
  69. "
  70. "" map caps lock to escape under Linux
  71. "!(has("win32") || has("win16") || has("win32unix")) && (!$SSH_CLIENT && !$SSH_TTY) && executable("xmodmap")
  72. "
  73. " au VimEnter * silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
  74. " au VimLeave * :call UnixCapsControl()
  75. "endif
  76. "
  77. "" function to check for running instances of vim on Windows
  78. "function! WindowsCapsControl()
  79. " silent! let running = system('tasklist /FI "IMAGENAME eq vim.exe" 2>NUL | find /I /C "vim.exe"')
  80. " if(running <= 1)
  81. " silent! !start taskkill /IM CapsEsc.exe
  82. " endif
  83. "endfunction
  84. "
  85. "" map caps lock to escape under Windows
  86. "if (has("win32") || has("win16"))
  87. " au VimEnter * silent! !start C:\Users\Josh\vimfiles\CapsEsc.exe
  88. " au VimLeave * :call WindowsCapsControl()
  89. "endif
  90. ""
  91. "" function to check for running instances of vim on Cygwin
  92. "function! CygwinCapsControl()
  93. " silent! let running = system('echo $(pgrep -c vim)')
  94. " if(running <= 1)
  95. " silent! !pkill CapsEsc
  96. " endif
  97. "endfunction
  98. "
  99. "" map caps lock to escape under Cygwin
  100. "if (has("win32unix"))
  101. " au VimEnter * silent! !/home/josh/.vim/CapsEsc.exe &
  102. " au VimLeave * :call CygwinCapsControl()
  103. "endif
  104. " swap files are rotated every 10 keystrokes
  105. set updatecount=10
  106. " backspace is used to remove previous characters, indents, and newlines
  107. set backspace=indent,eol,start
  108. " <Leader>l formats a line
  109. noremap <Leader>l Vgq
  110. " make an undo file to allow undoing after closing a file
  111. set undofile
  112. set undodir=~/.vim/undodir
  113. " set Makefiles with tabs not spaces
  114. autocmd FileType make setlocal noexpandtab
  115. " compare current buffer to saved file
  116. function! s:DiffWithSaved()
  117. let filetype=&ft
  118. diffthis
  119. vnew | r # | normal! 1Gdd
  120. diffthis
  121. exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
  122. endfunction
  123. com! DiffSaved call s:DiffWithSaved()
  124. " map the comp buff function above
  125. noremap <Leader>d :DiffSaved<CR>
  126. " map the write and make function
  127. noremap <Leader>c :WriteMake<CR>
  128. " write w/ privileges when Vim isn't started as root
  129. cmap w!! %!sudo tee > /dev/null %
  130. " remove trailing whitespace and return to start position
  131. noremap <Leader>w :%s/\s\+$//<CR>``
  132. " toggle background
  133. function! ClearBG()
  134. highlight Normal ctermbg=none
  135. endfunction
  136. function! BlackBG()
  137. highlight Nornal ctermbg=black
  138. endfunction
  139. " plugins
  140. " show recently opened files
  141. noremap <Leader>m :MRU<CR>
  142. " Start Geeknote
  143. noremap <Leader>g :Geeknote<CR>
  144. " show undo tree
  145. noremap <Leader>u :UndotreeToggle<CR>
  146. " syntastic/YCM
  147. if exists(':SyntasticStatuslineFlag()')
  148. set statusline+=%#warningmsg#
  149. set statusline+=%{SyntasticStatuslineFlag()}
  150. set statusline+=%*
  151. let g:syntastic_always_populate_loc_list = 1
  152. let g:syntastic_auto_loc_list = 1
  153. let g:syntastic_check_on_open = 1
  154. let g:syntastic_check_on_wq = 0
  155. endif
  156. " YouCompleteMe
  157. let g:ycm_global_ycm_extra_conf = '/home/josh/.vim/bundle/ycm_extra_conf.py'
  158. " autoclose suggestion windows
  159. let g:ycm_autoclose_preview_window_after_insertion=1
  160. " colors
  161. highlight YcmWarningSection ctermfg=Yellow
  162. highlight YcmWarningSign ctermfg=Yellow
  163. highlight YcmErrorSection ctermfg=Red
  164. highlight YcmErrorsign ctermfg=Red
  165. " vim-airline
  166. " place the airline bar above the command line
  167. set laststatus=2
  168. " neovim
  169. if has('nvim')
  170. " Esc clears search highlight
  171. nnoremap <silent> <esc> :noh<cr><esc>
  172. " Esc returns to normal mode in terminal mode
  173. tnoremap <C-w> <C-\><C-n><C-w>
  174. endif