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 {
23 " | Comments starting with a bar ('|') are added by the Grml-Team
24 " | and the settings below override the default.vim configuration everything
25 " | else is copied from $VIMRUNTIME/defaults.vim.
27 " | Do *not* source $VIMRUNTIME/defaults.vim (in case no user vimrc is found),
28 " | since that prevents overwriting values we want to set in this file,
29 " | instead we set settings similar to what can be found in default.vim below
30 let g:skip_defaults_vim=1
32 " Use Vim settings, rather than Vi settings (much better!).
33 " This must be first, because it changes other options as a side effect.
34 " Avoid side effects when it was already reset.
39 " When the +eval feature is missing, the set command above will be skipped.
40 " Use a trick to reset compatible only when the +eval feature is missing.
45 " Allow backspacing over everything in insert mode.
46 set backspace=indent,eol,start
48 set history=200 " keep 200 lines of command line history
49 set ruler " show the cursor position all the time
50 set showcmd " display incomplete commands
51 set wildmenu " display completion matches in a status line
53 set ttimeout " time out for key codes
54 set ttimeoutlen=100 " wait up to 100ms after Esc for special key
56 " Show @@@ in the last line if it is truncated.
59 " Show a few lines of context around the cursor. Note that this makes the
60 " text scroll if you mouse-click near the start or end of the window.
63 " Do incremental searching when it's possible to timeout.
68 " Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
72 " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
77 " Don't use Ex mode, use Q for formatting.
78 " Revert with ":unmap Q".
81 " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
82 " so that you can undo CTRL-U after inserting a line break.
83 " Revert with ":iunmap <C-U>".
84 inoremap <C-U> <C-G>u<C-U>
86 " In many terminal emulators the mouse works just fine. By enabling it you
87 " can position the cursor, Visually select and scroll with the mouse.
89 " | We prefer to disable the mouse usage though and use what we're used
90 " | from older Vim versions.
99 " Switch syntax highlighting on when the terminal has colors or when using the
100 " GUI (which always has colors).
101 if &t_Co > 2 || has("gui_running")
102 " Revert with ":syntax off".
105 " I like highlighting strings inside C comments.
106 " Revert with ":unlet c_comment_strings".
107 let c_comment_strings=1
110 " Only do this part when Vim was compiled with the +eval feature.
113 " Enable file type detection.
114 " Use the default filetype settings, so that mail gets 'tw' set to 72,
115 " 'cindent' is on in C files, etc.
116 " Also load indent files, to automatically do language-dependent indenting.
117 " Revert with ":filetype off".
118 filetype plugin indent on
120 " Put these in an autocmd group, so that you can revert them with:
121 " ":augroup vimStartup | au! | augroup END"
125 " When editing a file, always jump to the last known cursor position.
126 " Don't do it when the position is invalid, when inside an event handler
127 " (happens when dropping a file on gvim) and for a commit message (it's
128 " likely a different one than last time).
129 autocmd BufReadPost *
130 \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
131 \ | exe "normal! g`\""
138 " Convenient command to see the difference between the current buffer and the
139 " file it was loaded from, thus the changes you made.
140 " Only define it when not defined already.
141 " Revert with: ":delcommand DiffOrig".
142 if !exists(":DiffOrig")
143 command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
144 \ | wincmd p | diffthis
147 if has('langmap') && exists('+langremap')
148 " Prevent that the langmap option applies to characters that result from a
149 " mapping. If set (default), this may break plugins (but it's backward
154 " | End of defaults.vim related stuff }
156 " Begin of custom Grml configuration {
157 " The Grml-Team believes that the options and configuration values which override
158 " the Vim defaults are useful and helpful for our users.
160 " A lot of options are Grml defaults since the very start and we cleaned up as
161 " much as possible but if you do not like any of these settings feel free to
162 " change them back in your user vimrc or file a bug and tell us to change the
165 " The idea behind commented out options and configuration values is to show
166 " you interesting settings you should know about but we did not set them by
167 " default because they might have to much of an impact for everyone.
169 " If a commented option precedes an option set by us it usually shows the
172 set autoindent " always set autoindenting on
173 set dictionary=/usr/share/dict/words " used with CTRL-X CTRL-K
174 set esckeys " recognize keys that start with <Esc> in insert mode
175 set formatoptions=cqrt " list of flags that tell how automatic formatting works
176 set laststatus=2 " when to use a status line for the last window
177 set nobackup " don't keep a backup file
178 set noerrorbells " don't ring the bell (beep or screen flash) for error messages
179 set nostartofline " keep cursor in the same column (if possible) when moving cursor
180 set pastetoggle=<f11> " don't change text when copy/pasting
181 set shortmess=at " list of flags to make messages shorter
182 set showmatch " show matching brackets.
183 set textwidth=0 " don't wrap lines by default
184 set viminfo=%,'100,<100,s10,h " what to store in .viminfo file
185 set visualbell " use a visual bell instead of beeping
186 set whichwrap=<,>,h,l " list of flags specifying which commands wrap to another line
188 " set expandtab " Use appropriate number of spaces to insert a <Tab>
189 " set linebreak " Don't wrap words by default
190 set ignorecase " Do case insensitive matching
191 set smartcase " Do smart case matching
192 " set autowrite " Automatically save before commands like :next and :make
193 " set nodigraph " enter characters that normally cannot be entered by an ordinary keyboard
195 " list of strings used for list mode
196 " set list listchars=eol:$
197 set listchars=eol:$,precedes:«,extends:»,tab:»·,trail:·
199 " list of file names to search for tags
200 " set tags=./tags,tags
201 set tags=./tags,./TAGS,tags,TAGS,../tags,../../tags,../../../tags,../../../../tags
203 " When switching between different buffers you can't use undo without 'set hidden':
204 set hidden " Hide buffers when they are abandoned
206 " Suffixes that get lower priority when doing tab completion for filenames.
207 " These are files we are not likely to want to edit or read.
208 " set suffixes=.bak,~,.o,.h,.info,.swp,.obj
209 set suffixes=.bak,~,.o,.h,.info,.swp,.obj,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
211 " set the screen hardstatus to vim(filename.ext)
212 if ((&term =~ '^screen') && ($VIM_PLEASE_SET_TITLE =~ '^yes$') || has('gui_running'))
217 autocmd BufEnter * let &titlestring = "vim(" . expand("%:t") . ")"
219 let &titleold = fnamemodify(&shell, ":t")
224 " when the file type is "mail" then set the textwidth to "70":
225 autocmd FileType mail set tw=70
228 " some useful mappings:
230 " remove/delete trailing whitespace:
234 " execute the command in the current line (minus the first word, which
235 " is intended to be a shell prompt) and insert the output in the buffer
239 iab YDATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
240 map ,L 1G/Latest change:\s*/e+1<CR>CYDATE<ESC>
242 " Vim 7 brings cool new features - see ':he version7'!
243 " The coolest features of Vim7 by mika
244 " ====================================
245 " 1) omni/intellisense completion: use CTRL-X CTRL-O in insert mode to start it [:he compl-omni]
246 " 2) internal grep: vimgrep foo bar [:he vimgrep]
247 " 3) tab pages: vim -p file1 file2 - then use the :tab command [:he tabpage]
250 " 4) undo branches: :undolist / :earlier 2h / :later 2h
251 " instead of using u (undo) and CTRL-R (redo), you might experiment with g-
252 " and g+ to move through the text state [:he undolist]
253 " 5) browse remote directories via scp using netrw plugin: :edit scp://host//path/to/ [:he netrw.vim]
254 " 6) start editing the filename under the cursor and jump to the line
255 " number following the file name: press gF [:he gF]
256 " 7) press 'CTRL-W F' to start editing the filename under the cursor in a new
257 " window and jump to the line number following the file name. [:he CTRL-W_F]
258 " 8) spelling correction (see later for its configuration) [:he spell]:
259 " ]s -> Move to next misspelled word after the cursor.
260 " zg -> Add word under the cursor as a good word to the first name in 'spellfile'
261 " zw -> Like "zg" but mark the word as a wrong (bad) word.
262 " z= -> For the word under/after the cursor suggest correctly spelled words.
263 " 9) highlight active cursor line using 'set cursorline' [:he cursorline]
264 " 10) delete inner quotes inside HTML-code using <C-O>cit (see its mapping later) [:he tag-blocks]
267 " Thanks for some ideas to Christian 'strcat' Schneider and Julius Plenz
268 " turn spelling on by default:
270 " toggle spelling with F12 key:
271 map <F12> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>
272 set spellfile=~/.vim/spellfile.add
273 " change language - get spell files from http://ftp.vim.org/pub/vim/runtime/spell/ =>
274 " cd ~/.vim/spell && wget http://ftp.vim.org/pub/vim/runtime/spell/de.{latin1,utf-8}.spl
277 " highlight spelling correction:
278 " highlight SpellBad term=reverse ctermbg=12 gui=undercurl guisp=Red " badly spelled word
279 " highlight SpellCap term=reverse ctermbg=9 gui=undercurl guisp=Blue " word with wrong caps
280 " highlight SpellRare term=reverse ctermbg=13 gui=undercurl guisp=Magenta " rare word
281 " highlight SpellLocale term=underline ctermbg=11 gui=undercurl guisp=DarkCyan " word only exists in other region
283 " set maximum number of suggestions listed top 10 items:
284 set spellsuggest=best,10
286 " highlight matching parens:
287 " set matchpairs=(:),[:],{:},< :>
288 " let loaded_matchparen = 1
289 " highlight MatchParen term=reverse ctermbg=7 guibg=cornsilk
291 " highlight the cursor line and column:
293 " highlight CursorLine term=reverse ctermbg=7 guibg=#333333
294 " highlight CursorColumn guibg=#333333
296 " change inner tag - very useful e.g. within HTML-code!
297 " ci" will remove the text between quotes, also works for ' and `
300 " use the popup menu also when there is only one match:
301 " set completeopt=menuone
302 " determine the maximum number of items to show in the popup menu for:
304 " set completion highlighting:
305 " highlight Pmenu ctermbg=13 guifg=Black guibg=#BDDFFF " normal item
306 " highlight PmenuSel ctermbg=7 guifg=Black guibg=Orange " selected item
307 " highlight PmenuSbar ctermbg=7 guifg=#CCCCCC guibg=#CCCCCC " scrollbar
308 " highlight PmenuThumb cterm=reverse gui=reverse guifg=Black guibg=#AAAAAA " thumb of the scrollbar
311 " To enable persistent undo uncomment following section.
312 " The undo files will be stored in $HOME/.cache/vim
315 " " enable persistent-undo
318 " " store the persistent undo file in ~/.cache/vim
319 " set undodir=~/.cache/vim/
321 " " create undodir directory if possible and does not exist yet
322 " let targetdir=$HOME . "/.cache/vim"
323 " if isdirectory(targetdir) != 1 && getftype(targetdir) == "" && exists("*mkdir")
324 " call mkdir(targetdir, "p", 0700)
328 " Source a global configuration file if available
329 if filereadable("/etc/vim/vimrc.local")
330 source /etc/vim/vimrc.local
333 " source user-specific local configuration file
335 " NOTE: If this vimrc file is used as system vimrc the initialization of Vim looks like this:
337 " `system-vimrc (this file) + /etc/vim/vimrc.local + $HOME/.vimrc.local -> user-vimrc`
339 " This means that user-vimrc overrides the settings set in `$HOME/.vimrc.local`.
341 " If this file is used as user-vimrc the initialization of Vim looks like this
343 " `system-vimrc + /etc/vim/vimrc.local -> user-vimrc (this file) + /etc/vim/vimrc.local + $HOME/.vimrc.local`
345 " This means that `/etc/vim/vimrc.local` + `$HOME/.vimrc.local` overrides the
346 " settings set in the user-vimrc (and `/etc/vim/vimrc.local` is sourced twice).
348 " Either way, this might or might not be something a user would expect.
349 if filereadable(expand("$HOME/.vimrc.local"))
350 source $HOME/.vimrc.local
353 " End of custom Grml configuration }
355 "# END OF FILE #################################################################