" Configuration file for gvim " Written for Debian GNU/Linux by W.Akkerman " Some modifications by J.H.M. Dassen " Heavily extended by Kamil "Nopik" Burzynski " Normally we use vim-extensions. If you want true vi-compatibility " remove change the following statements set nocompatible " Use Vim defaults (much better!) set backspace=2 " allow backspacing over everything in insert mode " Now we set some defaults for the editor " set autoindent " always set autoindenting on set textwidth=0 " Don't wrap words by default "set nobackup " Don't 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 set ruler " show the cursor position all the time " Suffixes that get lower priority when doing tab completion for filenames. " 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 " We know xterm-debian is a color terminal if &term =~ "xterm-debian" || &term =~ "xterm-xfree86" || &term =~ "xterm" set t_Co=16 set t_Sf=[3%dm set t_Sb=[4%dm endif " Vim5 comes with syntaxhighlighting. If you want to enable syntaxhightlighting " by default uncomment the next three lines. if has("syntax") syntax on " Default to no syntax highlightning endif inoremap   cnoremap   imap [4~ cmap [4~ " Debian uses compressed helpfiles. We must inform vim that the main " helpfiles is compressed. Other helpfiles are stated in the tags-file. set helpfile=$VIMRUNTIME/doc/help.txt.gz "Autogroups{{{" if has("autocmd") " Set some sensible defaults for editing C-files augroup cprog " Remove all cprog autocommands au! " When starting to edit a file: " For *.c and *.h files set formatting of comments and set C-indenting on. " For other files switch it off. " Don't change the order, it's important that the line with * comes first. autocmd BufRead * set tabstop=2 shiftwidth=2 formatoptions=tcql nocindent comments& autocmd BufRead *.c,*.h,*.cpp,*.cxx set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,:// iab #i #include iab #f #if iab #d #define iab #e #endif iab #l #else iab ret return( );2 iab el else{ set sc augroup END " curlyC.vim " From Long Truong : Vim Tip #125. " Automatically comments {} in C/C++/Java. au BufNewFile,BufRead *.c,*.cc,*.h imap } :call CurlyBracket()a au BufNewFile,BufRead *.cpp,*.C imap } :call CurlyBracket()a au BufNewFile,BufRead *.java,*.idl imap } :call CurlyBracket()a function CurlyBracket() let l:startline = line(".") let l:result1 = searchpair('{', '', '}', 'bW') if (result1 > 0) let l:linenum = line(".") let l:string1 = substitute(getline(l:linenum), '^\s*\(.*\)\s*$', '\1', "") if (l:string1 =~ '^{') let l:string1 = substitute(getline(l:linenum - 1), '^\s*\(.*\)\s*$', '\1', "") . " " . l:string1 sil exe "normal k" endif " get else part if necessary if (l:string1 =~ "else" ) sil exe "normal k0" let l:result2 = searchpair('{', '', '}', 'bW') if (l:result2 > 0) let l:linenum = line(".") let l:string2 = substitute(getline(l:linenum - 1), '^\s*\(.*\)\s*$', '\1', "") if (l:string2 =~ '^{') let l:string2 = substitute(getline(l:linenum - 1), '^\s*\(.*\)\s*$', '\1', "") . " " . l:string2 endif let l:string1 = l:string2 . " ... " . l:string1 endif endif " remove trailing whitespaces and curly brace let l:my_string = substitute(l:string1, '\s*{[^{]*$', '', "") let l:my_strlen = strlen(l:my_string) if (l:my_strlen > 30) let l:my_string = strpart(l:my_string,0,30)."..." endif sil exe ":" . l:startline sil exe "normal i}" "if ((l:startline - l:linenum) > 10) sil exe "normal a /* " . l:my_string . " */ " "endif endif endfunction " Also, support editing of gzip-compressed files. DO NOT REMOVE THIS! " This is also used when loading the compressed helpfiles. augroup gzip " Remove all gzip autocommands au! " Enable editing of gzipped files " read: set binary mode before reading the file " uncompress text in buffer after reading " write: compress file after writing " append: uncompress file, append, compress file autocmd BufReadPre,FileReadPre *.gz set bin autocmd BufReadPre,FileReadPre *.gz let ch_save = &ch|set ch=2 autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip autocmd BufReadPost,FileReadPost *.gz set nobin autocmd BufReadPost,FileReadPost *.gz let &ch = ch_save|unlet ch_save autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") autocmd BufWritePost,FileWritePost *.gz !mv :r autocmd BufWritePost,FileWritePost *.gz !gzip :r autocmd FileAppendPre *.gz !gunzip autocmd FileAppendPre *.gz !mv :r autocmd FileAppendPost *.gz !mv :r autocmd FileAppendPost *.gz !gzip :r augroup END augroup bzip2 " Remove all bzip2 autocommands au! " Enable editing of bzipped files " read: set binary mode before reading the file " uncompress text in buffer after reading " write: compress file after writing " append: uncompress file, append, compress file autocmd BufReadPre,FileReadPre *.bz2 set bin autocmd BufReadPre,FileReadPre *.bz2 let ch_save = &ch|set ch=2 autocmd BufReadPost,FileReadPost *.bz2 |'[,']!bunzip2 autocmd BufReadPost,FileReadPost *.bz2 let &ch = ch_save|unlet ch_save autocmd BufReadPost,FileReadPost *.bz2 execute ":doautocmd BufReadPost " . expand("%:r") autocmd BufWritePost,FileWritePost *.bz2 !mv :r autocmd BufWritePost,FileWritePost *.bz2 !bzip2 :r autocmd FileAppendPre *.bz2 !bunzip2 autocmd FileAppendPre *.bz2 !mv :r autocmd FileAppendPost *.bz2 !mv :r autocmd FileAppendPost *.bz2 !bzip2 -9 --repetitive-best :r augroup END " vim -b : edit binary using xxd-format! augroup Binary au! au BufReadPre *.bin let &bin=1 au BufReadPost *.bin if &bin | %!xxd au BufReadPost *.bin set ft=xxd | endif au BufWritePre *.bin if &bin | %!xxd -r au BufWritePre *.bin endif au BufWritePost *.bin if &bin | %!xxd au BufWritePost *.bin set nomod | endif augroup END endif " has ("autocmd") " Some Debian-specific things augroup filetype au BufRead reportbug.* set ft=mail augroup END "}}} " The following are commented out as they cause vim to behave a lot " different from regular vi. They are highly recommended though. set showcmd " Show (partial) command in status line. "set showmatch " Show matching brackets. set ignorecase set smartcase " Do case insensitive matching set incsearch " Incremental search "set autowrite " Automatically save before commands like :next and :make set nohls set hh=20 set statusline=%<%f%h%m%r\ %y\ %w(%b,0x%B)%=%l(of\ %L),%c%V\ %P set laststatus=2 let &foldmethod="marker" colorscheme ron highlight Folded ctermfg=8 ctermbg=0 set number highlight LineNr ctermfg=6 set sessionoptions=blank,buffers,curdir,folds,help,localoptions,winsize set path=,/usr/include,/usr/src/dev/gcc2/include/g++-3 set previewheight=15 let g:explDetailedList=1 nmap za imap za set tags+=~/.vimsessions/tags imap nmap :call ScrollPrev() imap nmap :bprev imap nmap :call ScrollNext() imap nmap :bnext imap nmap :call DelArg() imap nmap :bdel:bnext imap nmap :buffers nmap :buffers:exe ":buf " . input("Which one: ") imap imap nmap :call AddArg() imap "nmap :exe "norma :bad ".input("Enter filename to add: ")."\n:blast\n" nmap :Sexploreo nmap ^]}i//}}}^[{ddPP$i{{{^i//za imap i nmap dd^]}dd[{ imap i nmap :so ~/.vimsessions/ nmap :waexe "mksession! " . input( "Session name: ", "~/.vimsessions/".fnamemodify(v:this_session, ":p:t")) imap nmap :w:chdir %:p:h:make imap nmap :chdir %:p:h:!make clean imap nmap :w:chdir %:p:h:!make imap nmap :up:chdir %:p:h:!make run nmap :w:!ctags -a --c-types=cdefgmnstuvx -f ~/.vimsessions/tags % imap if &term =~ "xterm" imap [3;5~ [39~i nmap [3;5~ [39~ imap Ü i nmap Ü  nmap [32~ imap [32~ endif imap [39~ [39~i nmap [39~ dd nmap [I:exe "normal " . input("Which one: ") ."[\t" nmap f [i imap :wi nmap nmap imap \ i nmap \ :call SwapComment() vmap \ :call SwapComment() "Ovewriting existing commands. "imap  "nmap gf nmap d :bdel "Comments vmap C c/**/P vmap x2P4x "{{{CVS integration" nmap d :chdir %:p:h:!cvs diff -w %:tpatch -R -o %:t.cvs:vert diffsplit %:t.cvs:echo "CVS diff mode turned on." nmap D :set nodiff:set foldcolumn=0:set foldmethod=marker:bwip:echo "CVS diff mode turned off." nmap :w:let cvsfile = @%:bd:let @z = ":!cvs commit " . cvsfile@z:let @z = ":badd " . cvsfile:let @z = ":buffer " . cvsfile@z imap "}}} "These codes are for alt+shift+cursors. "Warning: these are nonstandard codes, I modified keymap manually. "These sequences are defining very nice line movement. imap nmap i imap nmap i imap ~i nmap ddp imap [9~i nmap ddp nmap = 1G=G`` imap = 1G=G`` set gfn=-b&h-lucidatypewriter-medium-r-normal-*-*-120-*-*-m-*-iso8859-1 source $VIMRUNTIME/menu.vim set wildmenu set cpo-=< set wcm= "map :emenu "Nopik's functions ;){{{" fu SwapComment() let c = col(".")-1 exe "normal ^" let s = getline(".")[col(".")-1] . getline(".")[col(".")] if s == "//" exe "normal 2x" let c = c - 2 else exe "normal! i//" let c = c + 2 endif let d = col(".")-1 if d > 0 if c > 0 exe "normal " . d . "h" . c . "l" else exe "normal " . d . "h" endif else if c > 0 exe "normal " . c . "l" endif endif endf fu ScrollNext() let i = 0 let f = 0 while i 1 if @% == argv(argc()-1) exe "rewind " else exe "next " endif endif endif endf fu ScrollPrev() let i = 0 let f = 0 while i 1 if @% == argv(0) exe "last " else exe "previous " endif endif endif endf fu AddArg() let i = 0 let f = 0 let s = "" while i