9da75832f17a889a4026e057ea1381569698d37f
[grml-etc-core.git] / etc / skel / .vimrc
1 " Filename:      .vimrc
2 " Purpose:       configuration file for editor 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 " Latest change: Mon Jun 05 16:30:29 CEST 2006 [mika]
7 "###############################################################################
8 " Thanks to Sven Guckes for his template!
9 "###############################################################################
10
11 " be no-compatible with vi
12   set nocp
13 " turn these ON:
14   set digraph ek hidden ruler sc vb wmnu
15 " turn these OFF ("no" prefix):
16   set noeb noet nosol
17 " non-toggles:
18   set bs=2 fo=cqrt ls=2 shm=at tw=72 ww=<,>,h,l
19   set comments=b:#,:%,fb:-,n:>,n:)
20 "  set list listchars=tab:»·,trail:·
21   set listchars=eol:$,precedes:«,extends:»,tab:»·,trail:·
22   set viminfo=%,'50,\"100,:100,n~/.viminfo
23
24 " autocommands:
25 " when the file type is "mail" then set the textwidth to "70":
26   au FileType mail   set tw=70
27 " When editing a file, always jump to the last cursor position
28 "  au BufReadPost * if line("'\"") | exe "'\"" | endif
29   autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
30
31 " some colors - as an example "white on black" [use bold fonts]:
32 "  hi normal   ctermfg=white  ctermbg=black guifg=white  guibg=black
33 "  hi nontext  ctermfg=blue   ctermbg=black guifg=blue   guibg=black
34 " switch on syntax coloring!! "bunt ist meine lieblingsfarbe!" :-)
35   syn on
36
37 " some useful mappings:
38   set pastetoggle=<f11>
39
40 " with F7 copy all current buffer to clipboard, or a selection.
41 " with shift-F7, paste all clipboard contents
42 " see: http://www.vim.org/tips/tip.php?tip_id=964
43   map   <F7>  :w !xclip<CR><CR>
44   vmap  <F7>  "*y
45   map <S-F7>  :r!xclip -o<CR>
46
47 " remove/delete trailing whitespace:
48   nmap ;tr :%s/\s\+$//
49   vmap ;tr  :s/\s\+$//
50
51 " execute the command in the current line (minus the first word, which
52 " is intended to be a shell prompt) and insert the output in the buffer
53   map ,e ^wy$:r!\12"\r
54
55 " update timestamp
56   iab YDATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
57   map ,L  1G/Latest change:\s*/e+1<CR>CYDATE<ESC>
58
59 " the shell in a box mode. found in posting by Stefan `Sec` Zehl
60 " in newsgroup de.alt.sysadmin.recovery, msg­id:  <df7lhe$2hup$1@ice.42.org>
61 " Requires zsh for "print -P $PS1" / replace if needed.
62 " Your prompt should end in > (and only contain one)
63 " so run something like:
64 "   % export PS1='%n@%m > '
65 " in your zsh, press ',l' and <enter> for running commands, end mode via <esc>
66   map __start :imap <C-V><C-M> <C-O>__cmd<C-V>\|imap <C-V><ESC> <C-V><ESC>__end<C-M>
67   noremap __end :iunmap <C-V><CR>\|iunmap <C-V><ESC><C-M>:"Vish ended.<C-M>
68   noremap __cmd 0<ESC>f>ly$:r !<C-R>";print -P $PS1<C-M>A
69   noremap __scmd :r !print -P $PS1<c-M>A
70   map ,l __start__scmd
71
72 " Kill quote spaces (when quoting a quote)
73   map ,kqs mz:%s/^> >/>>/<cr>
74
75 " Vim 7 brings cool new features - see ':he version7'!
76 " The coolest features of Vim7 by mika
77 " ====================================
78 "  1) omni/intellisense completion: use CTRL-X CTRL-O in insert mode to start it [:he compl-omni]
79 "  2) internal grep: vimgrep foo bar [:he vimgrep]
80 "  3) tab pages: vim -p file1 file2 - then use the :tab command [:he tabpage]
81 "     gt -> next tab
82 "     gT -> previous tab
83 "  4) undo branches: :undolist / :earlier 2h / :later 2h
84 "     instead of using u (undo) and CTRL-R (redo), you might experiment with g-
85 "     and g+ to move through the text state [:he undolist]
86 "  5) browse remote directories via scp using netrw plugin: :edit scp://host//path/to/ [:he netrw.vim]
87 "  6) start editing the filename under the cursor and jump to the line
88 "     number following the file name: press gF [:he gF]
89 "  7) press 'CTRL-W F' to start editing the filename under the cursor in a new
90 "     window and jump to the line number following the file name. [:he CTRL-W_F]
91 "  8) spelling correction (see later for its configuration) [:he spell]:
92 "      ]s  -> Move to next misspelled word after the cursor.
93 "      zg  -> Add word under the cursor as a good word to the first name in 'spellfile'
94 "      zw  -> Like "zg" but mark the word as a wrong (bad) word.
95 "      z=  -> For the word under/after the cursor suggest correctly spelled words. 
96 " 9)  highlight active cursor line using 'set cursorline' [:he cursorline]
97 " 10) delete inner quotes inside HTML-code using <C-O>cit (see its mapping later) [:he tag-blocks]
98 "
99 if version >= 700
100   " Thanks for some ideas to Christian 'strcat' Schneider and Julius Plenz
101   " turn spelling on by default:
102   "  set spell
103   " toggle spelling with F12 key:
104     map <F12> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>
105     set spellfile=~/.vim/spellfile.add
106   " change language -  get spell files from http://ftp.vim.org/pub/vim/runtime/spell/ =>
107   " cd ~/.vim/spell && wget http://ftp.vim.org/pub/vim/runtime/spell/de.latin1.spl
108   " change to german:
109   "  set spelllang=de
110   " highlight spelling correction:
111   "  highlight SpellBad    term=reverse   ctermbg=12 gui=undercurl guisp=Red       " badly spelled word 
112   "  highlight SpellCap    term=reverse   ctermbg=9  gui=undercurl guisp=Blue      " word with wrong caps
113   "  highlight SpellRare   term=reverse   ctermbg=13 gui=undercurl guisp=Magenta   " rare word
114   "  highlight SpellLocale term=underline ctermbg=11 gui=undercurl guisp=DarkCyan  " word only exists in other region
115
116   " set maximum number of suggestions listed to top 10 items:
117   set sps=best,10
118
119   " highlight matching parens:
120   " set matchpairs=(:),[:],{:},< :>
121   " let loaded_matchparen = 1
122   " highlight MatchParen term=reverse   ctermbg=7   guibg=cornsilk
123
124   " highlight the cursor line and column:
125   " set cursorline
126   " highlight CursorLine   term=reverse   ctermbg=7   guibg=#333333
127   " highlight CursorColumn guibg=#333333
128
129   " change inner tag - very useful e.g. within HTML-code!
130   " ci" will remove the text between quotes, also works for ' and `
131   imap <F10> <C-O>cit
132
133   " use the popup menu also when there is only one match:
134   " set completeopt=menuone 
135   " determine the maximum number of items to show in the popup menu for:
136   set pumheight=7
137   " set completion highlighting:
138   "  highlight Pmenu      ctermbg=13     guifg=Black   guibg=#BDDFFF              " normal item
139   "  highlight PmenuSel   ctermbg=7      guifg=Black   guibg=Orange               " selected item
140   "  highlight PmenuSbar  ctermbg=7      guifg=#CCCCCC guibg=#CCCCCC              " scrollbar
141   "  highlight PmenuThumb cterm=reverse  gui=reverse guifg=Black   guibg=#AAAAAA  " thumb of the scrollbar
142
143 endif
144 "# END OF FILE #################################################################