使用VIM的程序员很多,这里提供一个VIMRC,提供了很多自动化的功能,比如高亮代码,自动完成等等。
"setlocal omnifunc=python3complete#Complete
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2000 Jan 06
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for VMS: sys$login:.vimrc
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
"let &termencoding=&encoding
"set fileencodings=utf-8,gbk,ucs-bom,cp936
set bs=2 " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " 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
set nu
"set bdir=~/.vimbackup
set nowrap
set bg=dark
set smarttab
set expandtab
set tabstop=4
" 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
" Make p in Visual mode replace the selected text with the "" register.
vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
syntax on
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")
" autocmd BufRead *.txt set tw=78
fun SetTitle()
call setline(1, "#coding=gbk")
call append(line("."), "import os")
call append(line(".") + 1, "import sys")
call append(line(".") + 2, "import argparse")
call append(line(".") + 3, "import commands")
call append(line(".") + 4, "import logging")
call append(line(".") + 5, "")
call append(line(".") + 6, "logging.basicConfig(level = logging.DEBUG,")
call append(line(".") + 7, " format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',")
call append(line(".") + 8, " datefmt = '%Y-%m-%d %H:%M:%S',")
call append(line(".") + 9, " filename = os.path.basename(__file__) + '.log',")
call append(line(".") + 10, " filemode = 'a')")
call append(line(".") + 11, "")
call append(line(".") + 12, "def perror_and_exit(message, status = -1):")
call append(line(".") + 13, " sys.stderr.write(message + '\\n')")
call append(line(".") + 14, " logging.info(message + 'sys exit')")
call append(line(".") + 15, " sys.exit(status)")
call append(line(".") + 16, "")
call append(line(".") + 17, "if __name__ == '__main__':")
call append(line(".") + 18, " ")
call append(line(".") + 19, " pass")
call cursor(20, 5)
endfunc
if has("autocmd")
autocmd BufNewFile *.py exec ":call SetTitle()"
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
augroup cprog
" Remove all cprog autocommands
au!
" When starting to edit a file:
" For C and C++ 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 FileType * set formatoptions=tcql nocindent comments&
autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
augroup END
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)
" set 'cmdheight' to two, to avoid the hit-return prompt
let ch_save = &ch
set ch=3
" when filtering the whole buffer, it will become empty
let empty = line("'[") == 1 && line("']") == line("$")
let tmp = tempname()
let tmpe = tmp . "." . expand("<afile>:e")
" write the just read lines to a temp file "'[,']w tmp.gz"
execute "'[,']w " . tmpe
" uncompress the temp file "!gunzip tmp.gz"
execute "!" . a:cmd . " " . tmpe
" delete the compressed lines
'[,']d
" read in the uncompressed lines "'[-1r tmp"
set nobin
execute "'[-1r " . tmp
" if buffer became empty, delete trailing blank line
if empty
normal Gdd''
endif
" delete the temp file
call delete(tmp)
let &ch = ch_save
" When uncompressed the whole buffer, do autocommands
if empty
execute ":doautocmd BufReadPost " . expand("%:r")
endif
endfun
" After writing compressed file: Compress written file with "cmd"
fun! GZIP_write(cmd)
if rename(expand("<afile>"), expand("<afile>:r")) == 0
execute "!" . a:cmd . " <afile>:r"
endif
endfun
" Before appending to compressed file: Uncompress file with "cmd"
fun! GZIP_appre(cmd)
execute "!" . a:cmd . " <afile>"
call rename(expand("<afile>:r"), expand("<afile>"))
endfun
augroup END
" This is disabled, because it changes the jumplist. Can't use CTRL-O to go
" back to positions in previous files more than once.
if 0
" When editing a file, always jump to the last cursor position.
" This must be after the uncompress commands.
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif
endif
endif " has("autocmd")
set shiftwidth=4
"set cindent
set wrap
set ts=4
set sw=4
set showcmd
map <F8> ggVG= <CR>
map <F9> :set nonu <CR>
map <F10> :set nu <CR>
map <F11> :silent! Tlist<CR>
map ,, :A<CR>
map ,- :AS<CR>
map ,= :AV<CR>
"omnicppcomplete config
set nocp
filetype plugin on
filetype indent on
set tags=tags;
"set tags+=~/home/work/tags
"set tags+=~/install/tags/wbl_tags
"set tags+=~/station/tags
"set tags+=~/qqcard_publish/tags
"set tags+=~/esales_publish/tags
"au BufWritePost *.c,*.cpp,*.cc,*.h !ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/station/tags ~/station/
"au BufWritePost *.c,*.cpp,*.cc,*.h !ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/qqcard_publish/tags ~/qqcard_publish/
"au BufWritePost *.c,*.cpp,*.cc,*.h !ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/esales_publish/tags ~/esales_publish/
"au BufWritePost *.c,*.cpp,*.cc,*.h !ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
map <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
"let OmniCpp_ShowPrototypeInAbbr = 1
let g:neocomplcache_enable_at_startup = 1
"taglist config
let Tlist_Ctags_Cmd = '/usr/bin/ctags' "设定linux系统中ctags程序的位置
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window = 0 "在右侧窗口中显示taglist窗口
"csope
"cscope add ~/Cip_esales_related/cscope/cscope.out
"nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>
" Only do this part when compiled with support for autocommands
if has("autocmd")
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
endif
原文:http://blog.csdn.net/junfeng_feng/article/details/42967313