vimrc 4.9 KB

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