.vimrc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. "reopen current file
  54. map <F5> :e!<CR>
  55. "using redraw to disable highlighted search patterns
  56. nnoremap <C-L> :nohl<CR><C-L>
  57. "map F1 to open previous buffer
  58. nmap <F1> :bp<CR>
  59. imap <F1> <ESC>:bp<CR>a
  60. "map F2 to open next buffer
  61. nmap <F2> :bn<CR>
  62. imap <F2> <ESC>:bn<CR>a
  63. "imap <C-Space> <C-X><C-O> "smart completion
  64. map <C-u> :u<CR>
  65. nmap <C-i> :tabnext<CR>
  66. "nmap <C-S-i> :tabprevious<CR>
  67. nmap <C-t> :tabnew<CR>
  68. "nmap <C-M-w> :tabclose<CR>
  69. nmap <C-q> :call CleanClose()<CR>
  70. nmap <F6> :vsplit<CR>
  71. nmap <F7> :split<CR>
  72. "ctrl-$arrow no cycle around splitted windows
  73. map <C-left> <C-W>h
  74. map <C-right> <C-W>l
  75. map <C-Up> <C-W>k
  76. map <C-Down> <C-W>j
  77. "ident in visual mode keep selection
  78. vmap > >gv
  79. vmap < <gv
  80. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  81. " Editor Settings
  82. "
  83. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  84. set fileformats=unix,dos,mac "support all three, in this order
  85. set hidden "make possible to change buffer without saving
  86. set backspace=indent,eol,start "enhance backspacing
  87. set report=0 "agressive reporting
  88. set pastetoggle=<F11> "use <F11> to toggle between 'paste' and 'nopaste'
  89. set nostartofline "leave the cursor where it is
  90. "indent settings
  91. set autoindent
  92. set smartindent
  93. set cindent
  94. "tabs and spaces settings
  95. set tabstop=4
  96. set shiftwidth=4
  97. set shiftround "round indent to shiftwidth
  98. set softtabstop=4
  99. set expandtab "no real tabs
  100. set showmatch "brace/parenthese/bracket matching
  101. set nowrap "wrap long lines
  102. set showbreak="++++ "
  103. "show some not printable chars
  104. set list
  105. set listchars=tab:>.,trail:·,extends:>,precedes:<,nbsp:%
  106. "search settings
  107. set hlsearch "highlight searches
  108. set incsearch "incremental searches
  109. set ignorecase "ignore case in search patterns
  110. set infercase "smart case support
  111. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  112. " Filetypes Settings
  113. "
  114. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  115. filetype plugin indent on
  116. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  117. " Global Triggers
  118. "
  119. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  120. "reload Vim config file after saving
  121. autocmd BufWritePost ~/.vimrc :source ~/.vimrc
  122. "always limit the width for text files
  123. autocmd BufRead *.txt set tw=78
  124. autocmd QuickFixCmdPre * botright cwindow 5
  125. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  126. " Spell Checking
  127. "
  128. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  129. function! ToggleSpell()
  130. if !exists("b:spell")
  131. setlocal spell spelllang=fr,en_us
  132. let b:spell = 1
  133. else
  134. setlocal nospell
  135. unlet b:spell
  136. endif
  137. endfunction
  138. nmap <F4> :call ToggleSpell()<CR>
  139. imap <F4> <Esc>:call ToggleSpell()<CR>a
  140. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  141. " TagList setup
  142. "
  143. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  144. " Settings for taglist.vim
  145. let Tlist_Use_Right_Window=1
  146. let Tlist_Auto_Open=0
  147. "let Tlist_Enable_Fold_Column=0
  148. let Tlist_Compact_Format=1
  149. "let Tlist_WinWidth=28
  150. let Tlist_Exit_OnlyWindow=1
  151. let Tlist_File_Fold_Auto_Close=1
  152. let Tlist_Process_File_Always=1
  153. "dip F1 to open previous buffersplay tags only for the current buffer
  154. let Tlist_Show_One_File=1
  155. let Tlist_Use_SingleClick=1
  156. let Tlist_Ctags_Cmd="~/.vim/bin/ctags-exuberant"
  157. nnoremap <silent> <F9> :Tlist<CR>
  158. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  159. " Useful functions
  160. "
  161. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  162. function! CleanClose()
  163. let todelbufNr = bufnr("%")
  164. let newbufNr = bufnr("#")
  165. if ((newbufNr != -1) && (newbufNr != todelbufNr) && buflisted(newbufNr))
  166. exe "b".newbufNr
  167. else
  168. bnext
  169. endif
  170. if (bufnr("%") == todelbufNr)
  171. new
  172. endif
  173. exe "bd".todelbufNr
  174. endfunction