codekingpro/portable-devtools
114k
1" Vim support file to define the default menus2" You can also use this as a start for your own set of menus.3"4" Maintainer: The Vim Project <https://github.com/vim/vim>5" Last Change: 2026 Jan 196" Former Maintainer: Bram Moolenaar <Bram@vim.org>7 8" Note that ":an" (short for ":anoremenu") is often used to make a menu work9" in all modes and avoid side effects from mappings defined by the user.10 11" Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise12" <CR> would not be recognized. See ":help 'cpoptions'".13let s:cpo_save = &cpo14set cpo&vim15 16" Avoid installing the menus twice17if !exists("did_install_default_menus")18let did_install_default_menus = 119 20 21if exists("v:lang") || &langmenu != ""22 " Try to find a menu translation file for the current language.23 if &langmenu != ""24 if &langmenu =~ "none"25 let s:lang = ""26 else27 let s:lang = &langmenu28 endif29 else30 let s:lang = v:lang31 endif32 " A language name must be at least two characters, don't accept "C"33 " Also skip "en_US" to avoid picking up "en_gb" translations.34 if strlen(s:lang) > 1 && s:lang !~? '^en_us'35 " When the language does not include the charset add 'encoding'36 if s:lang =~ '^\a\a$\|^\a\a_\a\a$'37 let s:lang = s:lang .. '.' .. &enc38 endif39 40 " We always use a lowercase name.41 " Change "iso-8859" to "iso_8859" and "iso8859" to "iso_8859", some42 " systems appear to use this.43 " Change spaces to underscores.44 let s:lang = substitute(tolower(s:lang), '\.iso-', ".iso_", "")45 let s:lang = substitute(s:lang, '\.iso8859', ".iso_8859", "")46 let s:lang = substitute(s:lang, " ", "_", "g")47 " Remove "@euro", otherwise "LC_ALL=de_DE@euro gvim" will show English menus48 let s:lang = substitute(s:lang, "@euro", "", "")49 " Change "iso_8859-1" and "iso_8859-15" to "latin1", we always use the50 " same menu file for them.51 let s:lang = substitute(s:lang, 'iso_8859-15\=$', "latin1", "")52 menutrans clear53 exe "runtime! lang/menu_" .. s:lang .. ".vim"54 55 if !exists("did_menu_trans")56 " There is no exact match, try matching with a wildcard added57 " (e.g. find menu_de_de.iso_8859-1.vim if s:lang == de_DE).58 let s:lang = substitute(s:lang, '\.[^.]*', "", "")59 exe "runtime! lang/menu_" .. s:lang .. "[^a-z]*vim"60 61 if !exists("did_menu_trans") && s:lang =~ '_'62 " If the language includes a region try matching without that region.63 " (e.g. find menu_de.vim if s:lang == de_DE).64 let langonly = substitute(s:lang, '_.*', "", "")65 exe "runtime! lang/menu_" .. langonly .. "[^a-z]*vim"66 endif67 68 if !exists("did_menu_trans") && strlen($LANG) > 1 && s:lang !~ '^en_us'69 " On windows locale names are complicated, try using $LANG, it might70 " have been set by set_init_1(). But don't do this for "en" or "en_us".71 " But don't match "slovak" when $LANG is "sl".72 exe "runtime! lang/menu_" .. tolower($LANG) .. "[^a-z]*vim"73 endif74 endif75 endif76endif77 78 79" Help menu80an 9999.10 &Help.&Overview<Tab><F1> :help<CR>81an 9999.20 &Help.&User\ Manual :help usr_toc<CR>82an 9999.30 &Help.&How-To\ Links :help how-to<CR>83an <silent> 9999.40 &Help.&Find\.\.\. :call <SID>Helpfind()<CR>84an 9999.45 &Help.-sep1- <Nop>85an 9999.50 &Help.&Credits :help credits<CR>86an 9999.60 &Help.Co&pying :help copying<CR>87an 9999.70 &Help.&Sponsor :help sponsor<CR>88an 9999.70 &Help.O&rphans :help kcc<CR>89an 9999.75 &Help.-sep2- <Nop>90an 9999.80 &Help.&Version :version<CR>91an 9999.90 &Help.&About :intro<CR>92 93if exists(':tlmenu')94 tlnoremenu 9999.10 &Help.&Overview<Tab><F1> <C-W>:help<CR>95 tlnoremenu 9999.20 &Help.&User\ Manual <C-W>:help usr_toc<CR>96 tlnoremenu 9999.30 &Help.&How-To\ Links <C-W>:help how-to<CR>97 tlnoremenu <silent> 9999.40 &Help.&Find\.\.\. <C-W>:call <SID>Helpfind()<CR>98 tlnoremenu 9999.45 &Help.-sep1- <Nop>99 tlnoremenu 9999.50 &Help.&Credits <C-W>:help credits<CR>100 tlnoremenu 9999.60 &Help.Co&pying <C-W>:help copying<CR>101 tlnoremenu 9999.70 &Help.&Sponsor <C-W>:help sponsor<CR>102 tlnoremenu 9999.70 &Help.O&rphans <C-W>:help kcc<CR>103 tlnoremenu 9999.75 &Help.-sep2- <Nop>104 tlnoremenu 9999.80 &Help.&Version <C-W>:version<CR>105 tlnoremenu 9999.90 &Help.&About <C-W>:intro<CR>106endif107 108def s:Helpfind()109 if !exists("g:menutrans_help_dialog")110 g:menutrans_help_dialog = "Enter a command or word to find help on:\n\nPrepend i_ for Input mode commands (e.g.: i_CTRL-X)\nPrepend c_ for command-line editing commands (e.g.: c_<Del>)\nPrepend ' for an option name (e.g.: 'shiftwidth')"111 endif112 var h = inputdialog(g:menutrans_help_dialog)113 if h != ""114 v:errmsg = ""115 silent! exe "help " .. h116 if v:errmsg != ""117 echo v:errmsg118 endif119 endif120enddef121 122" File menu123an 10.310 &File.&Open\.\.\.<Tab>:e :browse confirm e<CR>124an 10.320 &File.Sp&lit-Open\.\.\.<Tab>:sp :browse sp<CR>125an 10.320 &File.Open\ &Tab\.\.\.<Tab>:tabnew :browse tabnew<CR>126an 10.325 &File.&New<Tab>:enew :confirm enew<CR>127an <silent> 10.330 &File.&Close<Tab>:close128 \ :if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar>129 \ confirm enew <Bar>130 \ else <Bar>131 \ confirm close <Bar>132 \ endif<CR>133tln <silent> 10.330 &File.&Close<Tab>:close134 \ <C-W>:if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar>135 \ confirm enew <Bar>136 \ else <Bar>137 \ confirm close <Bar>138 \ endif<CR>139an 10.335 &File.-SEP1- <Nop>140an <silent> 10.340 &File.&Save<Tab>:w :if expand("%") == ""<Bar>browse confirm w<Bar>else<Bar>confirm w<Bar>endif<CR>141an 10.350 &File.Save\ &As\.\.\.<Tab>:sav :browse confirm saveas<CR>142 143if has("diff")144 an 10.400 &File.-SEP2- <Nop>145 an 10.410 &File.Split\ &Diff\ With\.\.\. :browse vert diffsplit<CR>146 an 10.420 &File.Split\ Patched\ &By\.\.\. :browse vert diffpatch<CR>147endif148 149if has("printer")150 an 10.500 &File.-SEP3- <Nop>151 an 10.510 &File.&Print :hardcopy<CR>152 vunmenu &File.&Print153 vnoremenu &File.&Print :hardcopy<CR>154elseif has("unix")155 an 10.500 &File.-SEP3- <Nop>156 an 10.510 &File.&Print :w !lpr<CR>157 vunmenu &File.&Print158 vnoremenu &File.&Print :w !lpr<CR>159endif160an 10.600 &File.-SEP4- <Nop>161an 10.610 &File.Sa&ve-Exit<Tab>:wqa :confirm wqa<CR>162an 10.620 &File.E&xit<Tab>:qa :confirm qa<CR>163 164def s:SelectAll()165 exe "norm! gg" .. (&slm == "" ? "VG" : "gH\<C-O>G")166enddef167 168" Edit menu169an 20.310 &Edit.&Undo<Tab>u u170an 20.320 &Edit.&Redo<Tab>^R <C-R>171an 20.330 &Edit.Rep&eat<Tab>\. .172 173an 20.335 &Edit.-SEP1- <Nop>174vnoremenu 20.340 &Edit.Cu&t<Tab>"+x "+x175vnoremenu 20.350 &Edit.&Copy<Tab>"+y "+y176cnoremenu 20.350 &Edit.&Copy<Tab>"+y <C-Y>177if exists(':tlmenu')178 tlnoremenu 20.350 &Edit.&Copy<Tab>"+y <C-W>:<C-Y><CR>179endif180nnoremenu 20.360 &Edit.&Paste<Tab>"+gP "+gP181cnoremenu &Edit.&Paste<Tab>"+gP <C-R>+182if exists(':tlmenu')183 tlnoremenu &Edit.&Paste<Tab>"+gP <C-W>"+184endif185exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP ' .. paste#paste_cmd['v']186exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP ' .. paste#paste_cmd['i']187nnoremenu 20.370 &Edit.Put\ &Before<Tab>[p [p188inoremenu &Edit.Put\ &Before<Tab>[p <C-O>[p189nnoremenu 20.380 &Edit.Put\ &After<Tab>]p ]p190inoremenu &Edit.Put\ &After<Tab>]p <C-O>]p191if has("win32")192 vnoremenu 20.390 &Edit.&Delete<Tab>x x193endif194noremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG :<C-U>call <SID>SelectAll()<CR>195inoremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG <C-O>:call <SID>SelectAll()<CR>196cnoremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG <C-U>call <SID>SelectAll()<CR>197 198an 20.405 &Edit.-SEP2- <Nop>199if has("win32") || has("gui_gtk") || has("gui_kde") || has("gui_motif")200 an 20.410 &Edit.&Find\.\.\. :promptfind<CR>201 vunmenu &Edit.&Find\.\.\.202 vnoremenu <silent> &Edit.&Find\.\.\. y:promptfind <C-R>=<SID>FixFText()<CR><CR>203 an 20.420 &Edit.Find\ and\ Rep&lace\.\.\. :promptrepl<CR>204 vunmenu &Edit.Find\ and\ Rep&lace\.\.\.205 vnoremenu <silent> &Edit.Find\ and\ Rep&lace\.\.\. y:promptrepl <C-R>=<SID>FixFText()<CR><CR>206else207 an 20.410 &Edit.&Find<Tab>/ /208 an 20.420 &Edit.Find\ and\ Rep&lace<Tab>:%s :%s/209 vunmenu &Edit.Find\ and\ Rep&lace<Tab>:%s210 vnoremenu &Edit.Find\ and\ Rep&lace<Tab>:s :s/211endif212 213an 20.425 &Edit.-SEP3- <Nop>214an 20.430 &Edit.Settings\ &Window :options<CR>215an 20.435 &Edit.Startup\ &Settings :call <SID>EditVimrc()<CR>216 217def s:EditVimrc()218 var fname: string219 if $MYVIMRC != ''220 fname = $MYVIMRC221 elseif has("win32")222 if $HOME != ''223 fname = $HOME .. "/_vimrc"224 else225 fname = $VIM .. "/_vimrc"226 endif227 elseif has("amiga")228 fname = "s:.vimrc"229 else230 fname = $HOME .. "/.vimrc"231 endif232 fname = fnameescape(fname)233 if &mod234 exe "split " .. fname235 else236 exe "edit " .. fname237 endif238enddef239 240def s:FixFText(): string241 # Fix text in nameless register to be used with :promptfind.242 return substitute(@", "[\r\n]", '\\n', 'g')243enddef244 245" Edit/Global Settings246an 20.440.100 &Edit.&Global\ Settings.Toggle\ Pattern\ &Highlight<Tab>:set\ hls! :set hls! hls?<CR>247an 20.440.110 &Edit.&Global\ Settings.Toggle\ &Ignoring\ Case<Tab>:set\ ic! :set ic! ic?<CR>248an 20.440.110 &Edit.&Global\ Settings.Toggle\ &Showing\ Matched\ Pairs<Tab>:set\ sm! :set sm! sm?<CR>249 250an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 1\ :set so=1<CR>251an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 2\ :set so=2<CR>252an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 3\ :set so=3<CR>253an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 4\ :set so=4<CR>254an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 5\ :set so=5<CR>255an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 7\ :set so=7<CR>256an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 10\ :set so=10<CR>257an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 100\ :set so=100<CR>258 259an 20.440.130.40 &Edit.&Global\ Settings.&Virtual\ Edit.Never :set ve=<CR>260an 20.440.130.50 &Edit.&Global\ Settings.&Virtual\ Edit.Block\ Selection :set ve=block<CR>261an 20.440.130.60 &Edit.&Global\ Settings.&Virtual\ Edit.Insert\ Mode :set ve=insert<CR>262an 20.440.130.70 &Edit.&Global\ Settings.&Virtual\ Edit.Block\ and\ Insert :set ve=block,insert<CR>263an 20.440.130.80 &Edit.&Global\ Settings.&Virtual\ Edit.Always :set ve=all<CR>264an 20.440.140 &Edit.&Global\ Settings.Toggle\ Insert\ &Mode<Tab>:set\ im! :set im!<CR>265an 20.440.145 &Edit.&Global\ Settings.Toggle\ Vi\ C&ompatibility<Tab>:set\ cp! :set cp!<CR>266an <silent> 20.440.150 &Edit.&Global\ Settings.Search\ &Path\.\.\. :call <SID>SearchP()<CR>267an <silent> 20.440.160 &Edit.&Global\ Settings.Ta&g\ Files\.\.\. :call <SID>TagFiles()<CR>268"269" GUI options270an 20.440.300 &Edit.&Global\ Settings.-SEP1- <Nop>271an <silent> 20.440.310 &Edit.&Global\ Settings.Toggle\ &Toolbar :call <SID>ToggleGuiOption("T")<CR>272an <silent> 20.440.320 &Edit.&Global\ Settings.Toggle\ &Bottom\ Scrollbar :call <SID>ToggleGuiOption("b")<CR>273an <silent> 20.440.330 &Edit.&Global\ Settings.Toggle\ &Left\ Scrollbar :call <SID>ToggleGuiOption("l")<CR>274an <silent> 20.440.340 &Edit.&Global\ Settings.Toggle\ &Right\ Scrollbar :call <SID>ToggleGuiOption("r")<CR>275 276def s:SearchP()277 if !exists("g:menutrans_path_dialog")278 g:menutrans_path_dialog = "Enter search path for files.\nSeparate directory names with a comma."279 endif280 var n = inputdialog(g:menutrans_path_dialog, substitute(&path, '\\ ', ' ', 'g'))281 if n != ""282 &path = substitute(n, ' ', '\\ ', 'g')283 endif284enddef285 286def s:TagFiles()287 if !exists("g:menutrans_tags_dialog")288 g:menutrans_tags_dialog = "Enter names of tag files.\nSeparate the names with a comma."289 endif290 var n = inputdialog(g:menutrans_tags_dialog, substitute(&tags, '\\ ', ' ', 'g'))291 if n != ""292 &tags = substitute(n, ' ', '\\ ', 'g')293 endif294enddef295 296def s:ToggleGuiOption(option: string)297 # If a:option is already set in guioptions, then we want to remove it298 if match(&guioptions, "\\C" .. option) > -1299 exec "set go-=" .. option300 else301 exec "set go+=" .. option302 endif303enddef304 305" Edit/File Settings306 307" Boolean options308an 20.440.100 &Edit.F&ile\ Settings.Toggle\ Line\ &Numbering<Tab>:set\ nu! :set nu! nu?<CR>309an 20.440.105 &Edit.F&ile\ Settings.Toggle\ Relati&ve\ Line\ Numbering<Tab>:set\ rnu! :set rnu! rnu?<CR>310an 20.440.110 &Edit.F&ile\ Settings.Toggle\ &List\ Mode<Tab>:set\ list! :set list! list?<CR>311an 20.440.120 &Edit.F&ile\ Settings.Toggle\ Line\ &Wrapping<Tab>:set\ wrap! :set wrap! wrap?<CR>312an 20.440.130 &Edit.F&ile\ Settings.Toggle\ W&rapping\ at\ Word<Tab>:set\ lbr! :set lbr! lbr?<CR>313an 20.440.160 &Edit.F&ile\ Settings.Toggle\ Tab\ &Expanding<Tab>:set\ et! :set et! et?<CR>314an 20.440.170 &Edit.F&ile\ Settings.Toggle\ &Auto\ Indenting<Tab>:set\ ai! :set ai! ai?<CR>315an 20.440.180 &Edit.F&ile\ Settings.Toggle\ &C-Style\ Indenting<Tab>:set\ cin! :set cin! cin?<CR>316 317" other options318an 20.440.600 &Edit.F&ile\ Settings.-SEP2- <Nop>319an 20.440.610.20 &Edit.F&ile\ Settings.&Shiftwidth.2 :set sw=2 sw?<CR>320an 20.440.610.30 &Edit.F&ile\ Settings.&Shiftwidth.3 :set sw=3 sw?<CR>321an 20.440.610.40 &Edit.F&ile\ Settings.&Shiftwidth.4 :set sw=4 sw?<CR>322an 20.440.610.50 &Edit.F&ile\ Settings.&Shiftwidth.5 :set sw=5 sw?<CR>323an 20.440.610.60 &Edit.F&ile\ Settings.&Shiftwidth.6 :set sw=6 sw?<CR>324an 20.440.610.80 &Edit.F&ile\ Settings.&Shiftwidth.8 :set sw=8 sw?<CR>325 326an 20.440.620.20 &Edit.F&ile\ Settings.Soft\ &Tabstop.2 :set sts=2 sts?<CR>327an 20.440.620.30 &Edit.F&ile\ Settings.Soft\ &Tabstop.3 :set sts=3 sts?<CR>328an 20.440.620.40 &Edit.F&ile\ Settings.Soft\ &Tabstop.4 :set sts=4 sts?<CR>329an 20.440.620.50 &Edit.F&ile\ Settings.Soft\ &Tabstop.5 :set sts=5 sts?<CR>330an 20.440.620.60 &Edit.F&ile\ Settings.Soft\ &Tabstop.6 :set sts=6 sts?<CR>331an 20.440.620.80 &Edit.F&ile\ Settings.Soft\ &Tabstop.8 :set sts=8 sts?<CR>332 333an <silent> 20.440.630 &Edit.F&ile\ Settings.Te&xt\ Width\.\.\. :call <SID>TextWidth()<CR>334an <silent> 20.440.640 &Edit.F&ile\ Settings.&File\ Format\.\.\. :call <SID>FileFormat()<CR>335 336def s:TextWidth()337 if !exists("g:menutrans_textwidth_dialog")338 g:menutrans_textwidth_dialog = "Enter new text width (0 to disable formatting): "339 endif340 var n = inputdialog(g:menutrans_textwidth_dialog, &tw .. '')341 if n != ""342 # Remove leading zeros to avoid it being used as an octal number.343 # But keep a zero by itself.344 var tw = substitute(n, "^0*", "", "")345 &tw = tw == '' ? 0 : str2nr(tw)346 endif347enddef348 349def s:FileFormat()350 if !exists("g:menutrans_fileformat_dialog")351 g:menutrans_fileformat_dialog = "Select format for writing the file"352 endif353 if !exists("g:menutrans_fileformat_choices")354 g:menutrans_fileformat_choices = "&Unix\n&Dos\n&Mac\n&Cancel"355 endif356 var def_choice: number357 if &ff == "dos"358 def_choice = 2359 elseif &ff == "mac"360 def_choice = 3361 else362 def_choice = 1363 endif364 var n = confirm(g:menutrans_fileformat_dialog, g:menutrans_fileformat_choices, def_choice, "Question")365 if n == 1366 set ff=unix367 elseif n == 2368 set ff=dos369 elseif n == 3370 set ff=mac371 endif372enddef373 374let s:did_setup_color_schemes = 0375 376" Setup the Edit.Color Scheme submenu377def s:SetupColorSchemes()378 if s:did_setup_color_schemes379 return380 endif381 s:did_setup_color_schemes = 1382 383 var n = globpath(&runtimepath, "colors/*.vim", 1, 1)384 n += globpath(&packpath, "pack/*/start/*/colors/*.vim", 1, 1)385 n += globpath(&packpath, "pack/*/opt/*/colors/*.vim", 1, 1)386 387 # Ignore case for VMS and windows, sort on name388 var names = sort(map(n, 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 'i')389 390 # define all the submenu entries391 var idx = 100392 for name in names393 exe "an 20.450." .. idx .. ' &Edit.C&olor\ Scheme.' .. name .. " :colors " .. name .. "<CR>"394 idx += 10395 endfor396 silent! aunmenu &Edit.Show\ C&olor\ Schemes\ in\ Menu397enddef398 399if exists("do_no_lazyload_menus")400 call s:SetupColorSchemes()401else402 an <silent> 20.450 &Edit.Show\ C&olor\ Schemes\ in\ Menu :call <SID>SetupColorSchemes()<CR>403endif404 405 406" Setup the Edit.Keymap submenu407if has("keymap")408 let s:did_setup_keymaps = 0409 410 def s:SetupKeymaps()411 if s:did_setup_keymaps412 return413 endif414 s:did_setup_keymaps = 1415 416 var names = globpath(&runtimepath, "keymap/*.vim", 1, 1)417 if !empty(names)418 var idx = 100419 an 20.460.90 &Edit.&Keymap.None :set keymap=<CR>420 for name in names421 # Ignore case for VMS and windows422 var mapname = substitute(name, '\c.*[/\\:\]]\([^/\\:_]*\)\(_[0-9a-zA-Z-]*\)\=\.vim', '\1', '')423 exe "an 20.460." .. idx .. ' &Edit.&Keymap.' .. mapname .. " :set keymap=" .. mapname .. "<CR>"424 idx += 10425 endfor426 endif427 silent! aunmenu &Edit.Show\ &Keymaps\ in\ Menu428 enddef429 430 if exists("do_no_lazyload_menus")431 call s:SetupKeymaps()432 else433 an <silent> 20.460 &Edit.Show\ &Keymaps\ in\ Menu :call <SID>SetupKeymaps()<CR>434 endif435endif436 437if has("win32") || has("gui_motif") || has("gui_gtk") || has("gui_kde") || has("gui_photon") || has("gui_mac")438 an 20.470 &Edit.Select\ Fo&nt\.\.\. :set guifont=*<CR>439endif440 441" Programming menu442if !exists("g:ctags_command")443 if has("vms")444 let g:ctags_command = "mc vim:ctags *.*"445 else446 let g:ctags_command = "ctags -R ."447 endif448endif449 450an 40.300 &Tools.&Jump\ to\ This\ Tag<Tab>g^] g<C-]>451vunmenu &Tools.&Jump\ to\ This\ Tag<Tab>g^]452vnoremenu &Tools.&Jump\ to\ This\ Tag<Tab>g^] g<C-]>453an 40.310 &Tools.Jump\ &Back<Tab>^T <C-T>454an 40.320 &Tools.Build\ &Tags\ File :exe "!" .. g:ctags_command<CR>455 456if has("folding") || has("spell")457 an 40.330 &Tools.-SEP1- <Nop>458endif459 460" Tools.Spelling Menu461if has("spell")462 an 40.335.110 &Tools.&Spelling.&Spell\ Check\ On :set spell<CR>463 an 40.335.120 &Tools.&Spelling.Spell\ Check\ &Off :set nospell<CR>464 an 40.335.130 &Tools.&Spelling.To\ &Next\ Error<Tab>]s ]s465 an 40.335.130 &Tools.&Spelling.To\ &Previous\ Error<Tab>[s [s466 an 40.335.140 &Tools.&Spelling.Suggest\ &Corrections<Tab>z= z=467 an 40.335.150 &Tools.&Spelling.&Repeat\ Correction<Tab>:spellrepall :spellrepall<CR>468 an 40.335.200 &Tools.&Spelling.-SEP1- <Nop>469 an 40.335.210 &Tools.&Spelling.Set\ Language\ to\ "en" :set spl=en spell<CR>470 an 40.335.220 &Tools.&Spelling.Set\ Language\ to\ "en_au" :set spl=en_au spell<CR>471 an 40.335.230 &Tools.&Spelling.Set\ Language\ to\ "en_ca" :set spl=en_ca spell<CR>472 an 40.335.240 &Tools.&Spelling.Set\ Language\ to\ "en_gb" :set spl=en_gb spell<CR>473 an 40.335.250 &Tools.&Spelling.Set\ Language\ to\ "en_nz" :set spl=en_nz spell<CR>474 an 40.335.260 &Tools.&Spelling.Set\ Language\ to\ "en_us" :set spl=en_us spell<CR>475 an <silent> 40.335.270 &Tools.&Spelling.&Find\ More\ Languages :call <SID>SpellLang()<CR>476 477 let s:undo_spelllang = ['aun &Tools.&Spelling.&Find\ More\ Languages']478 def s:SpellLang(encChanged = false)479 for cmd in s:undo_spelllang480 exe "silent! " .. cmd481 endfor482 s:undo_spelllang = []483 484 var enc = &enc == "iso-8859-15" ? "latin1" : &enc485 486 # Reset g:menutrans_set_lang_to when called for the EncodingChanged event.487 if !exists("g:menutrans_set_lang_to") || encChanged488 g:menutrans_set_lang_to = 'Set Language to'489 endif490 491 var found = 0492 var _nm = ''493 var names = globpath(&runtimepath, "spell/*." .. enc .. ".spl", 1, 1)494 if !empty(names)495 var n = 300496 for f in names497 var nm = substitute(f, '.*spell[/\\]\(..\)\.[^/\\]*\.spl', '\1', "")498 if nm != "en" && nm !~ '/'499 _nm = nm500 found += 1501 var menuname = '&Tools.&Spelling.' .. escape(g:menutrans_set_lang_to, "\\. \t|") .. '\ "' .. nm .. '"'502 exe 'an 40.335.' .. n .. ' ' .. menuname .. ' :set spl=' .. nm .. ' spell<CR>'503 s:undo_spelllang += ['aun ' .. menuname]504 endif505 n += 10506 endfor507 endif508 if found == 0509 echomsg "Could not find other spell files"510 elseif found == 1511 echomsg "Found spell file " .. _nm512 else513 echomsg "Found " .. found .. " more spell files"514 endif515 516 # Need to redo this when 'encoding' is changed.517 augroup spellmenu518 au! EncodingChanged * call SpellLang(true)519 augroup END520 enddef521endif522 523" Tools.Fold Menu524if has("folding")525 " open close folds526 an 40.340.110 &Tools.&Folding.&Enable/Disable\ Folds<Tab>zi zi527 an 40.340.120 &Tools.&Folding.&View\ Cursor\ Line<Tab>zv zv528 an 40.340.120 &Tools.&Folding.Vie&w\ Cursor\ Line\ Only<Tab>zMzx zMzx529 inoremenu 40.340.120 &Tools.&Folding.Vie&w\ Cursor\ Line\ Only<Tab>zMzx <C-O>zM<C-O>zx530 an 40.340.130 &Tools.&Folding.C&lose\ More\ Folds<Tab>zm zm531 an 40.340.140 &Tools.&Folding.&Close\ All\ Folds<Tab>zM zM532 an 40.340.150 &Tools.&Folding.O&pen\ More\ Folds<Tab>zr zr533 an 40.340.160 &Tools.&Folding.&Open\ All\ Folds<Tab>zR zR534 " fold method535 an 40.340.200 &Tools.&Folding.-SEP1- <Nop>536 an 40.340.210 &Tools.&Folding.Fold\ Met&hod.M&anual :set fdm=manual<CR>537 an 40.340.210 &Tools.&Folding.Fold\ Met&hod.I&ndent :set fdm=indent<CR>538 an 40.340.210 &Tools.&Folding.Fold\ Met&hod.E&xpression :set fdm=expr<CR>539 an 40.340.210 &Tools.&Folding.Fold\ Met&hod.S&yntax :set fdm=syntax<CR>540 an 40.340.210 &Tools.&Folding.Fold\ Met&hod.&Diff :set fdm=diff<CR>541 an 40.340.210 &Tools.&Folding.Fold\ Met&hod.Ma&rker :set fdm=marker<CR>542 " create and delete folds543 vnoremenu 40.340.220 &Tools.&Folding.Create\ &Fold<Tab>zf zf544 an 40.340.230 &Tools.&Folding.&Delete\ Fold<Tab>zd zd545 an 40.340.240 &Tools.&Folding.Delete\ &All\ Folds<Tab>zD zD546 " moving around in folds547 an 40.340.300 &Tools.&Folding.-SEP2- <Nop>548 an 40.340.310.10 &Tools.&Folding.Fold\ Col&umn\ Width.\ &0\ :set fdc=0<CR>549 an 40.340.310.20 &Tools.&Folding.Fold\ Col&umn\ Width.\ &2\ :set fdc=2<CR>550 an 40.340.310.30 &Tools.&Folding.Fold\ Col&umn\ Width.\ &3\ :set fdc=3<CR>551 an 40.340.310.40 &Tools.&Folding.Fold\ Col&umn\ Width.\ &4\ :set fdc=4<CR>552 an 40.340.310.50 &Tools.&Folding.Fold\ Col&umn\ Width.\ &5\ :set fdc=5<CR>553 an 40.340.310.60 &Tools.&Folding.Fold\ Col&umn\ Width.\ &6\ :set fdc=6<CR>554 an 40.340.310.70 &Tools.&Folding.Fold\ Col&umn\ Width.\ &7\ :set fdc=7<CR>555 an 40.340.310.80 &Tools.&Folding.Fold\ Col&umn\ Width.\ &8\ :set fdc=8<CR>556endif " has folding557 558if has("diff")559 an 40.350.100 &Tools.&Diff.&Update :diffupdate<CR>560 an 40.350.110 &Tools.&Diff.&Get\ Block :diffget<CR>561 vunmenu &Tools.&Diff.&Get\ Block562 vnoremenu &Tools.&Diff.&Get\ Block :diffget<CR>563 an 40.350.120 &Tools.&Diff.&Put\ Block :diffput<CR>564 vunmenu &Tools.&Diff.&Put\ Block565 vnoremenu &Tools.&Diff.&Put\ Block :diffput<CR>566endif567 568an 40.358 &Tools.-SEP2- <Nop>569an 40.360 &Tools.&Make<Tab>:make :make<CR>570an 40.370 &Tools.&List\ Errors<Tab>:cl :cl<CR>571an 40.380 &Tools.L&ist\ Messages<Tab>:cl! :cl!<CR>572an 40.390 &Tools.&Next\ Error<Tab>:cn :cn<CR>573an 40.400 &Tools.&Previous\ Error<Tab>:cp :cp<CR>574an 40.410 &Tools.&Older\ List<Tab>:cold :colder<CR>575an 40.420 &Tools.N&ewer\ List<Tab>:cnew :cnewer<CR>576an 40.430.50 &Tools.Error\ &Window.&Update<Tab>:cwin :cwin<CR>577an 40.430.60 &Tools.Error\ &Window.&Open<Tab>:copen :copen<CR>578an 40.430.70 &Tools.Error\ &Window.&Close<Tab>:cclose :cclose<CR>579 580an 40.520 &Tools.-SEP3- <Nop>581an <silent> 40.530 &Tools.&Convert\ to\ HEX<Tab>:%!xxd582 \ :call <SID>XxdConv()<CR>583an <silent> 40.540 &Tools.Conve&rt\ Back<Tab>:%!xxd\ -r584 \ :call <SID>XxdBack()<CR>585 586" Use a function to do the conversion, so that it also works with 'insertmode'587" set.588def s:XxdConv()589 var mod = &mod590 if has("vms")591 :%!mc vim:xxd592 else593 s:XxdFind()594 exe ':%!' .. g:xxdprogram595 endif596 if getline(1) =~ "^00000000:" # only if it worked597 set ft=xxd598 endif599 &mod = mod600enddef601 602def s:XxdBack()603 var mod = &mod604 if has("vms")605 :%!mc vim:xxd -r606 else607 s:XxdFind()608 exe ':%!' .. g:xxdprogram .. ' -r'609 endif610 set ft=611 if exists('#filetypedetect') && exists('#BufReadPost')612 doautocmd filetypedetect BufReadPost613 endif614 &mod = mod615enddef616 617def s:XxdFind()618 if !exists("g:xxdprogram")619 # On the PC xxd may not be in the path but in the install directory620 if has("win32") && !executable("xxd")621 g:xxdprogram = $VIMRUNTIME .. (&shellslash ? '/' : '\') .. "xxd.exe"622 if g:xxdprogram =~ ' '623 g:xxdprogram = '"' .. g:xxdprogram .. '"'624 endif625 else626 g:xxdprogram = "xxd"627 endif628 endif629enddef630 631let s:did_setup_compilers = 0632 633" Setup the Tools.Compiler submenu634def s:SetupCompilers()635 if s:did_setup_compilers636 return637 endif638 s:did_setup_compilers = 1639 640 var names = globpath(&runtimepath, "compiler/*.vim", 1, 1)641 var idx = 100642 for name in names643 # Ignore case for VMS and windows644 var cname = substitute(name, '\c.*[/\\:\]]\([^/\\:]*\)\.vim', '\1', '')645 exe "an 30.440." .. idx .. ' &Tools.Se&t\ Compiler.' .. cname .. " :compiler " .. cname .. "<CR>"646 idx += 10647 endfor648 silent! aunmenu &Tools.Show\ Compiler\ Se&ttings\ in\ Menu649enddef650 651if exists("do_no_lazyload_menus")652 call s:SetupCompilers()653else654 an <silent> 30.440 &Tools.Show\ Compiler\ Se&ttings\ in\ Menu :call <SID>SetupCompilers()<CR>655endif656 657" Load ColorScheme, Compiler Setting and Keymap menus when idle.658if !exists("do_no_lazyload_menus")659 def s:SetupLazyloadMenus()660 s:SetupColorSchemes()661 s:SetupCompilers()662 if has("keymap")663 s:SetupKeymaps()664 endif665 enddef666 augroup SetupLazyloadMenus667 au!668 au CursorHold,CursorHoldI * call <SID>SetupLazyloadMenus() | au! SetupLazyloadMenus669 augroup END670endif671 672 673if !exists("no_buffers_menu")674 675" Buffer list menu -- Setup functions & actions676 677" wait with building the menu until after loading 'session' files. Makes678" startup faster.679let s:bmenu_wait = 1680 681" Dictionary of buffer number to name. This helps prevent problems where a682" buffer as renamed and we didn't keep track of that.683let s:bmenu_items = {}684 685if !exists("bmenu_priority")686 let bmenu_priority = 60687endif688 689" invoked from a BufCreate or BufFilePost autocommand690def s:BMAdd()691 if s:bmenu_wait == 0692 # when adding too many buffers, redraw in short format693 if s:bmenu_count == &menuitems && s:bmenu_short == 0694 s:BMShow()695 else696 var name = expand("<afile>")697 var num = str2nr(expand("<abuf>"))698 if s:BMCanAdd(name, num)699 s:BMFilename(name, num)700 s:bmenu_count += 1701 endif702 endif703 endif704enddef705 706" invoked from a BufDelete or BufFilePre autocommand707def s:BMRemove()708 if s:bmenu_wait == 0709 var bufnum = expand("<abuf>")710 if s:bmenu_items->has_key(bufnum)711 var menu_name = s:bmenu_items[bufnum]712 exe 'silent! aun &Buffers.' .. menu_name713 s:bmenu_count = s:bmenu_count - 1714 unlet s:bmenu_items[bufnum]715 endif716 endif717enddef718 719" Return non-zero if buffer with number "name" / "num" is useful to add in the720" buffer menu.721def s:BMCanAdd(name: string, num: number): bool722 # no directory or unlisted buffer723 if isdirectory(name) || !buflisted(num)724 return false725 endif726 727 # no name with control characters728 if name =~ '[\x01-\x1f]'729 return false730 endif731 732 # no special buffer, such as terminal or popup733 var buftype = getbufvar(num, '&buftype')734 if buftype != '' && buftype != 'nofile' && buftype != 'nowrite'735 return false736 endif737 738 # only existing buffers739 return bufexists(num)740enddef741 742" Create the buffer menu (delete an existing one first).743def s:BMShow()744 s:bmenu_wait = 1745 s:bmenu_short = 1746 s:bmenu_count = 0747 s:bmenu_items = {}748 749 # Remove old menu, if it exists; keep one entry to avoid a torn off menu to750 # disappear. Use try/catch to avoid setting v:errmsg751 try752 unmenu &Buffers753 catch754 endtry755 exe 'noremenu ' .. g:bmenu_priority .. ".1 &Buffers.Dummy l"756 try757 unmenu! &Buffers758 catch759 endtry760 761 # create new menu762 exe 'an <silent> ' .. g:bmenu_priority .. ".2 &Buffers.&Refresh\\ menu :call <SID>BMShow()<CR>"763 exe 'an ' .. g:bmenu_priority .. ".4 &Buffers.&Delete :confirm bd<CR>"764 exe 'an ' .. g:bmenu_priority .. ".6 &Buffers.&Alternate :confirm b #<CR>"765 exe 'an ' .. g:bmenu_priority .. ".7 &Buffers.&Next :confirm bnext<CR>"766 exe 'an ' .. g:bmenu_priority .. ".8 &Buffers.&Previous :confirm bprev<CR>"767 exe 'an ' .. g:bmenu_priority .. ".9 &Buffers.-SEP- :"768 unmenu &Buffers.Dummy769 770 # figure out how many buffers there are771 var buf = 1772 while buf <= bufnr('$')773 if s:BMCanAdd(bufname(buf), buf)774 s:bmenu_count = s:bmenu_count + 1775 endif776 buf += 1777 endwhile778 if s:bmenu_count <= &menuitems779 s:bmenu_short = 0780 endif781 782 # iterate through buffer list, adding each buffer to the menu:783 buf = 1784 while buf <= bufnr('$')785 var name = bufname(buf)786 if s:BMCanAdd(name, buf)787 call s:BMFilename(name, buf)788 endif789 buf += 1790 endwhile791 s:bmenu_wait = 0792 aug buffer_list793 au!794 au BufCreate,BufFilePost * call s:BMAdd()795 au BufDelete,BufFilePre * call s:BMRemove()796 aug END797enddef798 799def s:BMHash(name: string): number800 # Create a sortable numeric hash of the name. This number has to be within801 # the bounds of a signed 32-bit integer as this is what Vim GUI uses802 # internally for the index.803 804 # Make name all upper case, so that alphanumeric chars are between 32 and 96805 var nm = toupper(name)806 807 if char2nr(nm[0]) < 32 || char2nr(nm[0]) > 96808 # We don't have an ASCII character, so just return the raw character value809 # for first character (clamped to 2^31) and set the high bit to make it810 # sort after other items. This means only the first character will be811 # sorted, unfortunately.812 return or(and(char2nr(nm), 0x7fffffff), 0x40000000)813 endif814 815 var sp: number816 if has("ebcdic")817 # HACK: Replace all non alphabetics with 'Z'818 # Just to make it work for now.819 nm = substitute(nm, "[^A-Z]", 'Z', "g")820 sp = char2nr('A') - 1821 else822 sp = char2nr(' ')823 endif824 # convert first five chars into a number for sorting by compressing each825 # char into 5 bits (0-63), to a total of 30 bits. If any character is not826 # ASCII, it will simply be clamped to prevent overflow.827 return (max([0, min([63, char2nr(nm[0]) - sp])]) << 24) +828 (max([0, min([63, char2nr(nm[1]) - sp])]) << 18) +829 (max([0, min([63, char2nr(nm[2]) - sp])]) << 12) +830 (max([0, min([63, char2nr(nm[3]) - sp])]) << 6) +831 max([0, min([63, char2nr(nm[4]) - sp])])832enddef833 834def s:BMHash2(name: string): string835 var nm = tolower(name[0])836 if nm[0] < 'a' || nm[0] > 'z'837 return '&others.'838 elseif nm[0] <= 'd'839 return '&abcd.'840 elseif nm[0] <= 'h'841 return '&efgh.'842 elseif nm[0] <= 'l'843 return '&ijkl.'844 elseif nm[0] <= 'p'845 return '&mnop.'846 elseif nm[0] <= 't'847 return '&qrst.'848 else849 return '&u-z.'850 endif851enddef852 853" Insert a buffer name into the buffer menu.854def s:BMFilename(name: string, num: number)855 var munge = s:BMMunge(name, num)856 var hash = s:BMHash(munge)857 var cmd: string858 if s:bmenu_short == 0859 s:bmenu_items[num] = munge860 cmd = 'an ' .. g:bmenu_priority .. '.' .. hash .. ' &Buffers.' .. munge861 else862 var menu_name = s:BMHash2(munge) .. munge863 s:bmenu_items[num] = menu_name864 cmd = 'an ' .. g:bmenu_priority .. '.' .. hash .. '.' .. hash .. ' &Buffers.' .. menu_name865 endif866 exe cmd .. ' :confirm b' .. num .. '<CR>'867enddef868 869" Truncate a long path to fit it in a menu item.870if !exists("g:bmenu_max_pathlen")871 let g:bmenu_max_pathlen = 35872endif873 874def s:BMTruncName(fname: string): string875 var name = fname876 if g:bmenu_max_pathlen < 5877 name = ""878 else879 var len = strlen(name)880 if len > g:bmenu_max_pathlen881 var amountl = (g:bmenu_max_pathlen / 2) - 2882 var amountr = g:bmenu_max_pathlen - amountl - 3883 var pattern = '^\(.\{,' .. amountl .. '}\).\{-}\(.\{,' .. amountr .. '}\)$'884 var left = substitute(name, pattern, '\1', '')885 var right = substitute(name, pattern, '\2', '')886 if strlen(left) + strlen(right) < len887 name = left .. '...' .. right888 endif889 endif890 endif891 return name892enddef893 894def s:BMMunge(fname: string, bnum: number): string895 var name = fname896 if name == ''897 if !exists("g:menutrans_no_file")898 g:menutrans_no_file = "[No Name]"899 endif900 name = g:menutrans_no_file901 else902 name = fnamemodify(name, ':p:~')903 endif904 # detach file name and separate it out:905 var name2 = fnamemodify(name, ':t')906 if bnum >= 0907 name2 = name2 .. ' (' .. bnum .. ')'908 endif909 name = name2 .. "\t" .. s:BMTruncName(fnamemodify(name, ':h'))910 name = escape(name, "\\. \t|")911 name = substitute(name, "&", "&&", "g")912 name = substitute(name, "\n", "^@", "g")913 return name914enddef915 916" When just starting Vim, load the buffer menu later917if has("vim_starting")918 augroup LoadBufferMenu919 au! VimEnter * if !exists("no_buffers_menu") | call <SID>BMShow() | endif920 au VimEnter * au! LoadBufferMenu921 augroup END922else923 call <SID>BMShow()924endif925 926endif " !exists("no_buffers_menu")927 928" Window menu929an 70.300 &Window.&New<Tab>^Wn <C-W>n930an 70.310 &Window.S&plit<Tab>^Ws <C-W>s931an 70.320 &Window.Sp&lit\ To\ #<Tab>^W^^ <C-W><C-^>932an 70.330 &Window.Split\ &Vertically<Tab>^Wv <C-W>v933an <silent> 70.332 &Window.Split\ File\ E&xplorer :call MenuExplOpen()<CR>934if !exists("*MenuExplOpen")935 def MenuExplOpen()936 if @% == ""937 :20vsp .938 else939 exe ":20vsp " .. fnameescape(expand("%:p:h"))940 endif941 enddef942endif943an 70.335 &Window.-SEP1- <Nop>944an 70.340 &Window.&Close<Tab>^Wc :confirm close<CR>945an 70.345 &Window.Close\ &Other(s)<Tab>^Wo :confirm only<CR>946an 70.350 &Window.-SEP2- <Nop>947an 70.355 &Window.Move\ &To.&Top<Tab>^WK <C-W>K948an 70.355 &Window.Move\ &To.&Bottom<Tab>^WJ <C-W>J949an 70.355 &Window.Move\ &To.&Left\ Side<Tab>^WH <C-W>H950an 70.355 &Window.Move\ &To.&Right\ Side<Tab>^WL <C-W>L951an 70.360 &Window.Rotate\ &Up<Tab>^WR <C-W>R952an 70.362 &Window.Rotate\ &Down<Tab>^Wr <C-W>r953an 70.365 &Window.-SEP3- <Nop>954an 70.370 &Window.&Equal\ Size<Tab>^W= <C-W>=955an 70.380 &Window.&Max\ Height<Tab>^W_ <C-W>_956an 70.390 &Window.M&in\ Height<Tab>^W1_ <C-W>1_957an 70.400 &Window.Max\ &Width<Tab>^W\| <C-W>\|958an 70.410 &Window.Min\ Widt&h<Tab>^W1\| <C-W>1\|959 960" The popup menu961an 1.10 PopUp.&Undo u962an 1.15 PopUp.-SEP1- <Nop>963vnoremenu 1.20 PopUp.Cu&t "+x964vnoremenu 1.30 PopUp.&Copy "+y965cnoremenu 1.30 PopUp.&Copy <C-Y>966nnoremenu 1.40 PopUp.&Paste "+gP967cnoremenu 1.40 PopUp.&Paste <C-R>+968exe 'vnoremenu <script> 1.40 PopUp.&Paste ' .. paste#paste_cmd['v']969exe 'inoremenu <script> 1.40 PopUp.&Paste ' .. paste#paste_cmd['i']970vnoremenu 1.50 PopUp.&Delete x971an 1.55 PopUp.-SEP2- <Nop>972vnoremenu 1.60 PopUp.Select\ Blockwise <C-V>973 974nnoremenu 1.70 PopUp.Select\ &Word vaw975onoremenu 1.70 PopUp.Select\ &Word aw976vnoremenu 1.70 PopUp.Select\ &Word <C-C>vaw977inoremenu 1.70 PopUp.Select\ &Word <C-O>vaw978cnoremenu 1.70 PopUp.Select\ &Word <C-C>vaw979 980nnoremenu 1.73 PopUp.Select\ &Sentence vas981onoremenu 1.73 PopUp.Select\ &Sentence as982vnoremenu 1.73 PopUp.Select\ &Sentence <C-C>vas983inoremenu 1.73 PopUp.Select\ &Sentence <C-O>vas984cnoremenu 1.73 PopUp.Select\ &Sentence <C-C>vas985 986nnoremenu 1.77 PopUp.Select\ Pa&ragraph vap987onoremenu 1.77 PopUp.Select\ Pa&ragraph ap988vnoremenu 1.77 PopUp.Select\ Pa&ragraph <C-C>vap989inoremenu 1.77 PopUp.Select\ Pa&ragraph <C-O>vap990cnoremenu 1.77 PopUp.Select\ Pa&ragraph <C-C>vap991 992nnoremenu 1.80 PopUp.Select\ &Line V993onoremenu 1.80 PopUp.Select\ &Line <C-C>V994vnoremenu 1.80 PopUp.Select\ &Line <C-C>V995inoremenu 1.80 PopUp.Select\ &Line <C-O>V996cnoremenu 1.80 PopUp.Select\ &Line <C-C>V997 998nnoremenu 1.90 PopUp.Select\ &Block <C-V>999onoremenu 1.90 PopUp.Select\ &Block <C-C><C-V>1000vnoremenu 1.90 PopUp.Select\ &Block <C-C><C-V>1001inoremenu 1.90 PopUp.Select\ &Block <C-O><C-V>1002cnoremenu 1.90 PopUp.Select\ &Block <C-C><C-V>1003 1004noremenu <script> <silent> 1.100 PopUp.Select\ &All :<C-U>call <SID>SelectAll()<CR>1005inoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-O>:call <SID>SelectAll()<CR>1006cnoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-U>call <SID>SelectAll()<CR>1007 1008if has("spell")1009 " Spell suggestions in the popup menu. Note that this will slow down the1010 " appearance of the menu!1011 def s:SpellPopup()1012 if exists("s:changeitem") && s:changeitem != ''1013 call s:SpellDel()1014 endif1015 1016 # Return quickly if spell checking is not enabled.1017 if !&spell || &spelllang == ''1018 return1019 endif1020 1021 var curcol = col('.')1022 var w: string1023 var a: string1024 [w, a] = spellbadword()1025 if col('.') > curcol # don't use word after the cursor1026 w = ''1027 endif1028 if w != ''1029 if a == 'caps'1030 s:suglist = [substitute(w, '.*', '\u&', '')]1031 else1032 s:suglist = spellsuggest(w, 10)1033 endif1034 if len(s:suglist) > 01035 if !exists("g:menutrans_spell_change_ARG_to")1036 g:menutrans_spell_change_ARG_to = 'Change\ "%s"\ to'1037 endif1038 s:changeitem = printf(g:menutrans_spell_change_ARG_to, escape(w, ' .'))1039 s:fromword = w1040 var pri = 11041 for sug in s:suglist1042 exe 'anoremenu 1.5.' .. pri .. ' PopUp.' .. s:changeitem .. '.' .. escape(sug, ' .')1043 \ .. ' :call <SID>SpellReplace(' .. pri .. ')<CR>'1044 pri += 11045 endfor1046 1047 if !exists("g:menutrans_spell_add_ARG_to_word_list")1048 g:menutrans_spell_add_ARG_to_word_list = 'Add\ "%s"\ to\ Word\ List'1049 endif1050 s:additem = printf(g:menutrans_spell_add_ARG_to_word_list, escape(w, ' .'))1051 exe 'anoremenu 1.6 PopUp.' .. s:additem .. ' :spellgood ' .. w .. '<CR>'1052 1053 if !exists("g:menutrans_spell_ignore_ARG")1054 g:menutrans_spell_ignore_ARG = 'Ignore\ "%s"'1055 endif1056 s:ignoreitem = printf(g:menutrans_spell_ignore_ARG, escape(w, ' .'))1057 exe 'anoremenu 1.7 PopUp.' .. s:ignoreitem .. ' :spellgood! ' .. w .. '<CR>'1058 1059 anoremenu 1.8 PopUp.-SpellSep- :1060 endif1061 endif1062 call cursor(0, curcol) # put the cursor back where it was1063 enddef1064 1065 def s:SpellReplace(n: number)1066 var l = getline('.')1067 # Move the cursor to the start of the word.1068 call spellbadword()1069 call setline('.', strpart(l, 0, col('.') - 1) .. s:suglist[n - 1]1070 \ .. strpart(l, col('.') + len(s:fromword) - 1))1071 enddef1072 1073 def s:SpellDel()1074 exe "aunmenu PopUp." .. s:changeitem1075 exe "aunmenu PopUp." .. s:additem1076 exe "aunmenu PopUp." .. s:ignoreitem1077 aunmenu PopUp.-SpellSep-1078 s:changeitem = ''1079 enddef1080 1081 augroup SpellPopupMenu1082 au! MenuPopup * call <SID>SpellPopup()1083 augroup END1084endif1085 1086" The GUI toolbar (for MS-Windows and GTK)1087if has("toolbar")1088 an 1.10 ToolBar.Open :browse confirm e<CR>1089 an <silent> 1.20 ToolBar.Save :if expand("%") == ""<Bar>browse confirm w<Bar>else<Bar>confirm w<Bar>endif<CR>1090 an 1.30 ToolBar.SaveAll :browse confirm wa<CR>1091 1092 if has("printer")1093 an 1.40 ToolBar.Print :hardcopy<CR>1094 vunmenu ToolBar.Print1095 vnoremenu ToolBar.Print :hardcopy<CR>1096 elseif has("unix")1097 an 1.40 ToolBar.Print :w !lpr<CR>1098 vunmenu ToolBar.Print1099 vnoremenu ToolBar.Print :w !lpr<CR>1100 endif1101 1102 an 1.45 ToolBar.-sep1- <Nop>1103 an 1.50 ToolBar.Undo u1104 an 1.60 ToolBar.Redo <C-R>1105 1106 an 1.65 ToolBar.-sep2- <Nop>1107 vnoremenu 1.70 ToolBar.Cut "+x1108 vnoremenu 1.80 ToolBar.Copy "+y1109 cnoremenu 1.80 ToolBar.Copy <C-Y>1110 nnoremenu 1.90 ToolBar.Paste "+gP1111 cnoremenu ToolBar.Paste <C-R>+1112 exe 'vnoremenu <script> ToolBar.Paste ' .. paste#paste_cmd['v']1113 exe 'inoremenu <script> ToolBar.Paste ' .. paste#paste_cmd['i']1114 1115 if !has("gui_athena")1116 an 1.95 ToolBar.-sep3- <Nop>1117 an 1.100 ToolBar.Replace :promptrepl<CR>1118 vunmenu ToolBar.Replace1119 vnoremenu ToolBar.Replace y:promptrepl <C-R>=<SID>FixFText()<CR><CR>1120 an 1.110 ToolBar.FindNext n1121 an 1.120 ToolBar.FindPrev N1122 endif1123 1124 an 1.215 ToolBar.-sep5- <Nop>1125 an <silent> 1.220 ToolBar.LoadSesn :call <SID>LoadVimSesn()<CR>1126 an <silent> 1.230 ToolBar.SaveSesn :call <SID>SaveVimSesn()<CR>1127 an 1.240 ToolBar.RunScript :browse so<CR>1128 1129 an 1.245 ToolBar.-sep6- <Nop>1130 an 1.250 ToolBar.Make :make<CR>1131 an 1.270 ToolBar.RunCtags :exe "!" .. g:ctags_command<CR>1132 an 1.280 ToolBar.TagJump g<C-]>1133 1134 an 1.295 ToolBar.-sep7- <Nop>1135 an 1.300 ToolBar.Help :help<CR>1136 an <silent> 1.310 ToolBar.FindHelp :call <SID>Helpfind()<CR>1137 1138" Only set the tooltips here if not done in a language menu file1139if exists("*Do_toolbar_tmenu")1140 call Do_toolbar_tmenu()1141else1142 let did_toolbar_tmenu = 11143 tmenu ToolBar.Open Open file1144 tmenu ToolBar.Save Save current file1145 tmenu ToolBar.SaveAll Save all files1146 tmenu ToolBar.Print Print1147 tmenu ToolBar.Undo Undo1148 tmenu ToolBar.Redo Redo1149 tmenu ToolBar.Cut Cut to clipboard1150 tmenu ToolBar.Copy Copy to clipboard1151 tmenu ToolBar.Paste Paste from Clipboard1152 if !has("gui_athena")1153 tmenu ToolBar.Replace Find / Replace...1154 tmenu ToolBar.FindNext Find Next1155 tmenu ToolBar.FindPrev Find Previous1156 endif1157 tmenu ToolBar.LoadSesn Choose a session to load1158 tmenu ToolBar.SaveSesn Save current session1159 tmenu ToolBar.RunScript Choose a Vim script to run1160 tmenu ToolBar.Make Make current project (:make)1161 tmenu ToolBar.RunCtags Build tags in current directory tree (!ctags -R .)1162 tmenu ToolBar.TagJump Jump to tag under cursor1163 tmenu ToolBar.Help Vim Help1164 tmenu ToolBar.FindHelp Search Vim Help1165endif1166 1167" Select a session to load; default to current session name if present1168def s:LoadVimSesn()1169 var name: string1170 if strlen(v:this_session) > 01171 name = fnameescape(v:this_session)1172 else1173 name = "Session.vim"1174 endif1175 execute "browse so " .. name1176enddef1177 1178" Select a session to save; default to current session name if present1179def s:SaveVimSesn()1180 if strlen(v:this_session) == 01181 v:this_session = "Session.vim"1182 endif1183 execute "browse mksession! " .. fnameescape(v:this_session)1184enddef1185 1186endif1187 1188endif " !exists("did_install_default_menus")1189 1190" Define these items always, so that syntax can be switched on when it wasn't.1191" But skip them when the Syntax menu was disabled by the user.1192if !exists("did_install_syntax_menu")1193 an 50.212 &Syntax.&Manual :syn manual<CR>1194 an 50.214 &Syntax.A&utomatic :syn on<CR>1195 an <silent> 50.216 &Syntax.On/Off\ for\ &This\ File :call <SID>SynOnOff()<CR>1196 if !exists("*s:SynOnOff")1197 def s:SynOnOff()1198 if has("syntax_items")1199 syn clear1200 else