1
0

vimrc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. if &diff
  24. colorscheme blue
  25. else
  26. runtime! plugin/guicolorscheme.vim
  27. GuiColorScheme darkspectrum
  28. endif
  29. set fileformats=unix " obviously...
  30. set ruler " show cursor location
  31. set modeline " read modelines
  32. set number " show line numbers
  33. set title " change the terminal's title
  34. set nocompatible " disable Vi-compatibility
  35. set laststatus=2 " always display filename
  36. set textwidth=79 " break line at 79 chars
  37. " Tabs are for heathens, we indent with spaces
  38. set expandtab smarttab
  39. set shiftwidth=4 tabstop=4 softtabstop=-1
  40. set autoindent copyindent
  41. set shiftround
  42. set backspace=indent,eol,start
  43. " Don't give people epilepsy
  44. set visualbell t_vb= noerrorbells
  45. " Enable wildmenu for browsing files in :e command
  46. set wildmenu
  47. set wildcharm=<TAB>
  48. set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.bc,*.old,*.cmi,*.cmx,*.aux
  49. " File explorer
  50. let g:netrw_liststyle=3 " Use tree-mode as default view
  51. let g:netrw_preview=1 " Preview window shown in a vsplit
  52. " ---------
  53. " Searching
  54. " ---------
  55. set history=1000 undolevels=1000
  56. set hlsearch " highlight search terms
  57. set incsearch " show search matches as you type
  58. set ignorecase smartcase " clever case sensitivity
  59. " ---------------------------
  60. " Mouse selection & scrolling
  61. " ---------------------------
  62. "set mouse=a
  63. map <ScrollWheelUp> <C-Y>
  64. map <S-ScrollWheelUp> <C-U>
  65. map <ScrollWheelDown> <C-E>
  66. map <S-ScrollWheelDown> <C-D>
  67. " -----------------------
  68. " Key bindings / commands
  69. " -----------------------
  70. " Use ';' instead of ':'
  71. nnoremap ; :
  72. " Use Q for formatting the current paragraph (or selection)
  73. vmap Q gq
  74. nmap Q gqap
  75. " Solve line jumping with long, wrapped lines (use [jk] for normal behaviour)
  76. nnoremap <down> gj
  77. nnoremap <up> gk
  78. " Window navigation with ctrl + [hjkl]
  79. map <C-h> <C-w>h
  80. map <C-j> <C-w>j
  81. map <C-k> <C-w>k
  82. map <C-l> <C-w>l
  83. " Shortcuts for common commands
  84. nmap <silent> ,/ :nohlsearch<CR>
  85. nmap <silent> ,mm :!make<CR>
  86. nmap <silent> ,ml :!make clean<CR>
  87. nmap <silent> ,mt :!make check<CR>
  88. nmap <silent> ,md :!make dist<CR>
  89. nmap <silent> ,mb :!make -B<CR>
  90. " Use w!! to save a file as root if opened with insufficient permissions
  91. cmap w!! w !sudo tee % >/dev/null
  92. " ---------------
  93. " Syntax / indent
  94. " ---------------
  95. " Some files only have 2 spaces indent
  96. autocmd FileType sass,html,ocaml,bib,llvm set shiftwidth=2
  97. " Make pfd's readable
  98. autocmd BufReadPre *.pdf set ro nowrap
  99. autocmd BufReadPost *.pdf silent %!pdftotext "%" -nopgbrk -layout -q -eol unix -
  100. " C syntax highlighting for CiviC files
  101. autocmd BufNewFile,BufRead *.cvc set filetype=c
  102. " Status line highlight
  103. highlight StatusLine ctermbg=black ctermfg=grey
  104. " Syntax highlighting by extension
  105. autocmd BufNewFile,BufRead *.less set filetype=less
  106. autocmd BufNewFile,BufRead *.md set filetype=markdown
  107. autocmd BufNewFile,BufRead *.gv set filetype=dot
  108. autocmd BufNewFile,BufRead *.ll set filetype=llvm
  109. autocmd BufNewFile,BufRead *.inc set filetype=sh
  110. " Highlight and underline badly spelled words when spellcheck is on
  111. highlight SpellBad guisp=#fcaf3e cterm=underline
  112. " -----------------------
  113. " Additional local config
  114. " -----------------------
  115. if filereadable($HOME . '/.vimrc_local')
  116. source ~/.vimrc_local
  117. endif