" Folkes VIMrc " " ----------------------------------------------------------- " General setup " ----------------------------------------------------------- " enable backspace to delete anyting (includes \n) in insert mode set backspace=2 set nocompatible " jingle bells, jingle bells, hingle bells, .... set errorbells " ----------------------------------------------------------- " Text-Formatting, Identing, Tabbing " ----------------------------------------------------------- " autoindenting (local to buffer) set ai " smartindenting (clever autoindenting) set si " number of spaces the tab stands for set tabstop=8 " number of spaces used for (auto)indenting set shiftwidth=4 " a in an indent insets 'shiftwidth' spaces (not tabstop) set smarttab " if non-zero, number of spaces to insert for a set softtabstop=4 " enable specific indenting for c-code and others set cindent " and here some nice options for cindenting set cinoptions={.5s,+.5s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s " by FOLKE " now real wrap during insert (enable/override this when using as mail-editor) set tw=0 " use full featured format-options. see "help fo-table for help if v:version >= 600 set formatoptions=tcrqn2 else " vim 5 doesn't know r/n set formatoptions=tcq2 endif " define what are comments set com& " reset to default set com^=sr:*\ -,mb:*\ \ ,el:*/ com^=sr://\ -,mb://\ \ ,el:/// " auto tw=78 when textmode if has("autocmd") autocmd FileType text setlocal textwidth=78 autocmd FileType text set nocindent endif " ----------------------------------------------------------- " Searching, Substituting " ----------------------------------------------------------- " select case-insenitiv search set ignorecase " No ignorecase if Uppercase chars in search set scs " change the way backslashes are used in search patterns set magic " begin search at top when EOF reached set wrapscan " jump to matches during entering the pattern set sm " highlight all matches... set hls " ...and also during entering the pattern set incsearch " use 'g'-flag when substituting (subst. all matches in that line, not only first) " to turn off, use g (why is there no -g ?) set gdefault " turn off the fucking :s///gc toggling set noedcompatible " ----------------------------------------------------------- " Highlighting, Colors, Fonts " ----------------------------------------------------------- " when we have a colored terminal or gui... if &t_Co > 2 || has("gui_running") " ...then use highlighting syntax on endif if has("gui_running") "Standartgroesse bei'm GUI-Fenster "columns width of the display set co=98 "lines number of lines in the display set lines=41 if has("win32") set guifont=Fixedsys:h9:cANSI "set guifont=Courier:h10:cANSI else "set gfn=-adobe-courier-medium-r-normal-*-*-140-*-*-m-*-iso8859-15 "set gfn=Courier\ New\ 12 set gfn=Nimbus\ Mono\ L\ 12 endif "colorscheme morning endif " how many lines to sync backwards syn sync minlines=10000 maxlines=10000 " how many lines to search backward after a jump to check syntax let c_minlines = 200 " aldo highlight some things in comments let c_comment_strings = 1 " SQL-Highlighting in PHP-Strings (1=yes 0=no) let php_sql_query = 1 let php_minlines=1200 let php_htmlInStrings=1 " use white background in GUI-Mode, black on console if has("gui_running") "|| &term=="xterm" set bg=light else set bg=dark endif " use css when converting syntax to html (2html.vim) let html_use_css = 1 " and a nice command for makeing html-code command Code2html :source $VIMRUNTIME/syntax/2html.vim| " ----------------------------------------------------------- " Statusline, Menu " ----------------------------------------------------------- " use tab for auto-expansion in menus set wc= " show a list of all matches when tabbing a command set wmnu " how command line completion works set wildmode=list:longest,list:full " ignore some files for filename completion set wildignore=*.o,*.r,*.so,*.sl,*.tar,*.tgz " some filetypes got lower priority set su=.h,.bak,~,.o,.info,.swp,.obj " remember last 2000 typed commands set hi=2000 " show cursor position below each window set ruler set ru " shows the current status (insert, visual, ...) in statusline set showmode " use shortest messages set shm=a " show always statusline of last window set laststatus=2 " ----------------------------------------------------------- " Insert-Mode Completion " ----------------------------------------------------------- " order and what to complete. see ":help complete" for info set complete=.,w,b,u,t,i " enable dictionary (add k to complete to scan dict when completing) " set dict= " adjust case of a keyword completion match set infercase " showfulltag when completing tags in Insert mode show only the name " not any arguments (when a c-funtion is inserted) set nosft " ----------------------------------------------------------- " Tag search (c-code) and tag highlighting " ----------------------------------------------------------- " where to look for tags set tags=./tags,../tags,../../tags,../../../tags,/usr/include/tags " double-click opens preview-window with matching tag noremap <2-LeftMouse> :call MousePush() " and also (useful on console or using no mouse) map  :call MousePush() imap  :let pos_pos = line('.').'normal! '.virtcol('.').''[(:call MousePush():exe pos_posa " cycle thru preview tags map :ptp map :ptn imap :silent! ptpa imap :silent! ptna " height of preview-window set previewheight=5 fun! MousePush() if filereadable(expand("")) exe 'edit ' . expand("") elseif -1 < match(getline(line(".")), "<".expand("").">") exe 'find ' . expand("") else exe 'ptag ' . expand ("") endif endfun " generate tags.vim file out of tags file for highlighting all local functions noremap :sp tags:%s/^\([^ \t:]*:\)\=\([^ \t]*\).*/syntax keyword Tag \2/:wq! tags.vim/^ " source tags.vim file noremap :source tags.vim " autoload tags.vim if exists au BufRead * \ if filereadable(expand("%:p:h")."/tags.vim") && expand("%p:h") != $VIMRUNTIME \ | exe 'source '.expand("%:p:h")."/tags.vim" \ | endif " ----------------------------------------------------------- " window handling " ----------------------------------------------------------- " focus follows mouse set mousef " minimal number of lines used for the current window set wh=1 " minimal number of lines used for any window set wmh=0 " make all windows the same size when adding/removing windows set noequalalways "a new window is put below the current one set splitbelow " ----------------------------------------------------------- " file, backup, path " ----------------------------------------------------------- " updatecount number of characters typed to cause a swap file update set uc=50 " make no backups set nobackup if has("unix") if v:version >= 600 set path=.,~/include/**,~/src/**2,~/.vim/**2,~/lib/**2,/usr/include/**,/usr/X11R6/include/,/usr/local/include else set path=.,~/include,/usr/include,/usr/X11R6/include/,/usr/local/include endif endif " ----------------------------------------------------------- " WIN-GUI Specials " ----------------------------------------------------------- " first of all: we don't use "behave windows" " to try to get a better clipboard-handling " (we do it ourself) if has("win32") if has("gui_running") " alt jumps to menu set winaltkeys=menu " clipboard to autoselect set guioptions+=a " ---- Windows Like keys ---- " CTRL-Z is Undo; not in cmdline though noremap u inoremap u " CTRL-Y is Redo (although not repeat); not in cmdline though noremap inoremap " CTRL-A is Select all noremap gggHG inoremap gggHG cnoremap gggHG " CTRL-F4 is Close window noremap c inoremap c cnoremap c " CTRL-Tab is Next window noremap w inoremap w cnoremap w " ---- Windows Like Copy-Paste keys ---- " CTRL-v is paste inoremap "*pi noremap "*p " CTRL-x is cut (in visual mode only) vnoremap "*d " CTRL-c is copy (in visual mode only) vnoremap "*y " ---- Restore some remapped things " make real (visual block) as available noremap inoremap endif endif " ----------------------------------------------------------- " UNIX Specials " ----------------------------------------------------------- if has("unix") set clipboard=autoselect set shell=/bin/bash endif " ----------------------------------------------------------- " Special Features " ----------------------------------------------------------- if v:version >= 600 filetype on filetype indent on else filetype on endif if has("autocmd") " try to auto-examine filetype if v:version >= 600 filetype plugin indent on endif " try to restore last known cursor position autocmd BufReadPost * if line("'\"") | exe "normal '\"" | endif " autoread gzip-files augroup gzip " Remove all gzip autocommands au! " Enable editing of gzipped files " set binary mode before reading the file autocmd BufReadPre,FileReadPre *.gz,*.bz2 set bin autocmd BufReadPost,FileReadPost *.gz call GZIP_read("gunzip") autocmd BufReadPost,FileReadPost *.bz2 call GZIP_read("bunzip2") autocmd BufWritePost,FileWritePost *.gz call GZIP_write("gzip") autocmd BufWritePost,FileWritePost *.bz2 call GZIP_write("bzip2") autocmd FileAppendPre *.gz call GZIP_appre("gunzip") autocmd FileAppendPre *.bz2 call GZIP_appre("bunzip2") autocmd FileAppendPost *.gz call GZIP_write("gzip") autocmd FileAppendPost *.bz2 call GZIP_write("bzip2") " After reading compressed file: Uncompress text in buffer with "cmd" fun! GZIP_read(cmd) let ch_save = &ch set ch=2 execute "'[,']!" . a:cmd set nobin let &ch = ch_save execute ":doautocmd BufReadPost " . expand("%:r") endfun " After writing compressed file: Compress written file with "cmd" fun! GZIP_write(cmd) !mv :r execute "!" . a:cmd . " :r" endfun " Before appending to compressed file: Uncompress file with "cmd" fun! GZIP_appre(cmd) execute "!" . a:cmd . " " !mv :r endfun augroup END " gzip endif " ----------------------------------------------------------- " Mappings " ----------------------------------------------------------- " Appends / insert current date nmap _d "=strftime("%d.%m.%Y")p nmap _D "=strftime("%d.%m.%Y")P " Changes directory to the one of the current file nmap _h :cd%:h " Suppresses all spaces at end/beginning of lines nmap _s :%s/\s\+$// nmap _S :%s/^\s\+// " Converts file format to/from unix command Unixformat :set ff=unix command Dosformat :set ff=dos " toggle highlight search (folke) noremap :if 1 == &hls \| noh \| else \| set hls \| endif \| "noremap "noremap " is bound to `complete' " inoremap  " cycle thru errors (folke) nnoremap :cn nnoremap :cp " Make opens error-list automatically command Make :make|:cw inoremap :write:Make nnoremap write:Make " cycle thru buffers ... nnoremap :bn nnoremap :bp " search in doc selected text vnoremap * :let save_reg=@"gvy:let @/=@":let @"=save_reg/ " Folkes magic # adder/remover vnoremap # :s/^\([ \t]*\)\(.*\)$/#\1\2:nohl:silent! set hl vnoremap 3 :s/^\([ \t]*\)#\(.*\)$/\1\2:nohl:silent! set hl " Folkes auto-reindenter function! SavePos() let g:restore_position_excmd = line('.').'normal! '.virtcol('.').'|' endfun function! RestorePos() exe g:restore_position_excmd unlet g:restore_position_excmd endfun inoremap :call SavePos()ggVG=:call RestorePos()a nnoremap :call SavePos()ggVG=:call RestorePos() " Folkes magic :wq in insertmode function Wqtipper() let x = confirm("Hey!\nDu bist im Insert-Mode!\n Willst du trotzdem :wq machen?"," &Ja \n &Nein ",1,1) if x == 1 silent! wq else "??? endif endfun iab wq :call Wqtipper() " i often press del with the left hand on shift inoremap noremap "unsorted "set foldclose=all set fdm=marker " enable modeline (e.g. # vim:ft=squid) set modeline