" An example for a vimrc file. " " Maintainer: Bram Moolenaar " Last change: 2002 Sep 19 " " To use it, copy it to " for Unix and OS/2: ~/.vimrc " for Amiga: s:.vimrc " for MS-DOS and Win32: $VIM\_vimrc " for OpenVMS: sys$login:.vimrc " When started as "evim", evim.vim will already have done these settings. if v:progname =~? "evim" finish endif " Use Vim settings, rather then Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " allow backspacing over everything in insert mode set backspace=indent,eol,start if has("vms") set nobackup " do not keep a backup file, use versions instead else set backup " keep a backup file endif set history=50 " keep 50 lines of command line history set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries " let &guioptions = substitute(&guioptions, "t", "", "g") " Don't use Ex mode, use Q for formatting map Q gq " This is an alternative that also works in block mode, but the deleted " text is lost and it only works for putting the current register. "vnoremap p "_dp " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif " Only do this part when compiled with support for autocommands. if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif augroup END else set autoindent " always set autoindenting on endif " has("autocmd") " Metadata: {{{ set nocompatible set title let g:Header_name="Agent Zhang" let g:Header_email="agentzh@gmail.com" " }}} " Encodings: {{{ set termencoding=utf-8 set encoding=utf-8 set fileencodings=utf8,big5-hkscs,utf-8,iso8859-1 set expandtab set grepprg=grep\ -nH\ $* " ,gbk,euc-jp,euc-kr,utf-bom,iso8859-1 " }}} " Terminal: {{{ noremap Bs Del noremap Del Bs noremap!Bs Del noremap!Del Bs set bs=2 "noremap! "noremap! " insert-mode cursors map! OA ka map! OB ja map! OC lli map! OD i " Alt now serves as window commands (^W) "noremap   "norgmap  p noremap gh h noremap gk k noremap gl l noremap gj j noremap F gf cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap b cnoremap cnoremap f cnoremap " cnoremap cnoremap OA cnoremap OB cnoremap OC cnoremap OD inoremap # X# " }}} " Utilities: {{{ " }}} " Utilities: {{{ " map :!svk add '%' " map :!svk di '%' " map :!svk pull " map :!svk ci "map W :!chmod +w % noremap :w! noremap [I:let nr = input("Which one: ")exe "normal " . nr ."[\t" noremap o:.!env LC_ALL=C date o noremap o:.!print `fortune -s` o noremap :w :!aspell -x check % :e! noremap i<%_('')%>hhhi noremap! <%_('')%>hhhi " }}} " Environment: {{{ set laststatus=0 set statusline=%<%f%=\ %l,%c%V\ %m%r%w%y\ U+%04B\ %n\:%P set tags=./tags,./../tags,./../../tags,./../../../tags,./../../../../tags set formatoptions+=Mmc set mouse=a set selectmode+=key " store settings from previous edits set viminfo='50,\"300,:20,/20,%,! set comments+=fb:+ " return to position of last edit. woo! set visualbell set t_vb= set noerrorbells set terse " terse messages set ruler " show cursor position set cmdheight=1 " :cmd area size set shortmess=aoOTI " short messages set showbreak="+" " show lines that have been broken set nrformats+=alpha " Increment for alpha'd lists. set shiftround set writeany autoread autowrite set tabstop=8 " so tabs look right for us set softtabstop=4 set shiftwidth=4 " so ^T and << are smaller set report=1 " so we our told whenever we affect more than 1 line set nomesg " because being talked to during an edit is aggravating set autoindent " so i don't have to tab in set wrap set breakat= "set wrapmargin=1 " Wrap slightly in from the margin set linebreak set virtualedit=block " 'Free' editing in visual block mode set dictionary+=/usr/share/dict/words " dictionary set splitbelow " horizontally split below set splitright " vertically split to the right set smartcase " be sensible when searching 'ic' set incsearch set hlsearch set ttyfast set timeoutlen=500 " Fastish for slow connections " }}} " Shortcuts: {{{ noremap!  :stop noremap 1 :buf 1 noremap 2 :buf 2 noremap 3 :buf 3 noremap 4 :buf 4 noremap 5 :buf 5 noremap 6 :buf 6 noremap 7 :buf 7 noremap 8 :buf 8 noremap 9 :buf 9 noremap 0 :buf 10 noremap! { }O noremap! /} a " Display position with buf number. noremap 2 " noremap v xp noremap } nnoremap V v nnoremap gq " edit previously editted file "noremap = :MBEbn " write out the file "map  :w! " noremap   " split line " map * i  " because it's easier to type "noremap g G "noremap G g " so we return to exact position map ' ` " so Y is analagous to C and D map Y y$ " single-key save+quit map Q :wq " go to next file in arg list, same position map  :n +/ " set textwidth to cursor's column map #tw :set textwidth==col(".") " }}} " Commands: {{{ " Sorting, uniquing and shuffling command -nargs=* -range=% Sort ,!sort command -nargs=* -range=% Uniq ,!uniq command -nargs=* -range=% Rand ,!rand command Nl :if (&nu) set nonu else set nu endif command Q :q! command W :w! command Wq :wq! command WQ :wq! " }}} " Perl: {{{ map :make map :call MakeTest() fun! MakeTest() set makeprg=make\ test make set makeprg=perl\ % endfun let current_compiler = "perl" if has("win32") setlocal shellpipe=1>&2\ 2> endif autocmd FileType perl set makeprg=perl\ -w\ % autocmd FileType perl6 set makeprg=pugs\ % autocmd FileType scheme set makeprg=mzscheme\ -g\ -r\ % autocmd FileType scheme set shiftwidth=2 autocmd FileType mzperl set makeprg=mzperl\ % autocmd FileType mzperl set shiftwidth=2 autocmd FileType imc set makeprg=parrot\ % let perl_include_POD=1 let perl_want_scope_in_variables=1 let perl_extended_vars=1 let perl_fold=1 " }}} " Filetypes: {{{ filetype indent on filetype plugin on " Ignore filenames with any of the following suffices set suffixes+=.aux,.bak,.dvi,.gz,.idx,.log,.ps,.swp,.tar,.class.,~ set suffixes+=.o,.bbl,.log,.blg,.ilg,.ind,.toc,.pdf,.lof " Suffices when doing 'gf' stuff. set suffixesadd+=.html,.pl,.pm,.tex,.sty,.css,.xml,.xsd,.txt,.ict set suffixesadd+=.shtml,.phtml,.ehtml,.epl,.rss,.rdf,.pod,.asp if has("wildignore") | set wildignore+=&suffixes | endif fun! FTCheck() let lines = getline(1) if lines =~? "\[<%]\[#&% ]" setf mason elseif lines =~? "--- #YAML:" setf yaml elseif lines =~? "[%" setf tt2 elseif lines =~? "===" setf diff elseif lines =~? "pugs" setf perl6 endif endfun " }}} " Color: {{{ syntax on set bg=dark hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red hi StatusLine ctermbg=DarkBlue ctermfg=White cterm=NONE,bold hi Comment guifg=DarkGreen ctermfg=DarkGreen hi Constant guifg=Yellow ctermfg=Yellow hi MailSubject guifg=Cyan ctermfg=Cyan hi Statement guifg=DarkCyan ctermfg=DarkCyan hi Identifier guifg=Green ctermfg=Green hi Type guifg=Cyan ctermfg=Cyan hi Todo guifg=Green guibg=DarkGreen cterm=bold ctermfg=White ctermbg=DarkGreen hi Number guifg=DarkMagenta ctermfg=DarkMagenta hi Special guifg=Yellow ctermfg=Yellow hi PreProc guifg=Magenta ctermfg=Magenta hi makeError guibg=Black ctermbg=Black hi masonLoc cterm=bold,underline hi htmlLink ctermfg=White cterm=bold,underline hi perlPOD guifg=DarkGreen ctermfg=DarkGreen hi podVerbatimLine ctermfg=Brown guifg=DarkYellow hi podCommand guifg=Green ctermfg=Green hi podCmdText guifg=Green ctermfg=Green let html_number_color=1 colorscheme murphy " }}} " Folding: {{{ set foldmethod=marker set foldtext=AutFoldText() set nofoldenable function ExpandTo(xlen,xstr) let hey = a:xstr while strlen(hey) < a:xlen let hey = hey . ' ' endwhile return hey endfunction function AutFoldText() let line = getline(v:foldstart) let tail = (v:foldend - v:foldstart + 1) . ' lines' return ExpandTo((winwidth(0) - strlen(tail)), line) . tail endfunction set fillchars=stlnc:-,vert:\|,fold:\ ,diff:- if has("win32") hi Folded ctermbg=blue ctermfg=yellow else hi Folded cterm=underline ctermfg=Gray endif autocmd FileType human syn region FoldMarker start="^[1234567890]" end="^[1234567890]"me=e-1 fold keepend " }}} " Autocommands: {{{ function! CHANGE_CURR_DIR() let _dir = expand("%:p:h") if _dir !~ '^/tmp' exec 'cd ' . _dir endif unlet _dir endfunction "autocmd BufEnter * call CHANGE_CURR_DIR() autocmd BufNewFile,BufRead * set path+=** autocmd BufReadPost * if line("'\"")|execute("normal `\"")|endif autocmd BufNewFile,BufRead *.t setf perl autocmd BufNewFile,BufRead *.yaml,*.yml setf yaml autocmd BufNewFile,BufRead *.ss setf scheme autocmd BufNewFile,BufRead *.mzp setf mzperl autocmd BufNewFile,BufRead *.mas setf mason autocmd BufNewFile,BufRead *.hta setf mason autocmd BufNewFile,BufRead *.p6 setf perl6 autocmd BufNewFile,BufRead *.tdy setf perl autocmd BufNewFile,BufRead *.pmc setf pmc autocmd BufNewFile,BufRead * call FTCheck() autocmd BufNewFile,BufRead *.hsc setf haskell autocmd BufNewFile,BufRead *.hs-drift setf haskell autocmd BufNewFile,BufRead *.tt setf tt2 autocmd BufNewFile,BufRead *.pod hi perlPOD ctermfg=Gray autocmd BufNewFile,BufRead *.0 24 autocmd BufNewFile,BufRead w3m* set fileencoding=utf-8 au BufNewFile,BufRead *.pmc set ft=pmc cindent au BufNewFile,BufRead *.pasm set ft=pasm ai sw=4 au BufNewFile,BufRead *.imc,*.imcc,*.pir set ft=pir ai sw=4 au BufNewFile *.imc,*.imcc,*.pir 0r ~/.vim/skeleton.pir let Tlist_Ctags_Cmd='/usr/local/bin/exctags' let Tlist_Inc_Winwidth=0 highlight WhiteSpaceEOL ctermbg=darkgreen guibg=lightgreen match WhiteSpaceEOL /\s*\ \s*$/ autocmd WinEnter * match WhiteSpaceEOL /\s*\ \s*$/ set sessionoptions=buffers,help,tabpages,winsize,winpos,sesdir set path+=** set et set smarttab " vim: foldmethod=marker shiftwidth=4 expandtab set guifont=Consolas\ 11 set pastetoggle=