X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fvim%2Fvimrc;h=064b15c872299c30f91c9591c2466adf2b6ee058;hb=2f64ae016b211b59ddd38b1ad2026b2ff9336328;hp=020ba515b1ae3235587610148091bd051c6a365f;hpb=abb5f0d01ea0b935b13530ea3d40a7e881cc93d8;p=grml-etc-core.git diff --git a/etc/vim/vimrc b/etc/vim/vimrc index 020ba51..064b15c 100644 --- a/etc/vim/vimrc +++ b/etc/vim/vimrc @@ -3,7 +3,6 @@ " Authors: grml-team (grml.org), (c) Michael Prokop " Bug-Reports: see http://grml.org/bugs/ " License: This file is licensed under the GPL v2. -" Latest change: Sam Feb 10 11:07:20 CET 2007 [mika] """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just @@ -35,8 +34,6 @@ " set linebreak " Don't wrap words by default set textwidth=0 " Don't wrap lines by default set nobackup " Don't keep a backup file - set backupcopy=no " grml: Overwrite files/links with w! -" set backupcopy=yes " Keep a backup file set viminfo='20,\"50 " read/write a .viminfo file, don't store more than " 50 lines of registers set history=50 " keep 50 lines of command line history @@ -46,14 +43,11 @@ " These are files we are not likely to want to edit or read. set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc -" Make p in Visual mode replace the selected text with the "" register. - vnoremap p :let current_reg = @"gvdi=current_reg - " Vim5 and later versions support syntax highlighting. " Just load the main syntax file when Vim was compiled with "+syntax". if has("syntax") syntax on - fi + endif " Debian uses compressed helpfiles. We must inform vim that the main " helpfiles is compressed. Other helpfiles are stated in the tags-file. @@ -92,14 +86,186 @@ " set autowrite " Automatically save before commands like :next and :make " When switching between different buffers you can't use undo without 'set hidden': set hidden " Hide buffers when they are abandoned -" set mouse=a " Enable mouse usage (all modes) in terminals + set mouse= " Disable mouse usage (being "a" AKA all modes in Vim >=8) in terminals + set wildmenu " command-line completion operates in an enhanced mode set pastetoggle= " don't change text when copy/pasting set dictionary=/usr/share/dict/word " used with CTRL-X CTRL-K +""" set the screen hardstatus to vim(filename.ext) + if ((&term =~ '^screen') && ($VIM_PLEASE_SET_TITLE =~ '^yes$') || has('gui_running')) + set t_ts=k + set t_fs=\ + set title + autocmd BufEnter * let &titlestring = "vim(" . expand("%:t") . ")" + let &titleold = fnamemodify(&shell, ":t") + endif + +" turn these ON: + set ek vb +" set digraph +" turn these OFF ("no" prefix): + set nodigraph noeb noet nosol +" non-toggles: + set bs=2 fo=cqrt ls=2 shm=at ww=<,>,h,l +" set bs=2 fo=cqrt ls=2 shm=at tw=72 ww=<,>,h,l + set comments=b:#,:%,fb:-,n:>,n:) +" set list listchars=tab:»·,trail:· + set listchars=eol:$,precedes:«,extends:»,tab:»·,trail:· + set viminfo=%,'50,\"100,:100,n~/.viminfo + set tags=./tags,./TAGS,tags,TAGS,../tags,../../tags,../../../tags,../../../../tags + +" autocommands: +" when the file type is "mail" then set the textwidth to "70": + if has("autocmd") + au FileType mail set tw=70 +" When editing a file, always jump to the last cursor position +" au BufReadPost * if line("'\"") | exe "'\"" | endif + autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif + endif + +" some colors - as an example "white on black" [use bold fonts]: +" hi normal ctermfg=white ctermbg=black guifg=white guibg=black +" hi nontext ctermfg=blue ctermbg=black guifg=blue guibg=black +" set t_Co=256 " number of colors + +" some useful mappings: + +" with F7 copy all current buffer to clipboard, or a selection. +" with shift-F7, paste all clipboard contents +" see: http://www.vim.org/tips/tip.php?tip_id=964 + map :w !xclip + vmap "*y + map :r!xclip -o + +" remove/delete trailing whitespace: + nmap ;tr :%s/\s\+$// + vmap ;tr :s/\s\+$// + +" execute the command in the current line (minus the first word, which +" is intended to be a shell prompt) and insert the output in the buffer + map ,e ^wy$:r!" + +" update timestamp + iab YDATE =strftime("%a %b %d %T %Z %Y") + map ,L 1G/Latest change:\s*/e+1CYDATE + +" the shell in a box mode. found in posting by Stefan `Sec` Zehl +" in newsgroup de.alt.sysadmin.recovery, msg­id: +" Requires zsh for "print -P $PS1" / replace if needed. +" Your prompt should end in > (and only contain one) +" so run something like: +" % export PS1='%n@%m > ' +" in your zsh, press ',l' and for running commands, end mode via + map __start :imap __cmd\|imap __end + noremap __end :iunmap \|iunmap :"Vish ended. + noremap __cmd 0f>ly$:r !";print -P $PS1A + noremap __scmd :r !print -P $PS1A + map ,l __start__scmd + +" Kill quote spaces (when quoting a quote) + map ,kqs mz:%s/^> >/>>/ + +" Interface to Mercurial Version Control + if filereadable( "/usr/share/doc/mercurial/examples/vim/hg-menu.vim" ) + source /usr/share/doc/mercurial/examples/vim/hg-menu.vim + endif + +" Vim 7 brings cool new features - see ':he version7'! +" The coolest features of Vim7 by mika +" ==================================== +" 1) omni/intellisense completion: use CTRL-X CTRL-O in insert mode to start it [:he compl-omni] +" 2) internal grep: vimgrep foo bar [:he vimgrep] +" 3) tab pages: vim -p file1 file2 - then use the :tab command [:he tabpage] +" gt -> next tab +" gT -> previous tab +" 4) undo branches: :undolist / :earlier 2h / :later 2h +" instead of using u (undo) and CTRL-R (redo), you might experiment with g- +" and g+ to move through the text state [:he undolist] +" 5) browse remote directories via scp using netrw plugin: :edit scp://host//path/to/ [:he netrw.vim] +" 6) start editing the filename under the cursor and jump to the line +" number following the file name: press gF [:he gF] +" 7) press 'CTRL-W F' to start editing the filename under the cursor in a new +" window and jump to the line number following the file name. [:he CTRL-W_F] +" 8) spelling correction (see later for its configuration) [:he spell]: +" ]s -> Move to next misspelled word after the cursor. +" zg -> Add word under the cursor as a good word to the first name in 'spellfile' +" zw -> Like "zg" but mark the word as a wrong (bad) word. +" z= -> For the word under/after the cursor suggest correctly spelled words. +" 9) highlight active cursor line using 'set cursorline' [:he cursorline] +" 10) delete inner quotes inside HTML-code using cit (see its mapping later) [:he tag-blocks] +" +if version >= 700 + " Thanks for some ideas to Christian 'strcat' Schneider and Julius Plenz + " turn spelling on by default: + " set spell + " toggle spelling with F12 key: + map :set spell!:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3) + set spellfile=~/.vim/spellfile.add + " change language - get spell files from http://ftp.vim.org/pub/vim/runtime/spell/ => + " cd ~/.vim/spell && wget http://ftp.vim.org/pub/vim/runtime/spell/de.{latin1,utf-8}.spl + " change to german: + " set spelllang=de + " highlight spelling correction: + " highlight SpellBad term=reverse ctermbg=12 gui=undercurl guisp=Red " badly spelled word + " highlight SpellCap term=reverse ctermbg=9 gui=undercurl guisp=Blue " word with wrong caps + " highlight SpellRare term=reverse ctermbg=13 gui=undercurl guisp=Magenta " rare word + " highlight SpellLocale term=underline ctermbg=11 gui=undercurl guisp=DarkCyan " word only exists in other region + + " set maximum number of suggestions listed top 10 items: + set sps=best,10 + + " highlight matching parens: + " set matchpairs=(:),[:],{:},< :> + " let loaded_matchparen = 1 + " highlight MatchParen term=reverse ctermbg=7 guibg=cornsilk + + " highlight the cursor line and column: + " set cursorline + " highlight CursorLine term=reverse ctermbg=7 guibg=#333333 + " highlight CursorColumn guibg=#333333 + + " change inner tag - very useful e.g. within HTML-code! + " ci" will remove the text between quotes, also works for ' and ` + imap cit + + " use the popup menu also when there is only one match: + " set completeopt=menuone + " determine the maximum number of items to show in the popup menu for: + set pumheight=7 + " set completion highlighting: + " highlight Pmenu ctermbg=13 guifg=Black guibg=#BDDFFF " normal item + " highlight PmenuSel ctermbg=7 guifg=Black guibg=Orange " selected item + " highlight PmenuSbar ctermbg=7 guifg=#CCCCCC guibg=#CCCCCC " scrollbar + " highlight PmenuThumb cterm=reverse gui=reverse guifg=Black guibg=#AAAAAA " thumb of the scrollbar +endif + + +" To enable persistent undo uncomment following section. +" The undo files will be stored in $HOME/.cache/vim + +" if version >= 703 +" " enable persistent-undo +" set undofile +" +" " store the persistent undo file in ~/.cache/vim +" set undodir=~/.cache/vim/ +" +" " create undodir directory if possible and does not exist yet +" let targetdir=$HOME . "/.cache/vim" +" if isdirectory(targetdir) != 1 && getftype(targetdir) == "" && exists("*mkdir") +" call mkdir(targetdir, "p", 0700) +" endif +" endif + " Source a global configuration file if available " Deprecated by Debian but still supported by grml if filereadable("/etc/vim/vimrc.local") source /etc/vim/vimrc.local endif -" EOF + +" source user-specific local configuration file + if filereadable(expand("$HOME/.vimrc.local")) + source $HOME/.vimrc.local + endif +"# END OF FILE #################################################################