.vimrc 7.2 KB

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