📄 menu.vim
字号:
" These menu commands create the default Vim menus." You can also use this as a start for your own set of menus." Note that ":amenu" is often used to make a menu work in all modes."" Maintainer: Bram Moolenaar <Bram@vim.org>" Last change: 2001 May 06" Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise" <CR> would not be recognized. See ":help 'cpoptions'".let menu_cpo_save = &cpolet &cpo = """ Avoid installing the menus twiceif !exists("did_install_default_menus")let did_install_default_menus = 1" Help menuamenu 9999.10 &Help.&Overview<Tab><F1> :help<CR>amenu 9999.20 &Help.&How-to\ links :help how-to<CR>amenu 9999.30 &Help.&GUI :help gui<CR>amenu 9999.40 &Help.&Credits :help credits<CR>amenu 9999.50 &Help.Co&pying :help uganda<CR>amenu 9999.55 &Help.-sep- <nul>amenu 9999.60 &Help.&Version :version<CR>amenu 9999.70 &Help.&About :intro<CR>" File menuamenu 10.310 &File.&Open\.\.\.<Tab>:e :browse confirm e<CR>amenu 10.320 &File.Sp&lit-Open\.\.\.<Tab>:sp :browse sp<CR>amenu 10.330 &File.&Close<Tab>:q :confirm q<CR>amenu 10.335 &File.-SEP1- :amenu 10.340 &File.&Save<Tab>:w :confirm w<CR>amenu 10.350 &File.Save\ &As\.\.\.<Tab>:w :browse confirm w<CR>amenu 10.355 &File.-SEP2- :if has("win32") " Use Notepad for printing. ":w >> prn" doesn't work for PostScript printers. amenu 10.360 &File.&Print :call Win32Print(":")<CR> vunmenu &File.&Print vmenu &File.&Print <Esc>:call Win32Print(":'<,'>")<CR> if !exists("*Win32Print") fun Win32Print(range) let mod_save = &mod let ff_save = &ff set ff=dos let ttt = tempname() exec a:range . "w! " . ttt let &ff = ff_save let &mod = mod_save exec "!notepad /p " . ttt exec "!del " . ttt endfun endifelseif has("unix") amenu 10.360 &File.&Print :w !lpr<CR> vunmenu &File.&Print vmenu &File.&Print :w !lpr<CR>endifamenu 10.365 &File.-SEP3- :amenu 10.370 &File.Sa&ve-Exit<Tab>:wqa :confirm wqa<CR>amenu 10.380 &File.E&xit<Tab>:qa :confirm qa<CR>" Edit menuamenu 20.310 &Edit.&Undo<Tab>u uamenu 20.320 &Edit.&Redo<Tab>^R <C-R>amenu 20.330 &Edit.Repea&t<Tab>\. .amenu 20.335 &Edit.-SEP1- :vmenu 20.340 &Edit.Cu&t<Tab>"*x "*xvmenu 20.350 &Edit.&Copy<Tab>"*y "*ynmenu 20.360 &Edit.&Paste<Tab>"*p "*pvmenu &Edit.&Paste<Tab>"*p "*P`]:if col(".")!=1<Bar>exe "norm l"<Bar>endif<CR>imenu &Edit.&Paste<Tab>"*p <Esc>:if col(".")!=1<Bar>exe 'norm "*p'<Bar>else<Bar>exe 'norm "*P'<Bar>endif<CR>`]acmenu &Edit.&Paste<Tab>"*p <C-R>*nmenu 20.370 &Edit.Put\ &Before<Tab>[p [pimenu &Edit.Put\ &Before<Tab>[p <C-O>[pnmenu 20.380 &Edit.Put\ &After<Tab>]p ]pimenu &Edit.Put\ &After<Tab>]p <C-O>]pif has("win32") vmenu 20.390 &Edit.&Delete<Tab>x xendifamenu 20.400 &Edit.&Select\ all<Tab>ggVG :if &slm != ""<Bar>exe ":norm gggH<C-O>G"<Bar>else<Bar>exe ":norm ggVG"<Bar>endif<CR>amenu 20.405 &Edit.-SEP2- :if has("win32") || has("gui_gtk") amenu 20.410 &Edit.&Find\.\.\. :promptfind<CR> amenu 20.420 &Edit.Find\ and\ R&eplace\.\.\. :promptrepl<CR> vunmenu &Edit.Find\ and\ R&eplace\.\.\. vmenu &Edit.Find\ and\ R&eplace\.\.\. y:promptrepl <C-R>"<CR>else amenu 20.410 &Edit.&Find<Tab>/ / amenu 20.420 &Edit.Find\ and\ R&eplace<Tab>:%s :%s/ vunmenu &Edit.Find\ and\ R&eplace vmenu &Edit.Find\ and\ R&eplace<Tab>:s :s/endifamenu 20.425 &Edit.-SEP3- :amenu 20.430 &Edit.Options\.\.\. :options<CR>" Programming menuamenu 40.300 &Tools.&Jump\ to\ this\ tag<Tab>g^] g<C-]>vunmenu &Tools.&Jump\ to\ this\ tag<Tab>g^]vmenu &Tools.&Jump\ to\ this\ tag<Tab>g^] g<C-]>amenu 40.310 &Tools.Jump\ &back<Tab>^T <C-T>amenu 40.320 &Tools.Build\ &Tags\ File :!ctags -R .<CR>amenu 40.330 &Tools.-SEP1- :amenu 40.340 &Tools.&Make<Tab>:make :make<CR>amenu 40.350 &Tools.&List\ Errors<Tab>:cl :cl<CR>amenu 40.360 &Tools.L&ist\ Messages<Tab>:cl! :cl!<CR>amenu 40.370 &Tools.&Next\ Error<Tab>:cn :cn<CR>amenu 40.380 &Tools.&Previous\ Error<Tab>:cp :cp<CR>amenu 40.390 &Tools.&Older\ List<Tab>:cold :colder<CR>amenu 40.400 &Tools.N&ewer\ List<Tab>:cnew :cnewer<CR>" Can't delete a menu in Athena versionif has("gui_athena") let no_buffers_menu = 1endifif !exists("no_buffers_menu")" Buffer list menu -- Setup functions & actions" wait with building the menu until after loading 'session' files. Makes" startup faster.let bmenu_wait = 1if !exists("bmenu_priority") let bmenu_priority = 60endiffunc! BmenuAdd() if g:bmenu_wait == 0 call BMenuFilename(expand("<afile>"), expand("<abuf>")) endifendfuncfunc! BmenuRemove() if g:bmenu_wait == 0 let munge = BmenuMunge(expand("<afile>"), expand("<abuf>")) if g:bmenu_short == 0 exe 'aun &Buffers.' . munge else exe 'aun &Buffers.' . BmenuHash2(munge) . munge endif let g:bmenu_count = g:bmenu_count - 1 endifendfunc" buffer menu stufffunc! BmenuShow(...) let g:bmenu_wait = 1 let g:bmenu_short = 1 let g:bmenu_count = 0 if !exists('g:bmenu_cutoff') let g:bmenu_cutoff = &lines / 2 endif " remove old menu, if exists exe g:bmenu_priority . 'am &Buffers.x x' aun &Buffers " get new priority, if exists if a:0 == 1 let g:bmenu_priority = a:1 endif " create new menu; make 'cpo' empty to include the <CR> let cpo_save = &cpo let &cpo = "" exe 'am ' . g:bmenu_priority . ".2 &Buffers.Refresh :call BmenuShow()<CR>" exe 'am ' . g:bmenu_priority . ".4 &Buffers.Delete :bd<CR>" exe 'am ' . g:bmenu_priority . ".6 &Buffers.Alternate :b #<CR>" exe 'am ' . g:bmenu_priority . ".8 &Buffers.-SEP- :" let &cpo = cpo_save " figure out how many buffers there are let buf = 1 while buf <= bufnr('$') if bufexists(buf) let g:bmenu_count = g:bmenu_count + 1 endif let buf = buf + 1 endwhile if g:bmenu_count < g:bmenu_cutoff let g:bmenu_short = 0 endif " iterate through buffer list, adding each buffer to the menu: let buf = 1 while buf <= bufnr('$') if bufexists(buf) call BMenuFilename(bufname(buf), buf) endif let buf = buf + 1 endwhile let g:bmenu_wait = 0 aug buffer_list au! au BufCreate,BufFilePost * call BmenuAdd() au BufDelete,BufFilePre * call BmenuRemove() aug ENDendfuncfunc! BmenuHash(name) " Make name all upper case, so that chars are between 32 and 96 let nm = substitute(a:name, ".*", '\U\0', "") " convert first six chars into a number for sorting: return (char2nr(nm[0]) - 32) * 0x1000000 + (char2nr(nm[1]) - 32) * 0x40000 + (char2nr(nm[2]) - 32) * 0x1000 + (char2nr(nm[3]) - 32) * 0x40 + (char2nr(nm[4]) - 32) * 0x40 + (char2nr(nm[5]) - 32)endfuncfunc! BmenuHash2(name) let nm = substitute(a:name, ".", '\L\0', "") if nm[0] >= 'a' && nm[0] <= 'd' return '&abcd.' elseif nm[0] >= 'e' && nm[0] <= 'h' return '&efgh.' elseif nm[0] >= 'i' && nm[0] <= 'l' return '&ijkl.' elseif nm[0] >= 'm' && nm[0] <= 'p' return '&mnop.' elseif nm[0] >= 'q' && nm[0] <= 't' return '&qrst.' elseif nm[0] >= 'u' && nm[0] <= 'z' return '&u-z.' else return '&others.'endfunc" take a buffer number, return a name to insert into a menu:func! BMenuFilename(name, num) let munge = BmenuMunge(a:name, a:num) let hash = BmenuHash(munge) if g:bmenu_short == 0 let name = 'am ' . g:bmenu_priority . '.' . hash .' &Buffers.' . munge else let name = 'am ' . g:bmenu_priority . '.' . hash . '.' . hash .' &Buffers.' . BmenuHash2(munge) . munge endif " make 'cpo' empty to include the <CR> let cpo_save = &cpo let &cpo = "" exe name . ' :b' . a:num . '<CR>' let &cpo = cpo_saveendfuncfunc! BmenuMunge(fname, bnum) let name = a:fname if name == '' let name = '[No File]' endif let name = fnamemodify(name, ':~') if !isdirectory(a:fname) " detach file name and separate it out: let name2 = fnamemodify(name, ':t') if a:bnum >= 0 let name2 = name2 . ' (' . a:bnum . ')' endif let name = name2 . "\t" . fnamemodify(name,':h') endif let name = escape(name, "\\. \t|") let name = substitute(name, "\n", "^@", "g") return nameendfunc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -