vimrc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. "
  2. " Vim configuration file (~/.vimrc)
  3. " 2009, 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. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  9. " General Settings
  10. "
  11. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  12. set nocompatible "no vi compatibility
  13. set history=200 "command history size
  14. set undolevels=120 "undo levels count
  15. set autoread "notify file changes
  16. set autochdir "switch to the current file directory
  17. set clipboard+=unnamed "share system clipboard
  18. set backup "enable backups
  19. set backupdir=~/.vim/backups "backup directory
  20. set directory=~/.vim/tmp "directory to place swap files in
  21. "Syntax highlight
  22. syntax on
  23. set t_Co=256
  24. set bg=dark
  25. colorscheme xoria256
  26. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  27. " Interface Settings
  28. "
  29. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  30. set title "show title
  31. set number "show line numbers
  32. set ruler "statusline for each window
  33. set visualbell t_vb= "visual beep
  34. set showcmd "show incomplete commands
  35. set confirm "raise a dialog asking what to do instead of failing
  36. "set mouse=a "enable mouse support
  37. set lazyredraw "do not redraw when running macros
  38. set ttyfast "fast terminal connection support
  39. set shortmess=a "abbreviations on status line
  40. set laststatus=2 "always statusline
  41. set statusline=%<%F\ %h%m%r%y%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",B\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P
  42. set wildmenu "display completion menu
  43. set wildmode=list:longest,list:full "content of completion menu
  44. "ignore some extensions while completing filename
  45. "set wildignore=*.o,*.so,,*.gz,*.bz2,*.tar,*.tgz,*.tbz2,*.png,*.jpg,*.jpeg,*.gif
  46. set wildchar=<TAB> "wildcar expansion character
  47. set modeline "allow last lines of documents set vim mode
  48. set modelines=3 "number of lines to check for modelines
  49. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  50. " Keyboard Settings
  51. "
  52. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  53. " keep ctrl-a/ctrl-e for begining/end of line
  54. nmap <C-a> 0i
  55. imap <C-a> <esc>0i
  56. vmap <C-a> 0i
  57. nmap <C-e> $i<right>
  58. imap <C-e> <esc>$i<right>
  59. vmap <C-e> $i<right>
  60. "reopen current file
  61. map <F5> :e!<CR>
  62. "using redraw to disable highlighted search patterns
  63. nnoremap <C-L> :nohl<CR><C-L>
  64. "map F1 to open previous buffer
  65. nmap <F1> :bp<CR>
  66. imap <F1> <ESC>:bp<CR>a
  67. "map F2 to open next buffer
  68. nmap <F2> :bn<CR>
  69. imap <F2> <ESC>:bn<CR>a
  70. "imap <C-Space> <C-X><C-O> "smart completion
  71. nmap <C-u> :u<CR>
  72. imap <C-u> <esc>:u<CR>
  73. nmap <C-i> :tabnext<CR>
  74. "nmap <C-S-i> :tabprevious<CR>
  75. nmap <C-t> :tabnew<CR>
  76. "nmap <C-M-w> :tabclose<CR>
  77. nmap <C-q> :call CleanClose()<CR>
  78. nmap <F6> :vsplit<CR>
  79. nmap <F7> :split<CR>
  80. "ctrl-$arrow no cycle around splitted windows
  81. map <C-left> <C-W>h
  82. map <C-right> <C-W>l
  83. map <C-Up> <C-W>k
  84. map <C-Down> <C-W>j
  85. "ident in visual mode keep selection
  86. vmap > >gv
  87. vmap < <gv
  88. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  89. " Editor Settings
  90. "
  91. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  92. set fileformats=unix,dos,mac "support all three, in this order
  93. set hidden "make possible to change buffer without saving
  94. set backspace=indent,eol,start "enhance backspacing
  95. set report=0 "agressive reporting
  96. set pastetoggle=<F11> "use <F11> to toggle between 'paste' and 'nopaste'
  97. set nostartofline "leave the cursor where it is
  98. "indent settings
  99. set autoindent
  100. set smartindent
  101. set cindent
  102. "tabs and spaces settings
  103. set tabstop=4
  104. set shiftwidth=4
  105. set shiftround "round indent to shiftwidth
  106. set softtabstop=4
  107. set expandtab "no real tabs
  108. set showmatch "brace/parenthese/bracket matching
  109. set nowrap "wrap long lines
  110. set showbreak="++++ "
  111. "show some not printable chars
  112. set list
  113. set listchars=tab:>.,trail:·,extends:>,precedes:<,nbsp:%
  114. "search settings
  115. set hlsearch "highlight searches
  116. set incsearch "incremental searches
  117. set ignorecase "ignore case in search patterns
  118. set infercase "smart case support
  119. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  120. " Email Settings
  121. "
  122. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  123. autocmd BufRead ~/.mutt/tmp/mutt-* set filetype=mail
  124. autocmd FileType mail set autoindent expandtab formatoptions=tcqn
  125. autocmd FileType mail vmap D dO[...]<CR>
  126. autocmd FileType mail call EnableSpellChecking()
  127. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  128. " Filetypes Settings
  129. "
  130. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  131. filetype plugin indent on
  132. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  133. " Global Triggers
  134. "
  135. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  136. "reload Vim config file after saving
  137. autocmd BufWritePost ~/.vimrc :source ~/.vimrc
  138. "always limit the width for text files
  139. autocmd BufRead *.txt set tw=78
  140. autocmd QuickFixCmdPre * botright cwindow 5
  141. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  142. " Spell Checking
  143. "
  144. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  145. "set spellfile=~/.vim/spell/words
  146. function EnableSpellChecking()
  147. setlocal spell spelllang=fr,en_us
  148. let b:spell = 1
  149. endfunction
  150. function DisableSpellChecking()
  151. setlocal nospell
  152. unlet b:spell
  153. endfunction
  154. function! ToggleSpell()
  155. if !exists("b:spell")
  156. execute 'call EnableSpellChecking()'
  157. else
  158. execute 'call DisableSpellChecking()'
  159. endif
  160. endfunction
  161. nmap <F4> :call ToggleSpell()<CR>
  162. imap <F4> <Esc>:call ToggleSpell()<CR>a
  163. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  164. " TagList setup
  165. "
  166. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  167. " Settings for taglist.vim
  168. let Tlist_Use_Right_Window=1
  169. let Tlist_Auto_Open=0
  170. "let Tlist_Enable_Fold_Column=0
  171. let Tlist_Compact_Format=1
  172. "let Tlist_WinWidth=28
  173. let Tlist_Exit_OnlyWindow=1
  174. let Tlist_File_Fold_Auto_Close=1
  175. let Tlist_Process_File_Always=1
  176. "dip F1 to open previous buffersplay tags only for the current buffer
  177. let Tlist_Show_One_File=1
  178. let Tlist_Use_SingleClick=1
  179. let Tlist_Ctags_Cmd="~/.vim/bin/ctags-exuberant"
  180. nnoremap <silent> <F9> :Tlist<CR>
  181. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  182. " Useful functions
  183. "
  184. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  185. function! CleanClose()
  186. let todelbufNr = bufnr("%")
  187. let newbufNr = bufnr("#")
  188. if ((newbufNr != -1) && (newbufNr != todelbufNr) && buflisted(newbufNr))
  189. exe "b".newbufNr
  190. else
  191. bnext
  192. endif
  193. if (bufnr("%") == todelbufNr)
  194. new
  195. endif
  196. exe "bd".todelbufNr
  197. endfunction