vimrc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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=-1
  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 ignorecase smartcase " clever case sensitivity
  55. " ---------------------------
  56. " Mouse selection & scrolling
  57. " ---------------------------
  58. "set mouse=a
  59. map <ScrollWheelUp> <C-Y>
  60. map <S-ScrollWheelUp> <C-U>
  61. map <ScrollWheelDown> <C-E>
  62. map <S-ScrollWheelDown> <C-D>
  63. " -----------------------
  64. " Key bindings / commands
  65. " -----------------------
  66. " Use ';' instead of ':'
  67. nnoremap ; :
  68. " Use Q for formatting the current paragraph (or selection)
  69. vmap Q gq
  70. nmap Q gqap
  71. " Solve line jumping with long, wrapped lines (use [jk] for normal behaviour)
  72. nnoremap <down> gj
  73. nnoremap <up> gk
  74. " Window navigation with ctrl + [hjkl]
  75. map <C-h> <C-w>h
  76. map <C-j> <C-w>j
  77. map <C-k> <C-w>k
  78. map <C-l> <C-w>l
  79. " Shortcuts for common commands
  80. nmap <silent> ,/ :nohlsearch<CR>
  81. nmap <silent> ,mm :!make<CR>
  82. nmap <silent> ,ml :!make clean<CR>
  83. nmap <silent> ,mt :!make check<CR>
  84. nmap <silent> ,md :!make dist<CR>
  85. nmap <silent> ,mb :!make -B<CR>
  86. " Use w!! to save a file as root if opened with insufficient permissions
  87. cmap w!! w !sudo tee % >/dev/null
  88. " ---------------
  89. " Syntax / indent
  90. " ---------------
  91. " Some files only have 2 spaces indent
  92. autocmd FileType sass,html set shiftwidth=2
  93. " Tabs in Makefiles are 4 spaces since they are required and thus need not be
  94. " religiously burned
  95. autocmd FileType make set tabstop=4
  96. " Make pfd's readable
  97. autocmd BufReadPre *.pdf set ro nowrap
  98. autocmd BufReadPost *.pdf silent %!pdftotext "%" -nopgbrk -layout -q -eol unix -
  99. " C syntax highlighting for CiviC files
  100. autocmd BufNewFile,BufRead *.cvc set filetype=c
  101. " Status line highlight
  102. highlight StatusLine ctermbg=black ctermfg=grey
  103. " Syntax highlighting for .less files
  104. autocmd BufNewFile,BufRead *.less set filetype=less
  105. " Highlight and underline badly spelled words when spellcheck is on
  106. highlight SpellBad guisp=#fcaf3e cterm=underline