.vimrc 7.5 KB

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