vimrc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. set ruler
  2. hi SpellBad guisp=#fcaf3e cterm=underline
  3. set expandtab
  4. set modeline
  5. set tabstop=4 " a tab is four spaces
  6. set backspace=indent,eol,start
  7. " allow backspacing over everything in insert mode
  8. set autoindent " always set autoindenting on
  9. set copyindent " copy the previous indentation on autoindenting
  10. set number " always show line numbers
  11. set shiftwidth=4 " number of spaces to use for autoindenting
  12. set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
  13. set ignorecase " ignore case when searching
  14. set smartcase " ignore case if search pattern is all lowercase,
  15. " case-sensitive otherwise
  16. set smarttab " insert tabs on the start of a line according to
  17. " shiftwidth, not tabstop
  18. set hlsearch " highlight search terms
  19. set incsearch " show search matches as you type
  20. set history=1000 " remember more commands and search history
  21. set undolevels=1000 " use many muchos levels of undo
  22. set wildignore=*.swp,*.bak,*.pyc,*.class,*.old
  23. set textwidth=79
  24. set vb t_vb=
  25. set ls=2 " always display filename
  26. " IMPORTANT: Uncomment one of the following lines to force
  27. " using 256 colors (or 88 colors) if your terminal supports it,
  28. " but does not automatically use 256 colors by default.
  29. " -- run in gnome-terminal: --
  30. " export TERM="xterm-256color"
  31. "
  32. set t_Co=88
  33. if $TERM == 'xterm-256color'
  34. set t_Co=256
  35. endif
  36. " ,rl = run pdflatex (on current file)
  37. map ,rl :!pdflatex -src -shell-escape -interaction=nonstopmode %
  38. " trigger pdflatex (above) on FileWritePost event
  39. ":autocmd BufWritePost *.tex :!pdflatex -src -shell-escape -interaction=nonstopmode % | grep -A 4 -i "error"
  40. :autocmd BufNewFile,BufRead *.tex :set spell
  41. "augroup vimrc_autocmds
  42. " autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929
  43. " autocmd BufEnter * match OverLength /\%81v.*/
  44. "augroup END
  45. " configure tags - add additional tags here or comment out not-used ones
  46. " cd /usr/include
  47. " ctags -R --sort=yes --fields=+iaS -f ~/.vim/tags/stdc stdio.h stdlib.h \
  48. " pthread.h math.h assert.h errno.h malloc.h strings.h fcntl.h unistd.h
  49. " ctags -R --sort=yes --fields=+iaS -f ~/.vim/tags/gl GL/
  50. "set tags+=~/.vim/tags/stdc
  51. "set tags+=~/.vim/tags/gl
  52. " build tags of your own project with CTRL+F12
  53. "map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
  54. "noremap <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
  55. "inoremap <F12> <Esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
  56. "" OmniCppComplete
  57. "let OmniCpp_NamespaceSearch = 1
  58. "let OmniCpp_GlobalScopeSearch = 1
  59. "let OmniCpp_ShowAccess = 1
  60. "let OmniCpp_MayCompleteDot = 1
  61. "let OmniCpp_MayCompleteArrow = 1
  62. "let OmniCpp_MayCompleteScope = 1
  63. "let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
  64. "" automatically open and close the popup menu / preview window
  65. "au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
  66. ""set completeopt=menuone,menu,longest,preview
  67. "set completeopt=menuone,menu " ,longest,preview
  68. "set nocp
  69. filetype plugin on
  70. "set background=dark
  71. "colorscheme darkspectrum
  72. runtime! plugin/guicolorscheme.vim
  73. GuiColorScheme darkspectrum
  74. " Wildmenu
  75. set wildmenu " use wildmenu
  76. set wildcharm=<TAB> " autocomplete
  77. set wildignore=*.swp,*.bak,*.pyc,*.class,*.old
  78. " ------------------
  79. " Various vim tweaks
  80. " ------------------
  81. set title " change the terminal's title
  82. set visualbell " don't beep
  83. set noerrorbells " don't beep
  84. set nocp " Disable Vi-compatibility
  85. " syntax detection and filetype indention
  86. filetype plugin indent on
  87. syntax enable
  88. autocmd BufReadPre *.pdf set ro nowrap
  89. autocmd BufReadPost *.pdf silent %!pdftotext "%" -nopgbrk -layout -q -eol unix -
  90. " C syntax highlighting for CiviC files
  91. au BufNewFile,BufRead *.cvc set filetype=c
  92. " Automatically remove all trailing spaces
  93. autocmd BufWritePre * :%s/\s\+$//e
  94. " -----------------
  95. " Source completion
  96. " -----------------
  97. au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
  98. "set completeopt=menuone,menu
  99. " --------------
  100. " Source folding
  101. " --------------
  102. "set foldmethod=indent
  103. " -------------
  104. " File explorer
  105. " -------------
  106. let g:netrw_liststyle=3 " Use tree-mode as default view
  107. "let g:netrw_browse_split=4 " Open file in previous buffer
  108. let g:netrw_preview=1 " Preview window shown in a vertically split
  109. " ------------
  110. " Key bindings
  111. " ------------
  112. " skip the press and hold 'shift' + press ';' + release 'shift'.
  113. " Now you can simply use ';' instead of ':'.
  114. nnoremap ; :
  115. " Use Q for formatting the current paragraph (or selection)
  116. vmap Q gq
  117. nmap Q gqap
  118. " Unbind Shift + up/down
  119. vmap <s-up> <up>
  120. nmap <s-up> <up>
  121. vmap <s-down> <down>
  122. nmap <s-down> <down>
  123. " If you like long lines with line wrapping enabled, this solves the problem
  124. " that pressing down jumpes your cursor “over” the current line to the next
  125. " line. It changes behaviour so that it jumps to the next row in the editor.
  126. nnoremap j gj
  127. nnoremap k gk
  128. " Easy window navigation
  129. map <C-h> <C-w>h
  130. map <C-j> <C-w>j
  131. map <C-k> <C-w>k
  132. map <C-l> <C-w>l
  133. " It clears the search buffer (and highlighting) when you press ,/
  134. nmap <silent> ,/ :nohlsearch<CR>
  135. nmap <silent> ,mt :!make check<CR>
  136. nmap <silent> ,mc :!make coverage<CR>
  137. nmap <silent> ,ml :!make clean<CR>
  138. nmap <silent> ,mm :!make<CR>
  139. nmap <silent> ,mM :!make && make<CR>
  140. nmap <silent> ,md :!make doc<CR>
  141. nmap <silent> ,mb :!make -B<CR>
  142. nmap <silent> ,a :!ant<CR>
  143. " when you forgot to sudo before editing a file that requires root privileges.
  144. " This lets you use w!! to do that after you opened the file already:
  145. cmap w!! w !sudo tee % >/dev/null
  146. " Status line highlight
  147. :hi StatusLine ctermbg=black ctermfg=grey
  148. " Syntax highlighting for .less files
  149. au BufNewFile,BufRead *.less set filetype=less
  150. set fileformats=unix
  151. let mapleader=","