1
0

vimrc 4.0 KB

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