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 " Uncomment the next line to make Vim more Vi-compatible
22 " NOTE: debian.vim sets 'nocompatible', but only if debian.vim is available,
23 " so let's make sure we run in nocompatible mode:
26 " Setting 'compatible' changes numerous
27 " options, so any other options should be set AFTER setting 'compatible'.
30 set backspace=indent,eol,start " more powerful backspacing
32 " Now we set some defaults for the editor
33 set autoindent " always set autoindenting on
34 " set linebreak " Don't wrap words by default
35 set textwidth=0 " Don't wrap lines by default
36 set nobackup " Don't keep a backup file
37 set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
38 " 50 lines of registers
39 set history=50 " keep 50 lines of command line history
40 set ruler " show the cursor position all the time
42 " Suffixes that get lower priority when doing tab completion for filenames.
43 " These are files we are not likely to want to edit or read.
44 set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
46 " Vim5 and later versions support syntax highlighting.
47 " Just load the main syntax file when Vim was compiled with "+syntax".
52 " Debian uses compressed helpfiles. We must inform vim that the main
53 " helpfiles is compressed. Other helpfiles are stated in the tags-file.
54 " set helpfile=$VIMRUNTIME/doc/help.txt.gz
56 " If using a dark background within the editing area and syntax highlighting
57 " turn on this option as well
60 " begin of grml specials:
61 " set list listchars=tab:»·
62 " set listchars=eol:$,precedes:«,extends:»,tab:··,trail:·
63 " end of grml specials
65 " Uncomment the following to have Vim jump to the last position when
68 " au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
69 " \| exe "normal g'\"" | endif
72 " Uncomment the following to have Vim load indentation rules according to the
73 " detected filetype. Per default Debian Vim only load filetype specific
79 " The following are commented out as they cause vim to behave a lot
80 " differently from regular Vi. They are highly recommended though.
81 set showcmd " Show (partial) command in status line.
82 set showmatch " Show matching brackets.
83 " set ignorecase " Do case insensitive matching
84 " set smartcase " Do smart case matching
85 " set incsearch " Incremental search
86 " set autowrite " Automatically save before commands like :next and :make
87 " When switching between different buffers you can't use undo without 'set hidden':
88 set hidden " Hide buffers when they are abandoned
89 " set mouse=a " Enable mouse usage (all modes) in terminals
90 set wildmenu " command-line completion operates in an enhanced mode
92 set pastetoggle=<f11> " don't change text when copy/pasting
93 set dictionary=/usr/share/dict/word " used with CTRL-X CTRL-K
95 """ set the screen hardstatus to vim(filename.ext)
96 if ((&term =~ '^screen') && ($VIM_PLEASE_SET_TITLE =~ '^yes$') || has('gui_running'))
100 autocmd BufEnter * let &titlestring = "vim(" . expand("%:t") . ")"
101 let &titleold = fnamemodify(&shell, ":t")
107 " turn these OFF ("no" prefix):
108 set nodigraph noeb noet nosol
110 set bs=2 fo=cqrt ls=2 shm=at ww=<,>,h,l
111 " set bs=2 fo=cqrt ls=2 shm=at tw=72 ww=<,>,h,l
112 set comments=b:#,:%,fb:-,n:>,n:)
113 " set list listchars=tab:»·,trail:·
114 set listchars=eol:$,precedes:«,extends:»,tab:»·,trail:·
115 set viminfo=%,'50,\"100,:100,n~/.viminfo
116 set tags=./tags,./TAGS,tags,TAGS,../tags,../../tags,../../../tags,../../../../tags
119 " when the file type is "mail" then set the textwidth to "70":
121 au FileType mail set tw=70
122 " When editing a file, always jump to the last cursor position
123 " au BufReadPost * if line("'\"") | exe "'\"" | endif
124 autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
127 " some colors - as an example "white on black" [use bold fonts]:
128 " hi normal ctermfg=white ctermbg=black guifg=white guibg=black
129 " hi nontext ctermfg=blue ctermbg=black guifg=blue guibg=black
130 " set t_Co=256 " number of colors
132 " some useful mappings:
134 " with F7 copy all current buffer to clipboard, or a selection.
135 " with shift-F7, paste all clipboard contents
136 " see: http://www.vim.org/tips/tip.php?tip_id=964
137 map <F7> :w !xclip<CR><CR>
139 map <S-F7> :r!xclip -o<CR>
141 " remove/delete trailing whitespace:
145 " execute the command in the current line (minus the first word, which
146 " is intended to be a shell prompt) and insert the output in the buffer
150 iab YDATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
151 map ,L 1G/Latest change:\s*/e+1<CR>CYDATE<ESC>
153 " the shell in a box mode. found in posting by Stefan `Sec` Zehl
154 " in newsgroup de.alt.sysadmin.recovery, msgid: <df7lhe$2hup$1@ice.42.org>
155 " Requires zsh for "print -P $PS1" / replace if needed.
156 " Your prompt should end in > (and only contain one)
157 " so run something like:
158 " % export PS1='%n@%m > '
159 " in your zsh, press ',l' and <enter> for running commands, end mode via <esc>
160 map __start :imap <C-V><C-M> <C-O>__cmd<C-V>\|imap <C-V><ESC> <C-V><ESC>__end<C-M>
161 noremap __end :iunmap <C-V><CR>\|iunmap <C-V><ESC><C-M>:"Vish ended.<C-M>
162 noremap __cmd 0<ESC>f>ly$:r !<C-R>";print -P $PS1<C-M>A
163 noremap __scmd :r !print -P $PS1<c-M>A
166 " Kill quote spaces (when quoting a quote)
167 map ,kqs mz:%s/^> >/>>/<cr>
169 " Interface to Mercurial Version Control
170 if filereadable( "/usr/share/doc/mercurial/examples/vim/hg-menu.vim" )
171 source /usr/share/doc/mercurial/examples/vim/hg-menu.vim
174 " Vim 7 brings cool new features - see ':he version7'!
175 " The coolest features of Vim7 by mika
176 " ====================================
177 " 1) omni/intellisense completion: use CTRL-X CTRL-O in insert mode to start it [:he compl-omni]
178 " 2) internal grep: vimgrep foo bar [:he vimgrep]
179 " 3) tab pages: vim -p file1 file2 - then use the :tab command [:he tabpage]
182 " 4) undo branches: :undolist / :earlier 2h / :later 2h
183 " instead of using u (undo) and CTRL-R (redo), you might experiment with g-
184 " and g+ to move through the text state [:he undolist]
185 " 5) browse remote directories via scp using netrw plugin: :edit scp://host//path/to/ [:he netrw.vim]
186 " 6) start editing the filename under the cursor and jump to the line
187 " number following the file name: press gF [:he gF]
188 " 7) press 'CTRL-W F' to start editing the filename under the cursor in a new
189 " window and jump to the line number following the file name. [:he CTRL-W_F]
190 " 8) spelling correction (see later for its configuration) [:he spell]:
191 " ]s -> Move to next misspelled word after the cursor.
192 " zg -> Add word under the cursor as a good word to the first name in 'spellfile'
193 " zw -> Like "zg" but mark the word as a wrong (bad) word.
194 " z= -> For the word under/after the cursor suggest correctly spelled words.
195 " 9) highlight active cursor line using 'set cursorline' [:he cursorline]
196 " 10) delete inner quotes inside HTML-code using <C-O>cit (see its mapping later) [:he tag-blocks]
199 " Thanks for some ideas to Christian 'strcat' Schneider and Julius Plenz
200 " turn spelling on by default:
202 " toggle spelling with F12 key:
203 map <F12> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>
204 set spellfile=~/.vim/spellfile.add
205 " change language - get spell files from http://ftp.vim.org/pub/vim/runtime/spell/ =>
206 " cd ~/.vim/spell && wget http://ftp.vim.org/pub/vim/runtime/spell/de.{latin1,utf-8}.spl
209 " highlight spelling correction:
210 " highlight SpellBad term=reverse ctermbg=12 gui=undercurl guisp=Red " badly spelled word
211 " highlight SpellCap term=reverse ctermbg=9 gui=undercurl guisp=Blue " word with wrong caps
212 " highlight SpellRare term=reverse ctermbg=13 gui=undercurl guisp=Magenta " rare word
213 " highlight SpellLocale term=underline ctermbg=11 gui=undercurl guisp=DarkCyan " word only exists in other region
215 " set maximum number of suggestions listed to top 10 items:
218 " highlight matching parens:
219 " set matchpairs=(:),[:],{:},< :>
220 " let loaded_matchparen = 1
221 " highlight MatchParen term=reverse ctermbg=7 guibg=cornsilk
223 " highlight the cursor line and column:
225 " highlight CursorLine term=reverse ctermbg=7 guibg=#333333
226 " highlight CursorColumn guibg=#333333
228 " change inner tag - very useful e.g. within HTML-code!
229 " ci" will remove the text between quotes, also works for ' and `
232 " use the popup menu also when there is only one match:
233 " set completeopt=menuone
234 " determine the maximum number of items to show in the popup menu for:
236 " set completion highlighting:
237 " highlight Pmenu ctermbg=13 guifg=Black guibg=#BDDFFF " normal item
238 " highlight PmenuSel ctermbg=7 guifg=Black guibg=Orange " selected item
239 " highlight PmenuSbar ctermbg=7 guifg=#CCCCCC guibg=#CCCCCC " scrollbar
240 " highlight PmenuThumb cterm=reverse gui=reverse guifg=Black guibg=#AAAAAA " thumb of the scrollbar
244 " To enable persistent undo uncomment following section.
245 " The undo files will be stored in $HOME/.cache/vim
248 " " enable persistent-undo
251 " " store the persistent undo file in ~/.cache/vim
252 " set undodir=~/.cache/vim/
254 " " create undodir directory if possible and does not exist yet
255 " let targetdir=$HOME . "/.cache/vim"
256 " if isdirectory(targetdir) != 1 && getftype(targetdir) == "" && exists("*mkdir")
257 " call mkdir(targetdir, "p", 0700)
261 " Source a global configuration file if available
262 " Deprecated by Debian but still supported by grml
263 if filereadable("/etc/vim/vimrc.local")
264 source /etc/vim/vimrc.local
267 " source user-specific local configuration file
268 if filereadable(expand("$HOME/.vimrc.local"))
269 source $HOME/.vimrc.local
271 "# END OF FILE #################################################################