1
0

vimrc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. set completeopt-=preview
  14. " ------
  15. " Layout
  16. " ------
  17. " try 256 color mode if envvar is set
  18. set t_Co=88
  19. if $TERM == 'xterm-256color' | set t_Co=256 | endif
  20. " Color scheme
  21. "set background=dark
  22. "colorscheme darkspectrum
  23. runtime! plugin/guicolorscheme.vim
  24. GuiColorScheme darkspectrum
  25. set fileformats=unix " obviously...
  26. set ruler " show cursor location
  27. set modeline " read modelines
  28. set number " show line numbers
  29. set title " change the terminal's title
  30. set nocompatible " disable Vi-compatibility
  31. set laststatus=2 " always display filename
  32. set textwidth=79 " break line at 79 chars
  33. " Tabs are for heathens, we indent with spaces
  34. set expandtab smarttab
  35. set shiftwidth=4 tabstop=4 softtabstop=-1
  36. set autoindent copyindent
  37. set shiftround
  38. set backspace=indent,eol,start
  39. " Don't give people epilepsy
  40. set visualbell t_vb= noerrorbells
  41. " Enable wildmenu for browsing files in :e command
  42. set wildmenu
  43. set wildcharm=<TAB>
  44. set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.bc,*.old,*.cmi,*.cmx
  45. " File explorer
  46. let g:netrw_liststyle=3 " Use tree-mode as default view
  47. let g:netrw_preview=1 " Preview window shown in a vsplit
  48. " ---------
  49. " Searching
  50. " ---------
  51. set history=1000 undolevels=1000
  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
  107. " -----------------------
  108. " Additional local config
  109. " -----------------------
  110. if filereadable($HOME . '/.vimrc_local')
  111. source ~/.vimrc_local
  112. endif