vimrc 配置 史上最牛
生活随笔
收集整理的這篇文章主要介紹了
vimrc 配置 史上最牛
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://amix.dk/vim/vimrc.html ?我了個去 真強大
另附一個vimrc" vim:shiftwidth=2:tabstop=8:expandtabif has('autocmd')" Remove ALL autocommands for the current groupau!" Mark .asm files MASM-type assemblyau BufNewFile,BufReadPre *.asm let b:asmsyntax='masm' endifif has('gui_running')let do_syntax_sel_menu=1 endifif has('gui_running') && $LANG !~ '\.'set encoding=utf-8 endifset nocompatible source $VIMRUNTIME/vimrc_example.vimset autoindent set nobackup set showmatch set formatoptions+=mM set fileencodings=ucs-bom,utf-8,gbk set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P if has('mouse')set mouse=a endif if has('multi_byte') && v:version > 601if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'set ambiwidth=doubleendif endif" Key mappings to ease browsing long lines noremap <C-J> gj noremap <C-K> gk noremap <Down> gj noremap <Up> gk inoremap <Down> <C-O>gj inoremap <Up> <C-O>gk" Key mappings for quick arithmetic inside Vim nnoremap <silent> <Leader>ma yypV:!calcu '<C-R>"'<CR>k$ vnoremap <silent> <Leader>ma yo<ESC>pV:!calcu '<C-R>"'<CR>k$ nnoremap <silent> <Leader>mr yyV:!calcu '<C-R>"'<CR>$ vnoremap <silent> <Leader>mr ygvmaomb:r !calcu '<C-R>"'<CR>"ay$dd`bv`a"ap" Key mapping to stop the search highlight nmap <silent> <F2> :nohlsearch<CR> imap <silent> <F2> <C-O>:nohlsearch<CR>" Key mapping for the taglist.vim plugin nmap <F9> :Tlist<CR> imap <F9> <C-O>:Tlist<CR>" Key mappings for the quickfix commands nmap <F11> :cn<CR> nmap <F12> :cp<CR>" Non-GUI setting if !has('gui_running')" Do not increase the windows width in the taglist.vim pluginif has('eval')let Tlist_Inc_Winwidth=0endif" Set text-mode menuif has('wildmenu')set wildmenuset cpoptions-=<set wildcharm=<C-Z>nmap <F10> :emenu <C-Z>imap <F10> <C-O>:emenu <C-Z>endif endifif has('autocmd')function! SetFileEncodings(encodings)let b:my_fileencodings_bak=&fileencodingslet &fileencodings=a:encodingsendfunctionfunction! RestoreFileEncodings()let &fileencodings=b:my_fileencodings_bakunlet b:my_fileencodings_bakendfunctionfunction! CheckFileEncoding()if &modified && &fileencoding != ''exec 'e! ++enc=' . &fileencodingendifendfunctionfunction! ConvertHtmlEncoding(encoding)if a:encoding ==? 'gb2312'return 'gbk' " GB2312 imprecisely means GBK in HTMLelseif a:encoding ==? 'iso-8859-1'return 'latin1' " The canonical encoding name in Vimelseif a:encoding ==? 'utf8'return 'utf-8' " Other encoding aliases should follow hereelsereturn a:encodingendifendfunctionfunction! DetectHtmlEncoding()if &filetype != 'html'returnendifnormal m`normal ggif search('\c<meta http-equiv=\("\?\)Content-Type\1 content="text/html; charset=[-A-Za-z0-9_]\+">') != 0let reg_bak=@"normal y$let charset=matchstr(@", 'text/html; charset=\zs[-A-Za-z0-9_]\+')let charset=ConvertHtmlEncoding(charset)normal ``let @"=reg_bakif &fileencodings == ''let auto_encodings=',' . &encoding . ','elselet auto_encodings=',' . &fileencodings . ','endifif charset !=? &fileencoding &&\(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding == '')silent! exec 'e ++enc=' . charsetendifelsenormal ``endifendfunctionfunction! GnuIndent()setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1setlocal shiftwidth=2setlocal tabstop=8endfunctionfunction! RemoveTrailingSpace()if $VIM_HATE_SPACE_ERRORS != '0' &&\(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')normal m`silent! :%s/\s\+$//enormal ``endifendfunction" Highlight space errors in C/C++ source files (Vim tip #935)if $VIM_HATE_SPACE_ERRORS != '0'let c_space_errors=1endif" Use Canadian spelling convention in engspchk (Vim script #195)let spchkdialect='can'" Show syntax highlighting attributes of character under cursor (Vim" script #383)map <Leader>a :call SyntaxAttr()<CR>" Automatically find scripts in the autoload directoryau FuncUndefined * exec 'runtime autoload/' . expand('<afile>') . '.vim'" File type related autosettingau FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4au FileType diff setlocal shiftwidth=4 tabstop=4au FileType html setlocal autoindent indentexpr=au FileType changelog setlocal textwidth=76" Text file encoding autodetectionau BufReadPre *.gb call SetFileEncodings('gbk')au BufReadPre *.big5 call SetFileEncodings('big5')au BufReadPre *.nfo call SetFileEncodings('cp437')au BufReadPost *.gb,*.big5,*.nfo call RestoreFileEncodings()au BufWinEnter *.txt call CheckFileEncoding()" Detect charset encoding in an HTML fileau BufReadPost *.htm* nested call DetectHtmlEncoding()" Recognize standard C++ headersau BufEnter /usr/include/c++/* setf cppau BufEnter /usr/include/g++-3/* setf cpp" Setting for files following the GNU coding standardau BufEnter /usr/* call GnuIndent()" Remove trailing spaces for C/C++ and Vim filesau BufWritePre * call RemoveTrailingSpace() endif
另附一個vimrc" vim:shiftwidth=2:tabstop=8:expandtabif has('autocmd')" Remove ALL autocommands for the current groupau!" Mark .asm files MASM-type assemblyau BufNewFile,BufReadPre *.asm let b:asmsyntax='masm' endifif has('gui_running')let do_syntax_sel_menu=1 endifif has('gui_running') && $LANG !~ '\.'set encoding=utf-8 endifset nocompatible source $VIMRUNTIME/vimrc_example.vimset autoindent set nobackup set showmatch set formatoptions+=mM set fileencodings=ucs-bom,utf-8,gbk set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P if has('mouse')set mouse=a endif if has('multi_byte') && v:version > 601if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'set ambiwidth=doubleendif endif" Key mappings to ease browsing long lines noremap <C-J> gj noremap <C-K> gk noremap <Down> gj noremap <Up> gk inoremap <Down> <C-O>gj inoremap <Up> <C-O>gk" Key mappings for quick arithmetic inside Vim nnoremap <silent> <Leader>ma yypV:!calcu '<C-R>"'<CR>k$ vnoremap <silent> <Leader>ma yo<ESC>pV:!calcu '<C-R>"'<CR>k$ nnoremap <silent> <Leader>mr yyV:!calcu '<C-R>"'<CR>$ vnoremap <silent> <Leader>mr ygvmaomb:r !calcu '<C-R>"'<CR>"ay$dd`bv`a"ap" Key mapping to stop the search highlight nmap <silent> <F2> :nohlsearch<CR> imap <silent> <F2> <C-O>:nohlsearch<CR>" Key mapping for the taglist.vim plugin nmap <F9> :Tlist<CR> imap <F9> <C-O>:Tlist<CR>" Key mappings for the quickfix commands nmap <F11> :cn<CR> nmap <F12> :cp<CR>" Non-GUI setting if !has('gui_running')" Do not increase the windows width in the taglist.vim pluginif has('eval')let Tlist_Inc_Winwidth=0endif" Set text-mode menuif has('wildmenu')set wildmenuset cpoptions-=<set wildcharm=<C-Z>nmap <F10> :emenu <C-Z>imap <F10> <C-O>:emenu <C-Z>endif endifif has('autocmd')function! SetFileEncodings(encodings)let b:my_fileencodings_bak=&fileencodingslet &fileencodings=a:encodingsendfunctionfunction! RestoreFileEncodings()let &fileencodings=b:my_fileencodings_bakunlet b:my_fileencodings_bakendfunctionfunction! CheckFileEncoding()if &modified && &fileencoding != ''exec 'e! ++enc=' . &fileencodingendifendfunctionfunction! ConvertHtmlEncoding(encoding)if a:encoding ==? 'gb2312'return 'gbk' " GB2312 imprecisely means GBK in HTMLelseif a:encoding ==? 'iso-8859-1'return 'latin1' " The canonical encoding name in Vimelseif a:encoding ==? 'utf8'return 'utf-8' " Other encoding aliases should follow hereelsereturn a:encodingendifendfunctionfunction! DetectHtmlEncoding()if &filetype != 'html'returnendifnormal m`normal ggif search('\c<meta http-equiv=\("\?\)Content-Type\1 content="text/html; charset=[-A-Za-z0-9_]\+">') != 0let reg_bak=@"normal y$let charset=matchstr(@", 'text/html; charset=\zs[-A-Za-z0-9_]\+')let charset=ConvertHtmlEncoding(charset)normal ``let @"=reg_bakif &fileencodings == ''let auto_encodings=',' . &encoding . ','elselet auto_encodings=',' . &fileencodings . ','endifif charset !=? &fileencoding &&\(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding == '')silent! exec 'e ++enc=' . charsetendifelsenormal ``endifendfunctionfunction! GnuIndent()setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1setlocal shiftwidth=2setlocal tabstop=8endfunctionfunction! RemoveTrailingSpace()if $VIM_HATE_SPACE_ERRORS != '0' &&\(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')normal m`silent! :%s/\s\+$//enormal ``endifendfunction" Highlight space errors in C/C++ source files (Vim tip #935)if $VIM_HATE_SPACE_ERRORS != '0'let c_space_errors=1endif" Use Canadian spelling convention in engspchk (Vim script #195)let spchkdialect='can'" Show syntax highlighting attributes of character under cursor (Vim" script #383)map <Leader>a :call SyntaxAttr()<CR>" Automatically find scripts in the autoload directoryau FuncUndefined * exec 'runtime autoload/' . expand('<afile>') . '.vim'" File type related autosettingau FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4au FileType diff setlocal shiftwidth=4 tabstop=4au FileType html setlocal autoindent indentexpr=au FileType changelog setlocal textwidth=76" Text file encoding autodetectionau BufReadPre *.gb call SetFileEncodings('gbk')au BufReadPre *.big5 call SetFileEncodings('big5')au BufReadPre *.nfo call SetFileEncodings('cp437')au BufReadPost *.gb,*.big5,*.nfo call RestoreFileEncodings()au BufWinEnter *.txt call CheckFileEncoding()" Detect charset encoding in an HTML fileau BufReadPost *.htm* nested call DetectHtmlEncoding()" Recognize standard C++ headersau BufEnter /usr/include/c++/* setf cppau BufEnter /usr/include/g++-3/* setf cpp" Setting for files following the GNU coding standardau BufEnter /usr/* call GnuIndent()" Remove trailing spaces for C/C++ and Vim filesau BufWritePre * call RemoveTrailingSpace() endif
轉載于:https://www.cnblogs.com/zhihaowang/archive/2011/01/07/10128591.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的vimrc 配置 史上最牛的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 社区奖品之DOULEX按键灯
- 下一篇: ExtJS 动态增加与删除items,动