vimrc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. " don't highlight current line
  20. set nocursorline
  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") && $SHELL=="/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")) && (!$SSH_CLIENT && !$SSH_TTY) && executable("xmodmap")
  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 escape 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. " map the write and make function
  105. noremap <Leader>c :WriteMake<CR>
  106. " write w/ privileges when Vim isn't started as root
  107. cmap w!! %!sudo tee > /dev/null %
  108. " plugins
  109. " show recently opened files
  110. noremap <Leader>m :MRU<CR>
  111. " Start Geeknote
  112. noremap <Leader>g :Geeknote<CR>
  113. " show undo tree
  114. noremap <Leader>u :UndotreeToggle<CR>
  115. " syntastic/YCM
  116. if exists(':SyntasticStatuslineFlag()')
  117. set statusline+=%#warningmsg#
  118. set statusline+=%{SyntasticStatuslineFlag()}
  119. set statusline+=%*
  120. let g:syntastic_always_populate_loc_list = 1
  121. let g:syntastic_auto_loc_list = 1
  122. let g:syntastic_check_on_open = 1
  123. let g:syntastic_check_on_wq = 0
  124. endif
  125. " YouCompleteMe
  126. let g:ycm_global_ycm_extra_conf = '/home/josh/.vim/bundle/ycm_extra_conf.py'
  127. " autoclose suggestion windows
  128. let g:ycm_autoclose_preview_window_after_insertion=1
  129. " colors
  130. highlight YcmWarningSection ctermfg=Yellow
  131. highlight YcmWarningSign ctermfg=Yellow
  132. highlight YcmErrorSection ctermfg=Red
  133. highlight YcmErrorsign ctermfg=Red