首页 > 代码库 > vim 配置文件
vim 配置文件
vim的配置文件如下_vimrc:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" General"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""function MySys()return "linux"endfunction"Get out of VI‘s compatible mode..set nocompatible"Sets how many lines of history VIM har to rememberset history=400"Enable filetype pluginfiletype plugin onfiletype indent on"Set to auto read when a file is changed from the outsideset autoread"Have the mouse enabled all the time:set mouse=a"Set mapleaderlet mapleader = ","let g:mapleader = ",""Fast savingnmap <leader>w :w!<cr>nmap <leader>f :find<cr>"Fast reloading of the .vimrcmap <leader>s :source ~/.gvimrc<cr>"Fast editing of .vimrcmap <leader>e :e! ~/.gvimrc<cr>"When .vimrc is edited, reload itautocmd! bufwritepost vimrc source ~/.gvimrcset fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936set termencoding=utf-8set encoding=utf-8"解决中文乱码问题set fenc=chinese "处理文本中显示乱码set encoding=utf-8set fileencodings=utf-8,chinese,latin-1if has("win32") set fileencoding=chineseelse set fileencoding=utf-8endif "处理菜单及右键菜单乱码source $VIMRUNTIME/delmenu.vimsource $VIMRUNTIME/menu.vim "处理consle输出乱码language messages zh_CN.utf-8"中文乱码结束"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Colors and Fonts""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Enable syntax hlsyntax enable"Set font to Monaco 10ptif MySys() == "mac" set gfn=Bitstream\ Vera\ Sans\ Mono:h14 set nomacatsui set termencoding=macromanelseif MySys() == "linux" set gfn=Monospace\ 11 set encoding=utf-8 set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1endifif has("gui_running") set guioptions-=T let psc_style=‘cool‘ colorscheme desertelse set background=dark colorscheme zellnerendif"Some nice mapping to switch syntax (useful if one mixes different languages in one file)map <leader>1 :set syntax=cheetah<cr>map <leader>2 :set syntax=xhtml<cr>map <leader>3 :set syntax=python<cr>map <leader>4 :set ft=javascript<cr>map <leader>$ :syntax sync fromstart<cr>autocmd BufEnter * :syntax sync fromstart"Highlight currentif has("gui_running") set cursorline hi cursorline guibg=#333333 hi CursorColumn guibg=#333333endif"Omni menu colorshi Pmenu guibg=#333333hi PmenuSel guibg=#555555 guifg=#ffffff"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Fileformats""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Favorite filetypesset ffs=unix,dos,macnmap <leader>fd :se ff=dos<cr>nmap <leader>fu :se ff=unix<cr>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => VIM userinterface""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Set 7 lines to the curors - when moving vertical..set so=7"Turn on WiLd menuset wildmenu"Always show current positionset ruler"The commandbar is 2 highset cmdheight=2"Show line numberset nu"Do not redraw, when running macros.. lazyredrawset lz"Change buffer - without savingset hid"Set backspaceset backspace=eol,start,indent"Bbackspace and cursor keys wrap toset whichwrap+=<,>,h,l"Ignore case when searchingset ignorecaseset incsearch"Set magic onset magic"No sound on errors.set noerrorbellsset novisualbellset t_vb="show matching bracetsset showmatch"How many tenths of a second to blinkset mat=2"Highlight search thingsset hlsearch """""""""""""""""""""""""""""" " => Statusline """""""""""""""""""""""""""""" "Always hide the statusline set laststatus=2 function! CurDir() let curdir = substitute(getcwd(), ‘/Users/amir/‘, "~/", "g") return curdir endfunction "Format the statusline set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c""""""""""""""""""""""""""""""" => Visual""""""""""""""""""""""""""""""" From an idea by Michael Naumannfunction! VisualSearch(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", ‘\\/.*$^~[]‘) let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == ‘b‘ execute "normal ?" . l:pattern . "^M" else execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_regendfunction"Basically you press * or # to search for the current selection !! Really usefulvnoremap <silent> * :call VisualSearch(‘f‘)<CR>vnoremap <silent> # :call VisualSearch(‘b‘)<CR>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Moving around and tabs""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Map space to / and c-space to ?map <space> /map <c-space> ?"Smart way to move btw. windowsmap <C-j> <C-W>jmap <C-k> <C-W>kmap <C-h> <C-W>hmap <C-l> <C-W>l"Actually, the tab does not switch buffers, but my arrows"Bclose function ca be found in "Buffer related" sectionmap <leader>bd :Bclose<cr>map <down> <leader>bd"Use the arrows to something usefullmap <right> :bn<cr>map <left> :bp<cr>"Tab configurationmap <leader>tn :tabnew %<cr>map <leader>te :tabeditmap <leader>tc :tabclose<cr>map <leader>tm :tabmovetry set switchbuf=usetab set stal=2catchendtry"Moving fast to front, back and 2 sides ;)imap <m-$> <esc>$aimap <m-0> <esc>0iimap <m-m> <esc>haimap <m-/> <esc>laimap <m-,> <esc>jaimap <m-.> <esc>kaimap <D-$> <esc>$aimap <D-0> <esc>0iimap <D-m> <esc>haimap <D-/> <esc>laimap <D-,> <esc>jaimap <D-.> <esc>ka"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => General Autocommands""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Switch to current dirmap <leader>cd :cd %:p:h<cr>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Parenthesis/bracket expanding""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""vnoremap $1 <esc>`>a)<esc>`<i(<esc>")vnoremap $2 <esc>`>a]<esc>`<i[<esc>vnoremap $3 <esc>`>a}<esc>`<i{<esc>vnoremap $$ <esc>`>a"<esc>`<i"<esc>vnoremap $q <esc>`>a‘<esc>`<i‘<esc>vnoremap $w <esc>`>a"<esc>`<i"<esc>"Map auto complete of (, ", ‘, [inoremap $1 ()<esc>:let leavechar=")"<cr>iinoremap $2 []<esc>:let leavechar="]"<cr>iinoremap $4 {<esc>o}<esc>:let leavechar="}"<cr>Oinoremap $3 {}<esc>:let leavechar="}"<cr>iinoremap $q ‘‘<esc>:let leavechar="‘"<cr>iinoremap $w ""<esc>:let leavechar=‘"‘<cr>iau BufNewFile,BufRead *.\(vim\)\@! inoremap " ""<esc>:let leavechar=‘"‘<cr>iau BufNewFile,BufRead *.\(txt\)\@! inoremap ‘ ‘‘<esc>:let leavechar="‘"<cr>iimap <m-l> <esc>:exec "normal f" . leavechar<cr>aimap <d-l> <esc>:exec "normal f" . leavechar<cr>a"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => General Abbrevs""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""My informationiab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>iab xname Amir Salihefendic"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Editing mappings etc.""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Remap VIM 0map 0 ^"Move a line of text using controlnmap <M-j> mz:m+<cr>`znmap <M-k> mz:m-2<cr>`zvmap <M-j> :m‘>+<cr>`<my`>mzgv`yo`zvmap <M-k> :m‘<-2<cr>`>my`<mzgv`yo`zif MySys() == "mac" nmap <D-j> <M-j> nmap <D-k> <M-k> vmap <D-j> <M-j> vmap <D-k> <M-k>endiffunc! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z"endfuncautocmd BufWrite *.py :call DeleteTrailingWS()set completeopt=menu"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Command-line config"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""func! Cwd() let cwd = getcwd() return "e " . cwd endfuncfunc! DeleteTillSlash() let g:cmd = getcmdline() if MySys() == "linux" || MySys() == "mac" let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "") else let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "") endif if g:cmd == g:cmd_edited if MySys() == "linux" || MySys() == "mac" let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "") else let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "") endif endif return g:cmd_editedendfuncfunc! CurrentFileDir(cmd) return a:cmd . " " . expand("%:p:h") . "/"endfunc"Smart mappings on the command linecno $h e ~/cno $d e ~/Desktop/cno $j e ./cno $q <C-\>eDeleteTillSlash()<cr>cno $c e <C-\>eCurrentFileDir("e")<cr>cno $tc <C-\>eCurrentFileDir("tabnew")<cr>cno $th tabnew ~/cno $td tabnew ~/Desktop/"Bash likecnoremap <C-A> <Home>cnoremap <C-E> <End>cnoremap <C-K> <C-U>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Buffer realted""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Fast open a buffer by search for a namemap <c-q> :sb"Open a dummy buffer for pastemap <leader>q :e ~/buffer<cr>"Restore cursor to file position in previous editing sessionset viminfo=‘10,\"100,:20,%,n~/.viminfoau BufReadPost * if line("‘\"") > 0|if line("‘\"") <= line("$")|exe("norm ‘\"")|else|exe "norm $"|endif|endif" Buffer - reverse everything ... :)map <F9> ggVGg?" Don‘t close window, when deleting a buffercommand! Bclose call <SID>BufcloseCloseIt()function! <SID>BufcloseCloseIt() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") if buflisted(l:alternateBufNum) buffer # else bnext endif if bufnr("%") == l:currentBufNum new endif if buflisted(l:currentBufNum) execute("bdelete! ".l:currentBufNum) endifendfunction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Files and backups""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Turn backup offset nobackupset nowbset noswapfile"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Folding""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Enable folding, I find it very usefulset nofenset fdl=0"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Text options"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set expandtabset shiftwidth=2map <leader>t2 :set shiftwidth=2<cr>map <leader>t4 :set shiftwidth=4<cr>au FileType html,python,vim,javascript setl shiftwidth=2au FileType html,python,vim,javascript setl tabstop=2au FileType java setl shiftwidth=4au FileType java setl tabstop=4set smarttabset lbrset tw=500 """""""""""""""""""""""""""""" " => Indent """""""""""""""""""""""""""""" "Auto indent set ai "Smart indet set si "C-style indeting set cindent "Wrap lines set wrap"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Spell checking"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""map <leader>sn ]smap <leader>sp [smap <leader>sa zgmap <leader>s? z="""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Plugin configuration""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""" " => Vim Grep """""""""""""""""""""""""""""" let Grep_Skip_Dirs = ‘RCS CVS SCCS .svn‘ let Grep_Cygwin_Find = 1 """""""""""""""""""""""""""""" " => Yank Ring """""""""""""""""""""""""""""" map <leader>y :YRShow<cr> """""""""""""""""""""""""""""" " => File explorer """""""""""""""""""""""""""""" "Split vertically let g:explVertical=1 "Window size let g:explWinSize=35 let g:explSplitLeft=1 let g:explSplitBelow=1 "Hide some files let g:explHideFiles=‘^\.,.*\.class$,.*\.swp$,.*\.pyc$,.*\.swo$,\.DS_Store$‘ "Hide the help thing.. let g:explDetailedHelp=0 """""""""""""""""""""""""""""" " => Minibuffer """""""""""""""""""""""""""""" "let g:miniBufExplModSelTarget = 1 "let g:miniBufExplorerMoreThanOne = 2 "let g:miniBufExplModSelTarget = 0 "let g:miniBufExplUseSingleClick = 1 "let g:miniBufExplMapWindowNavVim = 1 "let g:miniBufExplVSplit = 25 "let g:miniBufExplSplitBelow=1 "let g:bufExplorerSortBy = "name" "autocmd BufRead,BufNew :call UMiniBufExplorer """""""""""""""""""""""""""""" " => Tag list (ctags) - not used """""""""""""""""""""""""""""" "let Tlist_Ctags_Cmd = "/sw/bin/ctags-exuberant" "let Tlist_Sort_Type = "name" "let Tlist_Show_Menu = 1 "map <leader>t :Tlist<cr> """""""""""""""""""""""""""""" " => LaTeX Suite things """""""""""""""""""""""""""""" set grepprg=grep\ -nH\ $* let g:Tex_DefaultTargetFormat="pdf" let g:Tex_ViewRule_pdf=‘xpdf‘ "Bindings autocmd FileType tex map <silent><leader><space> :w!<cr> :silent! call Tex_RunLaTeX()<cr> "Auto complete some things ;) autocmd FileType tex inoremap $i \indent autocmd FileType tex inoremap $* \cdot autocmd FileType tex inoremap $i \item autocmd FileType tex inoremap $m \[<cr>\]<esc>O"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Filetype generic""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Todo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" au BufNewFile,BufRead *.todo so ~/vim_local/share/vim/vim72/syntax/amido.vim """""""""""""""""""""""""""""" " => VIM """""""""""""""""""""""""""""" autocmd FileType vim map <buffer> <leader><space> :w!<cr>:source %<cr> """""""""""""""""""""""""""""" " => HTML related """""""""""""""""""""""""""""" " HTML entities - used by xml edit plugin let xml_use_xhtml = 1 "let xml_no_auto_nesting = 1 "To HTML let html_use_css = 1 let html_number_lines = 0 let use_xhtml = 1 """""""""""""""""""""""""""""" " => Ruby & PHP section """""""""""""""""""""""""""""" autocmd FileType ruby map <buffer> <leader><space> :w!<cr>:!ruby %<cr> autocmd FileType php compiler php autocmd FileType php map <buffer> <leader><space> <leader>cd:w<cr>:make %<cr> """""""""""""""""""""""""""""" " => Python section """""""""""""""""""""""""""""" "Run the current buffer in python - ie. on leader+space au FileType python so ~/vim_local/share/vim/vim72/syntax/python.vim autocmd FileType python map <buffer> <leader><space> :w!<cr>:!python %<cr> autocmd FileType python so ~/vim_local/share/vim/vim72/plugin/python_fold.vim "Set some bindings up for ‘compile‘ of python autocmd FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r‘%‘)\" autocmd FileType python set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m "Python iMaps au FileType python set cindent au FileType python inoremap <buffer> $r return au FileType python inoremap <buffer> $s self au FileType python inoremap <buffer> $c ##<cr>#<space><cr>#<esc>kla au FileType python inoremap <buffer> $i import au FileType python inoremap <buffer> $p print au FileType python inoremap <buffer> $d """<cr>"""<esc>O "Run in the Python interpreter function! Python_Eval_VSplit() range let src = tempname() let dst = tempname() execute ": " . a:firstline . "," . a:lastline . "w " . src execute ":!python " . src . " > " . dst execute ":pedit! " . dst endfunction au FileType python vmap <F7> :call Python_Eval_VSplit()<cr> """""""""""""""""""""""""""""" " => Cheetah section """"""""""""""""""""""""""""""" autocmd FileType cheetah set ft=xml autocmd FileType cheetah set syntax=cheetah """"""""""""""""""""""""""""""" " => Vim section """"""""""""""""""""""""""""""" autocmd FileType vim set nofen """"""""""""""""""""""""""""""" " => Java section """"""""""""""""""""""""""""""" au FileType java inoremap <buffer> <C-t> System.out.println();<esc>hi "Java comments autocmd FileType java source ~/.vim/files/java.vim autocmd FileType java source ~/.vim/files/jcommenter.vim autocmd FileType java let b:jcommenter_class_author=‘Gaby (hbei_jing_2008@163.com)‘ autocmd FileType java let b:jcommenter_file_author=‘Gaby (hbei_jing_2008@163.com)‘ autocmd FileType java let b:jcommenter_file_copyright=‘(c) 2008 Vitular Inc. All Rights Reserved.‘ autocmd FileType java map <buffer> <F2> :call JCommentWriter()<cr> "Abbr‘z autocmd FileType java inoremap <buffer> $pr private autocmd FileType java inoremap <buffer> $po protected autocmd FileType java inoremap <buffer> $r return autocmd FileType java inoremap <buffer> $pu public autocmd FileType java inoremap <buffer> $i import autocmd FileType java inoremap <buffer> $b boolean autocmd FileType java inoremap <buffer> $v void autocmd FileType java inoremap <buffer> $s String autocmd FileType java inoremap <buffer> $I Integer autocmd FileType java inoremap <buffer> $l List autocmd FileType java inoremap <buffer> $c continue; "Folding function! JavaFold() setl foldmethod=syntax setl foldlevelstart=1 syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend syn match foldImports /\(\n\?import.\+;\n\)\+/ transparent fold function! FoldText() return substitute(getline(v:foldstart), ‘{.*‘, ‘{...}‘, ‘‘) endfunction setl foldtext=FoldText() endfunction au FileType java call JavaFold() au FileType java setl fen au BufEnter *.sablecc,*.scc set ft=sablecc """""""""""""""""""""""""""""" " => JavaScript section """"""""""""""""""""""""""""""" au FileType javascript so ~/vim_local/share/vim/vim72/syntax/javascript.vim function! JavaScriptFold() setl foldmethod=syntax setl foldlevelstart=1 syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend function! FoldText() return substitute(getline(v:foldstart), ‘{.*‘, ‘{...}‘, ‘‘) endfunction setl foldtext=FoldText() endfunction au FileType javascript call JavaScriptFold() au FileType javascript setl fen au FileType javascript imap <c-t> console.log();<esc>hi au FileType javascript imap <c-a> alert();<esc>hi au FileType javascript setl nocindent au FileType javascript inoremap <buffer> $r return au FileType javascript inoremap <buffer> $d //<cr>//<cr>//<esc>ka<space> au FileType javascript inoremap <buffer> $c /**<cr><space><cr>**/<esc>ka """""""""""""""""""""""""""""" " => HTML """"""""""""""""""""""""""""""" au FileType html,cheetah set ft=xml au FileType html,cheetah set syntax=html """""""""""""""""""""""""""""" " => C mappings """"""""""""""""""""""""""""""" autocmd FileType c map <buffer> <leader><space> :w<cr>:!gcc %<cr> """"""""""""""""""""""""""""""" " => SML """"""""""""""""""""""""""""""" autocmd FileType sml map <silent> <buffer> <leader><space> <leader>cd:w<cr>:!sml %<cr> """""""""""""""""""""""""""""" " => Scheme bidings """""""""""""""""""""""""""""" autocmd BufNewFile,BufRead *.scm map <buffer> <leader><space> <leader>cd:w<cr>:!petite %<cr> autocmd BufNewFile,BufRead *.scm inoremap <buffer> <C-t> (pretty-print )<esc>i autocmd BufNewFile,BufRead *.scm vnoremap <C-t> <esc>`>a)<esc>`<i(pretty-print <esc> """""""""""""""""""""""""""""" " => SVN section """"""""""""""""""""""""""""""" map <F8> :new<CR>:read !svn diff<CR>:set syntax=diff buftype=nofile<CR>gg""""""""""""""""""""""""""""""" => Snippets""""""""""""""""""""""""""""""" "You can use <c-j> to goto the next - it is pretty smart ;) """"""""""""""""""""""""""""""" " => Python """"""""""""""""""""""""""""""" autocmd FileType python inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("def ():\n<++>\nreturn <++>")<cr> autocmd FileType python inorea <buffer> cclass <c-r>=IMAP_PutTextWithMovement("class <++>:\n<++>")<cr> autocmd FileType python inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for <++> in <++>:\n<++>")<cr> autocmd FileType python inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if <++>:\n<++>")<cr> autocmd FileType python inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if <++>:\n<++>\nelse:\n<++>")<cr> """"""""""""""""""""""""""""""" " => JavaScript """"""""""""""""""""""""""""""" autocmd FileType cheetah,html,javascript inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("function <++>(<++>) {\n<++>;\nreturn <++>;\n}")<cr> autocmd filetype cheetah,html,javascript inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for(<++>; <++>; <++>) {\n<++>;\n}")<cr> autocmd FileType cheetah,html,javascript inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}")<cr> autocmd FileType cheetah,html,javascript inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}\nelse {\n<++>;\n}")<cr> """"""""""""""""""""""""""""""" " => HTML """"""""""""""""""""""""""""""" autocmd FileType cheetah,html,jsp inorea <buffer> cahref <c-r>=IMAP_PutTextWithMovement(‘<a href=http://www.mamicode.com/"<++>"><++></a>‘)<cr> autocmd FileType cheetah,html,jsp inorea <buffer> cbold <c-r>=IMAP_PutTextWithMovement(‘<b><++></b>‘)<cr> autocmd FileType cheetah,html,jsp inorea <buffer> cimg <c-r>=IMAP_PutTextWithMovement(‘<img src=http://www.mamicode.com/"<++>" alt="<++>" />‘)<cr> autocmd FileType cheetah,html,jsp inorea <buffer> cpara <c-r>=IMAP_PutTextWithMovement(‘<p><++></p>‘)<cr> autocmd FileType cheetah,html,jsp inorea <buffer> ctag <c-r>=IMAP_PutTextWithMovement(‘<<++>><++></<++>>‘)<cr> autocmd FileType cheetah,html,jsp inorea <buffer> ctag1 <c-r>=IMAP_PutTextWithMovement(‘<<++>><cr><++><cr></<++>>‘)<cr> autocmd FileType cheetah,html,jsp inorea <buffer> cta <c-r>=IMAP_PutTextWithMovement(‘<%<++>%>‘)<cr> """"""""""""""""""""""""""""""" " => Java """"""""""""""""""""""""""""""" autocmd FileType java inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("public<++> <++>(<++>) {\n<++>;\nreturn <++>;\n}")<cr> autocmd FileType java inorea <buffer> cfunpr <c-r>=IMAP_PutTextWithMovement("private<++> <++>(<++>) {\n<++>;\nreturn <++>;\n}")<cr> autocmd FileType java inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for(<++>; <++>; <++>) {\n<++>;\n}")<cr> autocmd FileType java inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}")<cr> autocmd FileType java inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if(<++>) {\n<++>;\n}\nelse {\n<++>;\n}")<cr> autocmd FileType java inorea <buffer> cwh <c-r>=IMAP_PutTextWithMovement("while(<++>) {\n<++>;\n}")<cr> autocmd FileType java inorea <buffer> cclass <c-r>=IMAP_PutTextWithMovement("<++> class <++> {\n<++>\n}")<cr> autocmd FileType java inorea <buffer> cmain <c-r>=IMAP_PutTextWithMovement("public static void main(String[] argv) {\n<++>\n}")<cr> "Presse c-q insted of space (or other key) to complete the snippet imap <C-q> <C-]>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Cope""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""For Copemap <silent> <leader><cr> :noh<cr>"Orginal for allmap <leader>n :cn<cr>map <leader>p :cp<cr>map <leader>c :botright cw 10<cr>map <c-Q> <c-l><c-j>:q<cr>:botright cw 10<cr>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => MISC""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Remove the Windows ^Mnoremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>‘tzt‘m"Paste toggle - when pasting something in, don‘t indent.set pastetoggle=<F3>"Remove indenting on empty linesmap <F2> :%s/\s*$//g<cr>:noh<cr>‘‘"Super pasteinoremap <C-v> <esc>:set paste<cr>mui<C-R>+<esc>mv‘uV‘v=:set nopaste<cr>"A function that inserts links & anchors on a TOhtml export." Notice:" Syntax used is:" *> Link" => Anchorfunction! SmartTOHtml() TOhtml try %s/"\s\+\*> \(.\+\)</" <a href="http://www.mamicode.com/#/1" style="color: cyan">\1<\/a></g %s/"\(-\|\s\)\+\*> \(.\+\)</" \ \ <a href="http://www.mamicode.com/#/2" style="color: cyan;">\2<\/a></g %s/"\s\+=> \(.\+\)</" <a name="\1" style="color: #fff">\1<\/a></g catch endtry exe ":write!" exe ":bd"endfunction"设置tags的路径:set tags=~/.tags"让你在插入模式下通过按[Ctrl]N自动地将任何类、方法或者字段名填满"设置Tlistlet Tlist_Show_One_File=1let Tlist_Exit_OnlyWindow=1"通过WinManager插件来将TagList窗口和netrw窗口整合起来let g:winManagerWindowLayout=‘BufExplorer,FileExplorer|TagList‘"let g:winManagerWindowLayout=‘NerdTree|TagList‘nmap wm :WMToggle<cr>let javabrowser_ctags_cmd=‘~/.ctags‘"这个是设定是否使用 quickfix 窗口来显示 cscope 结果:set cscopequickfix=s-,c-,d-,i-,t-,e-"cs的快捷键设置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>"设置多个文件编辑的buffer" <C-Tab>向前循环切换到每个buffer上,并在但前窗口打开"<C-S-Tab> 向后循环切换到每个buffer上,并在但前窗口打开let g:miniBufExplMapCTabSwitchBufs = 1"则可以用<C-h,j,k,l>切换到上下左右的窗口中去let g:miniBufExplMapWindowNavVim = 1"是用<C-箭头键>切换到上下左右窗口中去let g:miniBufExplMapWindowNavArrows = 1" 在新Buffer中切换到c\h文件nnoremap <silent> <F12> :A<CR>"在工程中查找用的快捷键设置nnoremap <silent> <F3> :Grep<CR>"打开文件类型检测, 加了这句才可以用智能补全filetype plugin indent onset completeopt=longest,menu"以后当你准备按"Ctrl+X Ctrl+O"的时候直接按<Tab>就好了, 够爽吧 ...." 0 - 不记录上次的补全方式" 1 - 记住上次的补全方式,直到用其他的补全命令改变它" 2 - 记住上次的补全方式,直到按ESC退出插入模式为止let g:SuperTabRetainCompletionType=2" 设置按下<Tab>后默认的补全方式, 默认是<C-P>," 现在改为<C-X><C-O>. 关于<C-P>的补全方式," 还有其他的补全方式, 你可以看看下面的一些帮助:" :help ins-completion" :help compl-omnilet g:SuperTabDefaultCompletionType="<C-X><C-O>"setlocal omnifunc=javacomplete#Completeset complete=.,w,b,u,t,i"NERDTreemap <F12> :NERDTreeToggle<cr>map gsgb :InsertGetterSetter<cr>
vim 配置文件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。