vimrc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 command in bottom bar
  18. set showcmd
  19. " highlight current line
  20. set cursorline
  21. " load filetype-specific indent files
  22. filetype indent on
  23. " visual autocomplete for command menu
  24. set wildmenu
  25. " redraw only when necessary (faster macros)
  26. set lazyredraw
  27. " highlight matching brackets
  28. set showmatch
  29. " search as characters are entered
  30. set incsearch
  31. " fold based on indent
  32. set foldmethod=indent
  33. " foldlevel when window is loaded
  34. set foldlevelstart=1
  35. " space is Leader
  36. map <space> <leader>
  37. " fold based on indent level
  38. set foldmethod=indent
  39. " set shell to zsh (if it exists)
  40. if !(has("win32") || has("win16") || has("win32unix"))
  41. if filereadable("/bin/zsh")
  42. silent! set shell=/bin/zsh
  43. endif
  44. endif
  45. " function to check for running instances of vim on Linux
  46. function! UnixCapsControl()
  47. silent! let running = system('echo $(pgrep -c vim)')
  48. if(running <= 1)
  49. silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Caps_Lock'
  50. endif
  51. endfunction
  52. " map caps lock to escape under Linux
  53. if !(has("win32") || has("win16") || has("win32unix"))
  54. au VimEnter * silent! !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
  55. au VimLeave * :call UnixCapsControl()
  56. endif
  57. " function to check for running instances of vim on Windows
  58. function! WindowsCapsControl()
  59. silent! let running = system('tasklist /FI "IMAGENAME eq vim.exe" 2>NUL | find /I /C "vim.exe"')
  60. if(running <= 1)
  61. silent! !start taskkill /IM CapsEsc.exe
  62. endif
  63. endfunction
  64. " map caps lock to escape under Windows
  65. if (has("win32") || has("win16"))
  66. au VimEnter * silent! !start C:\Users\Josh\vimfiles\CapsEsc.exe
  67. au VimLeave * :call WindowsCapsControl()
  68. endif
  69. "
  70. " function to check for running instances of vim on Cygwin
  71. function! CygwinCapsControl()
  72. silent! let running = system('echo $(pgrep -c vim)')
  73. if(running <= 1)
  74. silent! !pkill CapsEsc
  75. endif
  76. endfunction
  77. " map caps lock to excape under Cygwin
  78. if (has("win32unix"))
  79. au VimEnter * silent! !/home/josh/.vim/CapsEsc.exe &
  80. au VimLeave * :call CygwinCapsControl()
  81. endif
  82. " swap files are rotated every 10 keystrokes
  83. set updatecount=10
  84. " backspace is used to remove previous characters, indents, and newlines
  85. set backspace=indent,eol,start
  86. " <Leader>l formats a line
  87. noremap <Leader>l Vgq
  88. " make an undo file to allow undoing after closing a file
  89. set undofile
  90. set undodir=~/.vim/undodir
  91. " set Makefiles with tabs not spaces
  92. autocmd FileType make setlocal noexpandtab
  93. " compare current buffer to saved file
  94. function! s:DiffWithSaved()
  95. let filetype=&ft
  96. diffthis
  97. vnew | r # | normal! 1Gdd
  98. diffthis
  99. exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
  100. endfunction
  101. com! DiffSaved call s:DiffWithSaved()
  102. " map the comp buff function above
  103. noremap <Leader>d :DiffSaved<CR>
  104. " function to write a file and immediately run make
  105. function! s:writeAndMake()
  106. :w
  107. :make
  108. endfunction
  109. com! WriteMake call s:writeAndMake()
  110. " map the write and make function
  111. noremap <Leader>c :WriteMake<CR>
  112. " write w/ privileges when Vim isn't started as root
  113. cmap w!! %!sudo tee > /dev/null %
  114. " plugins
  115. " show recently opened files
  116. noremap <Leader>m :MRU<CR>
  117. " Start Geeknote
  118. noremap <Leader>g :Geeknote<CR>
  119. " show undo tree
  120. noremap <Leader>u :UndotreeToggle<CR>
  121. " syntastic
  122. if exists(':SyntasticStatuslineFlag()')
  123. set statusline+=%#warningmsg#
  124. set statusline+=%{SyntasticStatuslineFlag()}
  125. set statusline+=%*
  126. let g:syntastic_always_populate_loc_list = 1
  127. let g:syntastic_auto_loc_list = 1
  128. let g:syntastic_check_on_open = 1
  129. let g:syntastic_check_on_wq = 0
  130. endif
  131. " YouCompleteMe
  132. let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py'
  133. " autoclose suggestion windows
  134. let g:ycm_autoclose_preview_window_after_insertion=1
  135. " colors
  136. highlight YcmWarningSection ctermfg=Yellow
  137. highlight YcmWarningSign ctermfg=Yellow
  138. highlight YcmErrorSection ctermfg=Red
  139. highlight YcmErrorsign ctermfg=Red