1
0

vimrc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. " -------------
  2. " General setup
  3. " -------------
  4. filetype plugin indent on
  5. syntax enable
  6. " Automatically remove all trailing whitespace
  7. autocmd BufWritePre * :%s/\s\+$//e
  8. " Source completion
  9. " Automatically open and close the popup menu / preview window
  10. "set omnifunc=syntaxcomplete#Complete
  11. "au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
  12. "set completeopt=menuone,menu,longest,preview
  13. " ------
  14. " Layout
  15. " ------
  16. " try 256 color mode if envvar is set
  17. set t_Co=88
  18. if $TERM == 'xterm-256color' | set t_Co=256 | endif
  19. " Color scheme
  20. "set background=dark
  21. "colorscheme darkspectrum
  22. runtime! plugin/guicolorscheme.vim
  23. GuiColorScheme darkspectrum
  24. set fileformats=unix " obviously...
  25. set ruler " show cursor location
  26. set modeline " read modelines
  27. set number " show line numbers
  28. set title " change the terminal's title
  29. set nocompatible " disable Vi-compatibility
  30. set laststatus=2 " always display filename
  31. set textwidth=79 " break line at 79 chars
  32. " Tabs are for heathens, we indent with spaces
  33. set expandtab smarttab
  34. set shiftwidth=4 tabstop=8 softtabstop=0
  35. set autoindent copyindent
  36. set shiftround
  37. set backspace=indent,eol,start
  38. " Don't give people epilepsy
  39. set visualbell t_vb= noerrorbells
  40. " Enable wildmenu for browsing files in :e command
  41. set wildmenu
  42. set wildcharm=<TAB>
  43. set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.bc
  44. " File explorer
  45. let g:netrw_liststyle=3 " Use tree-mode as default view
  46. let g:netrw_preview=1 " Preview window shown in a vertically split
  47. " ---------
  48. " Searching
  49. " ---------
  50. set history=1000 undolevels=1000
  51. set wildignore=*.swp,*.bak,*.pyc,*.class,*.old
  52. set hlsearch " highlight search terms
  53. set incsearch " show search matches as you type
  54. set smartcase " clever case sensitivity
  55. " -----------------------
  56. " Key bindings / commands
  57. " -----------------------
  58. " Use ';' instead of ':'
  59. nnoremap ; :
  60. " Use Q for formatting the current paragraph (or selection)
  61. vmap Q gq
  62. nmap Q gqap
  63. " Solve line jumping with long, wrapped lines (use [jk] for normal behaviour)
  64. nnoremap <down> gj
  65. nnoremap <up> gk
  66. " Window navigation with ctrl + [hjkl]
  67. map <C-h> <C-w>h
  68. map <C-j> <C-w>j
  69. map <C-k> <C-w>k
  70. map <C-l> <C-w>l
  71. " Shortcuts for common commands
  72. nmap <silent> ,/ :nohlsearch<CR>
  73. nmap <silent> ,mm :!make<CR>
  74. nmap <silent> ,ml :!make clean<CR>
  75. nmap <silent> ,mt :!make check<CR>
  76. nmap <silent> ,md :!make dist<CR>
  77. nmap <silent> ,mb :!make -B<CR>
  78. " Use w!! to save a file as root if opened with insufficient permissions
  79. cmap w!! w !sudo tee % >/dev/null
  80. " ---------------
  81. " Syntax / indent
  82. " ---------------
  83. " Some files only have 2 spaces indent
  84. autocmd FileType sass,html set shiftwidth=2
  85. " Tabs in Makefiles are 4 spaces since they are required and thus need not be
  86. " religiously burned
  87. autocmd FileType make set tabstop=4
  88. " Make pfd's readable
  89. autocmd BufReadPre *.pdf set ro nowrap
  90. autocmd BufReadPost *.pdf silent %!pdftotext "%" -nopgbrk -layout -q -eol unix -
  91. " C syntax highlighting for CiviC files
  92. autocmd BufNewFile,BufRead *.cvc set filetype=c
  93. " Status line highlight
  94. highlight StatusLine ctermbg=black ctermfg=grey
  95. " Syntax highlighting for .less files
  96. autocmd BufNewFile,BufRead *.less set filetype=less
  97. " Highlight and underline badly spelled words when spellcheck is on
  98. highlight SpellBad guisp=#fcaf3e cterm=underline