.vimrc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. "
  2. " Vim configuration file (~/.vimrc)
  3. " 2009-2014, kolter <kolter@openics.org>
  4. "
  5. " This file is distributed in the hope that it will be useful,
  6. " but WITHOUT ANY WARRANTY
  7. "
  8. " {{{ Load Plugins
  9. call plug#begin('~/.vim/plugged')
  10. Plug 'junegunn/indentLine'
  11. Plug 'sjl/gundo.vim'
  12. Plug 'scrooloose/syntastic'
  13. Plug 'majutsushi/tagbar'
  14. Plug 'scrooloose/nerdtree'
  15. Plug 'bling/vim-airline'
  16. Plug 'kien/ctrlp.vim'
  17. Plug 'tpope/vim-fugitive'
  18. Plug 'airblade/vim-gitgutter'
  19. Plug 'gregsexton/gitv'
  20. Plug 'terryma/vim-multiple-cursors'
  21. Plug 'jlanzarotta/bufexplorer'
  22. Plug 'flazz/vim-colorschemes'
  23. Plug 'vim-scripts/comments.vim'
  24. Plug 'ervandew/supertab'
  25. Plug 'rstacruz/sparkup'
  26. Plug 'Lokaltog/vim-easymotion'
  27. Plug 'editorconfig/editorconfig-vim'
  28. Plug 'godlygeek/tabular'
  29. Plug 'plasticboy/vim-markdown'
  30. Plug 'pearofducks/ansible-vim'
  31. Plug 'LaTeX-Box-Team/LaTeX-Box'
  32. Plug 'SirVer/ultisnips'
  33. Plug 'honza/vim-snippets'
  34. Plug 'rkitover/vimpager'
  35. Plug 'http://git.openics.org/kolter/vim-bindzone.git'
  36. call plug#end()
  37. " }}}
  38. " {{{ General Settings
  39. " Filetypes Settings
  40. if has('autocmd')
  41. filetype plugin indent on
  42. "reload Vim config file after saving
  43. "autocmd BufWritePost $MYVIMRC :source $MYVIMRC
  44. "always limit the width for text files
  45. autocmd BufRead *.txt set tw=78
  46. autocmd QuickFixCmdPre * botright cwindow 5
  47. endif
  48. "Term settings (under tmux)
  49. if &term =~ '^screen'
  50. "tmux will send xterm-style keys when its xterm-keys option is on
  51. execute "set <xUp>=\e[1;*A"
  52. execute "set <xDown>=\e[1;*B"
  53. execute "set <xRight>=\e[1;*C"
  54. execute "set <xLeft>=\e[1;*D"
  55. endif
  56. set nocompatible "no vi compatibility
  57. set history=1000 "command history size
  58. set undolevels=120 "undo levels count
  59. set autoread "notify file changes
  60. set autochdir "switch to the current file directory
  61. set clipboard+=unnamed "share system clipboard
  62. set backup "enable backups
  63. set backupdir=~/.vim/backups "backup directory
  64. set directory=~/.vim/tmp "directory to place swap files in
  65. "Encoding settings
  66. if has("multi_byte")
  67. if &termencoding == ""
  68. let &termencoding = &encoding
  69. endif
  70. set encoding=utf-8
  71. setglobal fileencoding=utf-8
  72. set fileencodings=utf-8,default,latin1,ucs-bom
  73. endif
  74. "Syntax highlight
  75. syntax on
  76. set t_Co=256
  77. set bg=dark
  78. colorscheme grb256
  79. " }}}
  80. " {{{ Interface Settings
  81. set title "show title
  82. set number "show line numbers
  83. set ruler "statusline for each window
  84. set visualbell t_vb= "visual beep
  85. set showcmd "show incomplete commands
  86. set confirm "raise a dialog asking what to do instead of failing
  87. "set mouse=a "enable mouse support
  88. set lazyredraw "do not redraw when running macros
  89. set ttyfast "fast terminal connection support
  90. set ttimeout
  91. set ttimeoutlen=100
  92. set scrolloff=999
  93. set sidescrolloff=5
  94. set shortmess=a "abbreviations on status line
  95. set laststatus=2 "always statusline
  96. set wildmenu "display completion menu
  97. set wildmode=list:longest,list:full "content of completion menu
  98. "ignore some extensions while completing filename
  99. "set wildignore=*.o,*.so,,*.gz,*.bz2,*.tar,*.tgz,*.tbz2,*.png,*.jpg,*.jpeg,*.gif
  100. set wildchar=<TAB> "wildcar expansion character
  101. set modeline "allow last lines of documents set vim mode
  102. set modelines=3 "number of lines to check for modelines
  103. " }}}
  104. " {{{ Keyboard Settings
  105. " fix home and end keys with some terminals
  106. if $TERM =~ '^screen-256color'
  107. map <Esc>OH <Home>
  108. map! <Esc>OH <Home>
  109. map <Esc>OF <End>
  110. map! <Esc>OF <End>
  111. endif
  112. " keep ctrl-a/ctrl-e for begining/end of line
  113. nmap <c-a> <c-o>I
  114. imap <c-a> <c-o>I
  115. vmap <c-a> <c-o>I
  116. nmap <c-e> <c-o>A
  117. imap <c-e> <c-o>A
  118. vmap <c-e> <c-o>A
  119. "reopen current file
  120. map <F5> :e!<cr>
  121. "using redraw to disable highlighted search patterns
  122. nnoremap <c-L> :nohl<cr><c-L>
  123. "map F1 to open previous buffer
  124. nmap <F1> :bp<cr>
  125. imap <F1> <ESC>:bp<cr>a
  126. "map F2 to open next buffer
  127. nmap <F2> :bn<cr>
  128. imap <F2> <ESC>:bn<cr>a
  129. imap <c-@> <c-x><c-o>
  130. nmap <c-s-left> :tabprevious<cr>
  131. nmap <c-s-right> :tabnext<cr>
  132. nmap <c-s-up> :tabnew<cr>
  133. nmap <c-s-down> :tabclose<cr>
  134. nmap <c-d> :bw<cr>
  135. nmap <F6> :vsplit<cr>
  136. nmap <F7> :split<cr>
  137. "ctrl-$arrow to cycle around splitted windows
  138. map <c-left> <c-w>h
  139. map <c-right> <c-w>l
  140. map <c-Up> <c-w>k
  141. map <c-Down> <c-w>j
  142. "ident in visual mode keep selection
  143. vmap > >gv
  144. vmap < <gv
  145. " }}}
  146. " {{{ Editor Settings
  147. set fileformats=unix,dos,mac "support all three, in this order
  148. set hidden "make possible to change buffer without saving
  149. set report=0 "agressive reporting
  150. set pastetoggle=<F11> "use <F11> to toggle between 'paste' and 'nopaste'
  151. set nostartofline "leave the cursor where it is
  152. "indent settings
  153. set autoindent
  154. set backspace=indent,eol,start "enhance backspacing
  155. set smartindent
  156. set cindent
  157. set smarttab
  158. "tabs and spaces settings
  159. set expandtab "tab are spaces
  160. set tabstop=4
  161. set shiftwidth=4
  162. set shiftround "round indent to shiftwidth
  163. set softtabstop=4
  164. set showmatch "brace/parenthese/bracket matching
  165. set nowrap "wrap long lines
  166. if has("multi_byte")
  167. set showbreak="…"
  168. else
  169. set showbreak="+++"
  170. endif
  171. "show some not printable chars
  172. set list
  173. if has("multi_byte")
  174. set listchars=trail:·,extends:>,precedes:<,nbsp:•,tab:▷\⋅
  175. else
  176. set listchars=tab:>.,trail:·,extends:>,precedes:<,nbsp:%
  177. endif
  178. "search settings
  179. set hlsearch "highlight searches
  180. set incsearch "incremental searches
  181. set ignorecase "ignore case in search patterns
  182. set infercase "smart case support
  183. " }}}
  184. " {{{ Code folding
  185. set foldmethod=indent "fold based on indent
  186. set nofoldenable "dont fold by default
  187. set foldlevel=0
  188. " }}}
  189. " {{{ Email Settings
  190. if has('autocmd')
  191. autocmd BufRead ~/.mutt/tmp/mutt-* set filetype=mail
  192. autocmd FileType mail set autoindent expandtab nocindent formatoptions=tcqn
  193. autocmd FileType mail vmap D dO[...]<CR>
  194. autocmd FileType mail call EnableSpellChecking()
  195. endif
  196. " }}}
  197. " {{{ Spell Checking
  198. "set spellfile=~/.vim/spell/words
  199. function! EnableSpellChecking()
  200. setlocal spell spelllang=fr,en_us
  201. let b:spell = 1
  202. endfunction
  203. function! DisableSpellChecking()
  204. setlocal nospell
  205. unlet b:spell
  206. endfunction
  207. function! ToggleSpell()
  208. if !exists("b:spell")
  209. execute 'call EnableSpellChecking()'
  210. else
  211. execute 'call DisableSpellChecking()'
  212. endif
  213. endfunction
  214. nmap <F4> :call ToggleSpell()<CR>
  215. imap <F4> <Esc>:call ToggleSpell()<CR>a
  216. " }}}
  217. " {{{ Gundo extension Setup
  218. " Gundo sidebar on the right
  219. let g:gundo_right = 1
  220. " Gundo layout
  221. let g:gundo_width = 60
  222. let g:gundo_preview_height = 40
  223. " Gundo status lines
  224. let g:gundo_tree_statusline = "Gundo"
  225. let g:gundo_preview_statusline = "Gundo Preview"
  226. " Preview pane below the buffer
  227. let g:gundo_preview_bottom = 1
  228. " Close Gundo panes on revert
  229. let g:gundo_close_on_revert = 1
  230. " F3 key to show/hide Gundo sidebar
  231. nnoremap <F3> :GundoToggle<CR>
  232. " }}}
  233. " {{{ Syntastic extension Setup
  234. " automatically open/close pane when errors (or not)
  235. let g:syntastic_auto_loc_list = 1
  236. " Redefine errors/warning symbols on sidebar
  237. let g:syntastic_error_symbol = 'EE'
  238. let g:syntastic_style_error_symbol = 'ee'
  239. let g:syntastic_warning_symbol = 'WW'
  240. let g:syntastic_style_warning_symbol = 'Ws'
  241. " redefine default python linter
  242. "let g:syntastic_python_checker = 'pylint'
  243. " add options to python linter
  244. "let g:syntastic_python_checker_args = ''
  245. " }}}
  246. " {{{ ctrlp extension Setup
  247. " Change default key
  248. let g:ctrlp_map = '<c-o>'
  249. " Match window height
  250. let g:ctrlp_max_height = 20
  251. " Add a key to search in opened buffers
  252. map <c-b> :CtrlPBuffer<cr>
  253. " }}}
  254. " {{{ airline extension setup
  255. let g:airline_powerline_fonts=1
  256. let g:airline#extensions#tabline#enabled=1
  257. " }}}
  258. " {{{ tagbar extension setup
  259. nmap <F8> :TagbarToggle<CR>
  260. " }}}
  261. " {{{ Latex settings
  262. let g:tex_conceal = ""
  263. let g:LatexBox_Folding = 1
  264. let g:UltiSnipsExpandTrigger="<tab>"
  265. let g:UltiSnipsJumpForwardTrigger="<tab>"
  266. let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
  267. if has('autocmd')
  268. autocmd FileType tex set foldlevel=0 foldenable
  269. endif
  270. " }}}
  271. " vim: foldmethod=marker foldlevel=0 foldenable