.vimrc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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 'http://git.openics.org/kolter/vim-bindzone.git'
  32. call plug#end()
  33. " }}}
  34. " {{{ General Settings
  35. " Filetypes Settings
  36. if has('autocmd')
  37. filetype plugin indent on
  38. "reload Vim config file after saving
  39. "autocmd BufWritePost $MYVIMRC :source $MYVIMRC
  40. "always limit the width for text files
  41. autocmd BufRead *.txt set tw=78
  42. autocmd QuickFixCmdPre * botright cwindow 5
  43. endif
  44. "Term settings (under tmux)
  45. if &term =~ '^screen'
  46. "tmux will send xterm-style keys when its xterm-keys option is on
  47. execute "set <xUp>=\e[1;*A"
  48. execute "set <xDown>=\e[1;*B"
  49. execute "set <xRight>=\e[1;*C"
  50. execute "set <xLeft>=\e[1;*D"
  51. endif
  52. set nocompatible "no vi compatibility
  53. set history=1000 "command history size
  54. set undolevels=120 "undo levels count
  55. set autoread "notify file changes
  56. set autochdir "switch to the current file directory
  57. set clipboard+=unnamed "share system clipboard
  58. set backup "enable backups
  59. set backupdir=~/.vim/backups "backup directory
  60. set directory=~/.vim/tmp "directory to place swap files in
  61. "Encoding settings
  62. if has("multi_byte")
  63. if &termencoding == ""
  64. let &termencoding = &encoding
  65. endif
  66. set encoding=utf-8
  67. setglobal fileencoding=utf-8
  68. set fileencodings=utf-8,default,latin1,ucs-bom
  69. endif
  70. "Syntax highlight
  71. syntax on
  72. set t_Co=256
  73. set bg=dark
  74. colorscheme grb256
  75. " }}}
  76. " {{{ Interface Settings
  77. set title "show title
  78. set number "show line numbers
  79. set ruler "statusline for each window
  80. set visualbell t_vb= "visual beep
  81. set showcmd "show incomplete commands
  82. set confirm "raise a dialog asking what to do instead of failing
  83. "set mouse=a "enable mouse support
  84. set lazyredraw "do not redraw when running macros
  85. set ttyfast "fast terminal connection support
  86. set ttimeout
  87. set ttimeoutlen=100
  88. set scrolloff=999
  89. set sidescrolloff=5
  90. set shortmess=a "abbreviations on status line
  91. set laststatus=2 "always statusline
  92. set wildmenu "display completion menu
  93. set wildmode=list:longest,list:full "content of completion menu
  94. "ignore some extensions while completing filename
  95. "set wildignore=*.o,*.so,,*.gz,*.bz2,*.tar,*.tgz,*.tbz2,*.png,*.jpg,*.jpeg,*.gif
  96. set wildchar=<TAB> "wildcar expansion character
  97. set modeline "allow last lines of documents set vim mode
  98. set modelines=3 "number of lines to check for modelines
  99. " }}}
  100. " {{{ Keyboard Settings
  101. " keep ctrl-a/ctrl-e for begining/end of line
  102. nmap <c-a> <c-o>I
  103. imap <c-a> <c-o>I
  104. vmap <c-a> <c-o>I
  105. nmap <c-e> <c-o>A
  106. imap <c-e> <c-o>A
  107. vmap <c-e> <c-o>A
  108. "reopen current file
  109. map <F5> :e!<cr>
  110. "using redraw to disable highlighted search patterns
  111. nnoremap <c-L> :nohl<cr><c-L>
  112. "map F1 to open previous buffer
  113. nmap <F1> :bp<cr>
  114. imap <F1> <ESC>:bp<cr>a
  115. "map F2 to open next buffer
  116. nmap <F2> :bn<cr>
  117. imap <F2> <ESC>:bn<cr>a
  118. imap <c-@> <c-x><c-o>
  119. nmap <c-s-left> :tabprevious<cr>
  120. nmap <c-s-right> :tabnext<cr>
  121. nmap <c-s-up> :tabnew<cr>
  122. nmap <c-s-down> :tabclose<cr>
  123. nmap <c-d> :bw<cr>
  124. nmap <F6> :vsplit<cr>
  125. nmap <F7> :split<cr>
  126. "ctrl-$arrow to cycle around splitted windows
  127. map <c-left> <c-w>h
  128. map <c-right> <c-w>l
  129. map <c-Up> <c-w>k
  130. map <c-Down> <c-w>j
  131. "ident in visual mode keep selection
  132. vmap > >gv
  133. vmap < <gv
  134. " }}}
  135. " {{{ Editor Settings
  136. set fileformats=unix,dos,mac "support all three, in this order
  137. set hidden "make possible to change buffer without saving
  138. set report=0 "agressive reporting
  139. set pastetoggle=<F11> "use <F11> to toggle between 'paste' and 'nopaste'
  140. set nostartofline "leave the cursor where it is
  141. "indent settings
  142. set autoindent
  143. set backspace=indent,eol,start "enhance backspacing
  144. set smartindent
  145. set cindent
  146. set smarttab
  147. "tabs and spaces settings
  148. set expandtab "tab are spaces
  149. set tabstop=4
  150. set shiftwidth=4
  151. set shiftround "round indent to shiftwidth
  152. set softtabstop=4
  153. set showmatch "brace/parenthese/bracket matching
  154. set nowrap "wrap long lines
  155. if has("multi_byte")
  156. set showbreak="…"
  157. else
  158. set showbreak="+++"
  159. endif
  160. "show some not printable chars
  161. set list
  162. if has("multi_byte")
  163. set listchars=trail:·,extends:>,precedes:<,nbsp:•,tab:▷\⋅
  164. else
  165. set listchars=tab:>.,trail:·,extends:>,precedes:<,nbsp:%
  166. endif
  167. "search settings
  168. set hlsearch "highlight searches
  169. set incsearch "incremental searches
  170. set ignorecase "ignore case in search patterns
  171. set infercase "smart case support
  172. " }}}
  173. " {{{ Code folding
  174. set foldmethod=indent "fold based on indent
  175. set foldnestmax=10 "deepest fold is 10 levels
  176. set nofoldenable "dont fold by default
  177. set foldlevel=1
  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. " vim: foldmethod=marker foldlevel=0 foldenable