.vimrc 7.4 KB

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