1 " Filename: /etc/vim/vimrc
2 " Purpose: configuration file for vim
3 " Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
4 " Bug-Reports: see http://grml.org/bugs/
5 " License: This file is licensed under the GPL v2.
6 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
8 " All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
9 " /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime you
10 " can find below. If you wish to change any of those settings, you should do it
11 " in the file /etc/vim/vimrc.local, since debian.vim will be overwritten
12 " everytime an upgrade of the vim packages is performed and this file
13 " (/etc/vim/vimrc) every time the package grml-etc-core is upgraded. It is
14 " recommended to make changes after sourcing debian.vim since it alters the
15 " value of the 'compatible' option.
17 " This line should not be removed as it ensures that various options are
18 " properly set to work with the Vim-related packages available in Debian.
21 "" Begin of defaults.vim related stuff {
22 " Do *not* source $VIMRUNTIME/defaults.vim, since that prevents overwriting
23 " values we want to set in this file, instead we set settings similar to
24 " what can be found in default.vim below
25 let g:skip_defaults_vim=1
27 " Use Vim settings, rather than Vi settings (much better!).
28 " This must be first, because it changes other options as a side effect.
31 " Allow backspacing over everything in insert mode.
32 set backspace=indent,eol,start
34 set history=200 " keep 200 lines of command line history
35 set ruler " show the cursor position all the time
36 set showcmd " display incomplete commands
37 set wildmenu " display completion matches in a status line
39 set ttimeout " time out for key codes
40 set ttimeoutlen=100 " wait up to 100ms after Esc for special key
42 " Show @@@ in the last line if it is truncated.
45 " Show a few lines of context around the cursor. Note that this makes the
46 " text scroll if you mouse-click near the start or end of the window.
49 " Do incremental searching when it's possible to timeout.
54 " Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
57 " set nformats=bin,octal,hex
59 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
64 " Don't use Ex mode, use Q for formatting.
65 " Revert with ":unmap Q".
68 " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
69 " so that you can undo CTRL-U after inserting a line break.
70 " Revert with ":iunmap <C-U>".
71 inoremap <C-U> <C-G>u<C-U>
73 " Switch syntax highlighting on when the terminal has colors or when using the
74 " GUI (which always has colors).
75 if &t_Co > 2 || has("gui_running")
76 " Just load the main syntax file when Vim was compiled with "+syntax".
78 " Revert with ":syntax off".
82 " I like highlighting strings inside C comments.
83 " Revert with ":unlet c_comment_strings".
84 let c_comment_strings=1
87 " Only do this part when compiled with support for autocommands.
90 " Enable file type detection.
91 " Use the default filetype settings, so that mail gets 'tw' set to 72,
92 " 'cindent' is on in C files, etc.
93 " Also load indent files, to automatically do language-dependent indenting.
94 " Revert with ":filetype off".
95 filetype plugin indent on
97 " Put these in an autocmd group, so that you can revert them with:
98 " ":augroup vimStartup | au! | augroup END"
102 " When editing a file, always jump to the last known cursor position.
103 " Don't do it when the position is invalid or when inside an event handler
104 " (happens when dropping a file on gvim).
105 autocmd BufReadPost *
106 \ if line("'\"") >= 1 && line("'\"") <= line("$") |
107 \ exe "normal! g`\"" |
112 endif " has("autocmd")
114 " Convenient command to see the difference between the current buffer and the
115 " file it was loaded from, thus the changes you made.
116 " Only define it when not defined already.
117 " Revert with: ":delcommand DiffOrig".
118 if !exists(":DiffOrig")
119 command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
120 \ | wincmd p | diffthis
123 if has('langmap') && exists('+langremap')
124 " Prevent that the langmap option applies to characters that result from a
125 " mapping. If set (default), this may break plugins (but it's backward
130 "" End of defaults.vim related stuff }
132 "" Begin of custom Grml configuration {
133 set autoindent " always set autoindenting on
134 set backspace=2 " specificy what <BS>, CTRL-W, etc. can do in Insert mode
135 set dictionary=/usr/share/dict/word " used with CTRL-X CTRL-K
136 set esckeys " recognize keys that start with <Esc> in insert mode
137 set formatoptions=cqrt " list of flags that tell how automatic formatting works
138 set laststatus=2 " when to use a status line for the last window
139 set nobackup " don't keep a backup file
140 set noerrorbells " don't ring the bell (beep or screen flash) for error messages
141 set nostartofline " keep cursor in the same column (if possible) when moving cursor
142 set pastetoggle=<f11> " don't change text when copy/pasting
143 set shortmess=at " list of flags to make messages shorter
144 set showmatch " show matching brackets.
145 set textwidth=0 " don't wrap lines by default
146 set viminfo=%,'50,\"100,:100,n~/.viminfo " what to store in .viminfo file
147 set visualbell " use a visual bell instead of beeping
148 set whichwrap=<,>,h,l " list of flags specifying which commands wrap to another line
150 " set noet " use appropriate number of spaces to insert a <Tab>
151 " set linebreak " Don't wrap words by default
152 " set ignorecase " Do case insensitive matching
153 " set smartcase " Do smart case matching
154 " set autowrite " Automatically save before commands like :next and :make
155 " set comments=b:#,:%,fb:-,n:>,n:) " definition of what comment lines look like
156 " set nodigraph " enter characters that normally cannot be entered by an ordinary keyboard
158 " list of strings used for list mode
159 " set list listchars=tab:»·,trail:·
160 " set list listchars=tab:»·
161 set listchars=eol:$,precedes:«,extends:»,tab:»·,trail:·
163 " list of file names to search for tags
164 set tags=./tags,./TAGS,tags,TAGS,../tags,../../tags,../../../tags,../../../../tags
166 " When switching between different buffers you can't use undo without 'set hidden':
167 set hidden " Hide buffers when they are abandoned
169 " Suffixes that get lower priority when doing tab completion for filenames.
170 " These are files we are not likely to want to edit or read.
171 set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
173 " If using a dark background within the editing area and syntax highlighting
174 " turn on this option as well
177 " Uncomment the following to have Vim jump to the last position when
180 " au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
181 " \| exe "normal g'\"" | endif
184 " Load indentation rules according to the detected filetype.
185 " Per default Debian Vim only load filetype specific
191 " In many terminal emulators the mouse works just fine. By enabling it you
192 " can position the cursor, Visually select and scroll with the mouse.
196 " We prefer to disable the mouse usage though and use what we're used
197 " from older Vim versions:
202 " set the screen hardstatus to vim(filename.ext)
203 if ((&term =~ '^screen') && ($VIM_PLEASE_SET_TITLE =~ '^yes$') || has('gui_running'))
207 autocmd BufEnter * let &titlestring = "vim(" . expand("%:t") . ")"
208 let &titleold = fnamemodify(&shell, ":t")
212 " when the file type is "mail" then set the textwidth to "70":
214 au FileType mail set tw=70
215 " When editing a file, always jump to the last cursor position
216 " au BufReadPost * if line("'\"") | exe "'\"" | endif
217 autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
220 " some useful mappings:
222 " remove/delete trailing whitespace:
226 " execute the command in the current line (minus the first word, which
227 " is intended to be a shell prompt) and insert the output in the buffer
231 iab YDATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
232 map ,L 1G/Latest change:\s*/e+1<CR>CYDATE<ESC>
234 " Vim 7 brings cool new features - see ':he version7'!
235 " The coolest features of Vim7 by mika
236 " ====================================
237 " 1) omni/intellisense completion: use CTRL-X CTRL-O in insert mode to start it [:he compl-omni]
238 " 2) internal grep: vimgrep foo bar [:he vimgrep]
239 " 3) tab pages: vim -p file1 file2 - then use the :tab command [:he tabpage]
242 " 4) undo branches: :undolist / :earlier 2h / :later 2h
243 " instead of using u (undo) and CTRL-R (redo), you might experiment with g-
244 " and g+ to move through the text state [:he undolist]
245 " 5) browse remote directories via scp using netrw plugin: :edit scp://host//path/to/ [:he netrw.vim]
246 " 6) start editing the filename under the cursor and jump to the line
247 " number following the file name: press gF [:he gF]
248 " 7) press 'CTRL-W F' to start editing the filename under the cursor in a new
249 " window and jump to the line number following the file name. [:he CTRL-W_F]
250 " 8) spelling correction (see later for its configuration) [:he spell]:
251 " ]s -> Move to next misspelled word after the cursor.
252 " zg -> Add word under the cursor as a good word to the first name in 'spellfile'
253 " zw -> Like "zg" but mark the word as a wrong (bad) word.
254 " z= -> For the word under/after the cursor suggest correctly spelled words.
255 " 9) highlight active cursor line using 'set cursorline' [:he cursorline]
256 " 10) delete inner quotes inside HTML-code using <C-O>cit (see its mapping later) [:he tag-blocks]
259 " Thanks for some ideas to Christian 'strcat' Schneider and Julius Plenz
260 " turn spelling on by default:
262 " toggle spelling with F12 key:
263 map <F12> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>
264 set spellfile=~/.vim/spellfile.add
265 " change language - get spell files from http://ftp.vim.org/pub/vim/runtime/spell/ =>
266 " cd ~/.vim/spell && wget http://ftp.vim.org/pub/vim/runtime/spell/de.{latin1,utf-8}.spl
269 " highlight spelling correction:
270 " highlight SpellBad term=reverse ctermbg=12 gui=undercurl guisp=Red " badly spelled word
271 " highlight SpellCap term=reverse ctermbg=9 gui=undercurl guisp=Blue " word with wrong caps
272 " highlight SpellRare term=reverse ctermbg=13 gui=undercurl guisp=Magenta " rare word
273 " highlight SpellLocale term=underline ctermbg=11 gui=undercurl guisp=DarkCyan " word only exists in other region
275 " set maximum number of suggestions listed top 10 items:
276 set spellsuggest=best,10
278 " highlight matching parens:
279 " set matchpairs=(:),[:],{:},< :>
280 " let loaded_matchparen = 1
281 " highlight MatchParen term=reverse ctermbg=7 guibg=cornsilk
283 " highlight the cursor line and column:
285 " highlight CursorLine term=reverse ctermbg=7 guibg=#333333
286 " highlight CursorColumn guibg=#333333
288 " change inner tag - very useful e.g. within HTML-code!
289 " ci" will remove the text between quotes, also works for ' and `
292 " use the popup menu also when there is only one match:
293 " set completeopt=menuone
294 " determine the maximum number of items to show in the popup menu for:
296 " set completion highlighting:
297 " highlight Pmenu ctermbg=13 guifg=Black guibg=#BDDFFF " normal item
298 " highlight PmenuSel ctermbg=7 guifg=Black guibg=Orange " selected item
299 " highlight PmenuSbar ctermbg=7 guifg=#CCCCCC guibg=#CCCCCC " scrollbar
300 " highlight PmenuThumb cterm=reverse gui=reverse guifg=Black guibg=#AAAAAA " thumb of the scrollbar
304 " To enable persistent undo uncomment following section.
305 " The undo files will be stored in $HOME/.cache/vim
308 " " enable persistent-undo
311 " " store the persistent undo file in ~/.cache/vim
312 " set undodir=~/.cache/vim/
314 " " create undodir directory if possible and does not exist yet
315 " let targetdir=$HOME . "/.cache/vim"
316 " if isdirectory(targetdir) != 1 && getftype(targetdir) == "" && exists("*mkdir")
317 " call mkdir(targetdir, "p", 0700)
321 " Source a global configuration file if available
322 " Deprecated by Debian but still supported by grml
323 if filereadable("/etc/vim/vimrc.local")
324 source /etc/vim/vimrc.local
327 " source user-specific local configuration file
328 if filereadable(expand("$HOME/.vimrc.local"))
329 source $HOME/.vimrc.local
331 "" End of custom Grml configuration }
333 "# END OF FILE #################################################################