" " ~/.vimrc, Wed Jul 22 2009 (Oct 24 2000-) Peter Csizmadia " set nobackup " backup: keep a backup file, nobackup: no backup set background=dark syntax on " syntax highlighting function! SetBackgroundAndForeground() highlight Normal guibg=black guifg=white endfunction call SetBackgroundAndForeground() set hlsearch " search pattern highlighting set suffixes=.bak,~,.o,.class,.info,.swp " no completion for these set bs=2 " allow backspacing over everything in insert mode set tw=78 " automatically insert at end of line set mousehide " hide mouse pointer while typing set guioptions+=a set viminfo='20,\"1000 set encoding=utf-8 set fileencoding=utf-8 if version >= 504 set clipboard=unnamed,autoselect endif " do not indent before case:, public:, private:, protected: set cinoptions=:0g0 " Start in insert mode without losing the Esc key "set im! "imap " Ctrl-Q quit map :confirm q imap :confirm q " Ctrl-Z undo map :undo imap :undo " Paragraph up/down, find imap { imap } imap / imap n " Edit new file map :browse confirm e imap :browse confirm e " Ctrl-J formats the current paragraph map gqap imap gqap " F6: go to next file, Alt-F6: previous file map :bnext! imap :bnext! map :bprevious! imap :bprevious! " F9: make all, Alt-F9: build all map :!make imap :!make map :!make clean && make imap :!make clean && make " F10: replace 8 spaces with one tab map :,$s/ /\t/gc imap :,$s/ /\t/gc " Switches C indenting and abbreviations off, use before mouse copy/paste map pas :set pastea " After mouse copy/paste, turn on C indenting and abbreviations again map nop :set nopaste " Makefiles, sh scripts, sed scripts, .ssh/authorized_keys files function! MakeAndScriptMode() call SetBackgroundAndForeground() set tw=0 wm=0 " do not wrap lines endfunction au BufNewFile,BufRead makefile*,Makefile*,GNUMakefile*,*.sh,*.?sh,*.sed,authorized_keys*,*.plt,*.in call MakeAndScriptMode() " C-like script languages function! CScriptMode() call SetBackgroundAndForeground() set tw=0 wm=0 " do not wrap lines set cindent " automatic indentation endfunction au BufNewFile,BufRead *.js,*.pl,*.awk call CScriptMode() " C-like languages function! CMode() call SetBackgroundAndForeground() set tw=0 wm=0 sw=4 sts=4 " do not wrap lines, indent: 4 chars set cindent " automatic indentation endfunction au BufNewFile,BufRead *.c,*.C,*.cpp,*.cxx,*.cc,*.h,*.hpp,*.c++,*.h++,*.cu,*.xpm,*.java,*.jsp call CMode() " LaTeX function! LaTeXMode() call SetBackgroundAndForeground() map :!latex % && dvips %:r.dvi -o %:r.ps map :!xdvi %:r.dvi & if match(expand("`where gv`"),"not.*found") >= 0 map :!ghostview %:r.ps & else map :!gv %:r.ps & endif endfunction au BufNewFile,BufRead *.tex call LaTeXMode() " HTML function! HTMLMode() call SetBackgroundAndForeground() set tw=0 wm=0 sw=4 sts=4 " do not wrap lines, indent: 4 chars map :set tw=78gqap:set tw=0 endfunction au BufNewFile,BufRead *.html call HTMLMode() "augroup gzip " from the vimrc_example file " " 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 BufReadPost,FileReadPost *.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 BufReadPost,FileReadPost *.bz2 let ch_save = &ch|set ch=2 " autocmd BufReadPost,FileReadPost *.bz2 '[,']!bunzip2 " autocmd BufReadPost,FileReadPost *.bz2 set nobin " 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 :r "augroup END augroup lzma " " Remove all lzma autocommands au! " Enable editing of lzma compressed 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 *.lzma set bin autocmd BufReadPost,FileReadPost *.lzma let ch_save = &ch|set ch=2 autocmd BufReadPost,FileReadPost *.lzma '[,']!unlzma autocmd BufReadPost,FileReadPost *.lzma set nobin autocmd BufReadPost,FileReadPost *.lzma let &ch = ch_save|unlet ch_save autocmd BufReadPost,FileReadPost *.lzma execute ":doautocmd BufReadPost " . expand("%:r") autocmd BufWritePost,FileWritePost *.lzma !mv :r autocmd BufWritePost,FileWritePost *.lzma !lzma :r autocmd FileAppendPre *.lzma !unlzma autocmd FileAppendPre *.lzma !mv :r autocmd FileAppendPost *.lzma !mv :r autocmd FileAppendPost *.lzma !lzma :r augroup END