Vim vimrc配置

Vim 的 vimrc 配置,我们直接将 vimrc 拷贝到用户目录并命名为 ~/.vimrc,vimrc 配置如下:

set nocompatible set autoread syntax enable syntax on set hlsearch set incsearch set backspace=indent,eol,start whichwrap+=<,>,[,] colorscheme desert "tango"desert set wrap set whichwrap=b,s,<,>,[,] "set slidescroll=10 set linebreak set history=1000 set helplang=cn set encoding=utf8 set langmenu=zh_CN.UTF-8 set imcmdline source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim set guifont=Liberation\Mono\ 12 set showmatch set mouse=a set selection=exclusive set selectmode=mouse,key set nocursorline highlight StatusLine guifg=SlateBlue guibg=yellow highlight StatusLineNC guifg=Gray guibg=White set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] set laststatus=2 set ruler set cmdheight=2 set fillchars=vert:\ ,stl:\ ,stlnc:\ set report=0 set ignorecase filetype on set clipboard+=unnamed set wildmenu set tabstop=4 set softtabstop=4 set shiftwidth=4 set formatoptions=tcrqn set smartindent set autoindent set viminfo+=! set nu if has("autocmd") autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number autocmd FileType xml,html vmap <C-o> <ESC>'<i<!--<ESC>o<ESC>'>o--> autocmd FileType java,c,cpp,cs vmap <C-o> <ESC>'<o/*<ESC>'>o*/ autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=100 autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif endif " has("autocmd") if filereadable("/etc/vim/gvimrc.local") source /etc/vim/gvimrc.local endif set tags=tags let Tlist_Sort_Type = "name" let Tlist_Ctags_Cmd = '/usr/bin/ctags' let Tlist_Show_One_File = 1 let Tlist_Exit_OnlyWindow = 1 let Tlist_Use_Right_Window = 1 let Tlist_Enable_Fold_Column = 1 let Tlist_Use_SingleClick=1 let Tlist_Process_File_Always=1 let Tlist_GainFocus_On_ToggleOpen=1 nmap tl :TlistToggle<cr> syn on filetype plugin on filetype indent on set shellslash set grepprg=grep\ -nH\ $* let g:tex_flavor = "latex" set nocp filetype plugin on filetype plugin indent on autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete autocmd FileType python set omnifunc=pythoncomplete#Complete autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags autocmd FileType java set omnifunc=javacomplete#Complete if has("autocmd") && exists("+omnifunc") autocmd Filetype * \ if &omnifunc == "" | \ setlocal omnifunc=syntaxcomplete#Complete | \ endif endif let g:rubycomplete_buffer_loading = 1 let g:rubycomplete_classes_in_global = 1 set fenc=utf-8 set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 let g:fencview_autodetect = 1 "打开文件时自动识别编码 let g:fencview_checklines = 100 "检查前后100行来判断编 set fileencodings=ucs-bom,utf8,GB18030,Big5,latin1 if has("cscope") "cscope配置 set csprg=/usr/bin/cscope set csto=1 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out endif set csverb endif nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR> nnoremap <silent> <F12> :A<CR> nnoremap <silent> <F3> :Grep<CR> map <F6> :make<CR> "设置一键编译 map <F5> :call CompileRunGcc()<CR> " C的编译和运行, F5编译和运行C程序 func! CompileRunGcc() exec "w" exec "!gcc -Wall % -o %<" exec "! ./%<" endfunc map <F6> :call CompileRunGpp()<CR> " C++的编译和运行,F6编译和运行C++程序 func! CompileRunGpp() exec "w" exec "!g++ -Wall % -o %<" exec "! ./%<" endfunc vmap <C-c> "yy "模仿MS windows中的快捷键 vmap <C-x> "yd nmap <C-v> "yp vmap <C-v> "yp nmap <C-a> ggvG$ let NERDshutUp=1 set shortmess=atI "不显示援助索马里儿童信息 nmap <silent> ,hl <Plug>MarkSet "mark给不同的单词高亮配置 vmap <silent> ,hl <Plug>MarkSet nmap <silent> ,hh <Plug>MarkClear vmap <silent> ,hh <Plug>MarkClear nmap <silent> ,hr <Plug>MarkRegex vmap <silent> ,hr <Plug>MarkRegex