menu.vim (42876B)
1 " Vim support file to define the default menus 2 " 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 Oct 13 6 " Former Maintainer: Bram Moolenaar <Bram@vim.org> 7 8 " Note that ":an" (short for ":anoremenu") is often used to make a menu work 9 " 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', otherwise 12 " <CR> would not be recognized. See ":help 'cpoptions'". 13 let s:cpo_save = &cpo 14 set cpo&vim 15 16 " Avoid installing the menus twice 17 if !exists("did_install_default_menus") 18 let did_install_default_menus = 1 19 20 21 if 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 else 27 let s:lang = &langmenu 28 endif 29 else 30 let s:lang = v:lang 31 endif 32 " 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 .. '.' .. &enc 38 endif 39 40 " We always use a lowercase name. 41 " Change "iso-8859" to "iso_8859" and "iso8859" to "iso_8859", some 42 " 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 menus 48 let s:lang = substitute(s:lang, "@euro", "", "") 49 " Change "iso_8859-1" and "iso_8859-15" to "latin1", we always use the 50 " same menu file for them. 51 let s:lang = substitute(s:lang, 'iso_8859-15\=$', "latin1", "") 52 menutrans clear 53 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 added 57 " (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 endif 67 68 if !exists("did_menu_trans") && strlen($LANG) > 1 && s:lang !~ '^en_us' 69 " On windows locale names are complicated, try using $LANG, it might 70 " 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 endif 74 endif 75 endif 76 endif 77 78 79 " Help menu 80 an 9999.10 &Help.&Overview<Tab><F1> :help<CR> 81 an 9999.20 &Help.&User\ Manual :help usr_toc<CR> 82 an 9999.30 &Help.&How-To\ Links :help how-to<CR> 83 an <silent> 9999.40 &Help.&Find\.\.\. :call <SID>Helpfind()<CR> 84 an 9999.45 &Help.-sep1- <Nop> 85 an 9999.50 &Help.&Credits :help credits<CR> 86 an 9999.60 &Help.Co&pying :help copying<CR> 87 an 9999.70 &Help.&Sponsor :help sponsor<CR> 88 an 9999.70 &Help.O&rphans :help kcc<CR> 89 an 9999.75 &Help.-sep2- <Nop> 90 an 9999.80 &Help.&Version :version<CR> 91 an 9999.90 &Help.&About :intro<CR> 92 93 if 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> 106 endif 107 108 def 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 endif 112 var h = inputdialog(g:menutrans_help_dialog) 113 if h != "" 114 v:errmsg = "" 115 silent! exe "help " .. h 116 if v:errmsg != "" 117 echo v:errmsg 118 endif 119 endif 120 enddef 121 122 " File menu 123 an 10.310 &File.&Open\.\.\.<Tab>:e :browse confirm e<CR> 124 an 10.320 &File.Sp&lit-Open\.\.\.<Tab>:sp :browse sp<CR> 125 an 10.320 &File.Open\ &Tab\.\.\.<Tab>:tabnew :browse tabnew<CR> 126 an 10.325 &File.&New<Tab>:enew :confirm enew<CR> 127 an <silent> 10.330 &File.&Close<Tab>:close 128 \ :if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar> 129 \ confirm enew <Bar> 130 \ else <Bar> 131 \ confirm close <Bar> 132 \ endif<CR> 133 tln <silent> 10.330 &File.&Close<Tab>:close 134 \ <C-W>:if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar> 135 \ confirm enew <Bar> 136 \ else <Bar> 137 \ confirm close <Bar> 138 \ endif<CR> 139 an 10.335 &File.-SEP1- <Nop> 140 an <silent> 10.340 &File.&Save<Tab>:w :if expand("%") == ""<Bar>browse confirm w<Bar>else<Bar>confirm w<Bar>endif<CR> 141 an 10.350 &File.Save\ &As\.\.\.<Tab>:sav :browse confirm saveas<CR> 142 143 if 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> 147 endif 148 149 if has("printer") 150 an 10.500 &File.-SEP3- <Nop> 151 an 10.510 &File.&Print :hardcopy<CR> 152 vunmenu &File.&Print 153 vnoremenu &File.&Print :hardcopy<CR> 154 elseif has("unix") 155 an 10.500 &File.-SEP3- <Nop> 156 an 10.510 &File.&Print :w !lpr<CR> 157 vunmenu &File.&Print 158 vnoremenu &File.&Print :w !lpr<CR> 159 endif 160 an 10.600 &File.-SEP4- <Nop> 161 an 10.610 &File.Sa&ve-Exit<Tab>:wqa :confirm wqa<CR> 162 an 10.620 &File.E&xit<Tab>:qa :confirm qa<CR> 163 164 def s:SelectAll() 165 exe "norm! gg" .. (&slm == "" ? "VG" : "gH\<C-O>G") 166 enddef 167 168 " Edit menu 169 an 20.310 &Edit.&Undo<Tab>u u 170 an 20.320 &Edit.&Redo<Tab>^R <C-R> 171 an 20.330 &Edit.Rep&eat<Tab>\. . 172 173 an 20.335 &Edit.-SEP1- <Nop> 174 vnoremenu 20.340 &Edit.Cu&t<Tab>"+x "+x 175 vnoremenu 20.350 &Edit.&Copy<Tab>"+y "+y 176 cnoremenu 20.350 &Edit.&Copy<Tab>"+y <C-Y> 177 if exists(':tlmenu') 178 tlnoremenu 20.350 &Edit.&Copy<Tab>"+y <C-W>:<C-Y><CR> 179 endif 180 nnoremenu 20.360 &Edit.&Paste<Tab>"+gP "+gP 181 cnoremenu &Edit.&Paste<Tab>"+gP <C-R>+ 182 if exists(':tlmenu') 183 tlnoremenu &Edit.&Paste<Tab>"+gP <C-W>"+ 184 endif 185 exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP ' .. paste#paste_cmd['v'] 186 exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP ' .. paste#paste_cmd['i'] 187 nnoremenu 20.370 &Edit.Put\ &Before<Tab>[p [p 188 inoremenu &Edit.Put\ &Before<Tab>[p <C-O>[p 189 nnoremenu 20.380 &Edit.Put\ &After<Tab>]p ]p 190 inoremenu &Edit.Put\ &After<Tab>]p <C-O>]p 191 if has("win32") 192 vnoremenu 20.390 &Edit.&Delete<Tab>x x 193 endif 194 noremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG :<C-U>call <SID>SelectAll()<CR> 195 inoremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG <C-O>:call <SID>SelectAll()<CR> 196 cnoremenu <script> <silent> 20.400 &Edit.&Select\ All<Tab>ggVG <C-U>call <SID>SelectAll()<CR> 197 198 an 20.405 &Edit.-SEP2- <Nop> 199 if 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> 206 else 207 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>:%s 210 vnoremenu &Edit.Find\ and\ Rep&lace<Tab>:s :s/ 211 endif 212 213 an 20.425 &Edit.-SEP3- <Nop> 214 an 20.430 &Edit.Settings\ &Window :options<CR> 215 an 20.435 &Edit.Startup\ &Settings :call <SID>EditVimrc()<CR> 216 217 def s:EditVimrc() 218 var fname: string 219 if $MYVIMRC != '' 220 fname = $MYVIMRC 221 elseif has("win32") 222 if $HOME != '' 223 fname = $HOME .. "/_vimrc" 224 else 225 fname = $VIM .. "/_vimrc" 226 endif 227 elseif has("amiga") 228 fname = "s:.vimrc" 229 else 230 fname = $HOME .. "/.vimrc" 231 endif 232 fname = fnameescape(fname) 233 if &mod 234 exe "split " .. fname 235 else 236 exe "edit " .. fname 237 endif 238 enddef 239 240 def s:FixFText(): string 241 # Fix text in nameless register to be used with :promptfind. 242 return substitute(@", "[\r\n]", '\\n', 'g') 243 enddef 244 245 " Edit/Global Settings 246 an 20.440.100 &Edit.&Global\ Settings.Toggle\ Pattern\ &Highlight<Tab>:set\ hls! :set hls! hls?<CR> 247 an 20.440.110 &Edit.&Global\ Settings.Toggle\ &Ignoring\ Case<Tab>:set\ ic! :set ic! ic?<CR> 248 an 20.440.110 &Edit.&Global\ Settings.Toggle\ &Showing\ Matched\ Pairs<Tab>:set\ sm! :set sm! sm?<CR> 249 250 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 1\ :set so=1<CR> 251 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 2\ :set so=2<CR> 252 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 3\ :set so=3<CR> 253 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 4\ :set so=4<CR> 254 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 5\ :set so=5<CR> 255 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 7\ :set so=7<CR> 256 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 10\ :set so=10<CR> 257 an 20.440.120 &Edit.&Global\ Settings.&Context\ Lines.\ 100\ :set so=100<CR> 258 259 an 20.440.130.40 &Edit.&Global\ Settings.&Virtual\ Edit.Never :set ve=<CR> 260 an 20.440.130.50 &Edit.&Global\ Settings.&Virtual\ Edit.Block\ Selection :set ve=block<CR> 261 an 20.440.130.60 &Edit.&Global\ Settings.&Virtual\ Edit.Insert\ Mode :set ve=insert<CR> 262 an 20.440.130.70 &Edit.&Global\ Settings.&Virtual\ Edit.Block\ and\ Insert :set ve=block,insert<CR> 263 an 20.440.130.80 &Edit.&Global\ Settings.&Virtual\ Edit.Always :set ve=all<CR> 264 an 20.440.140 &Edit.&Global\ Settings.Toggle\ Insert\ &Mode<Tab>:set\ im! :set im!<CR> 265 an 20.440.145 &Edit.&Global\ Settings.Toggle\ Vi\ C&ompatibility<Tab>:set\ cp! :set cp!<CR> 266 an <silent> 20.440.150 &Edit.&Global\ Settings.Search\ &Path\.\.\. :call <SID>SearchP()<CR> 267 an <silent> 20.440.160 &Edit.&Global\ Settings.Ta&g\ Files\.\.\. :call <SID>TagFiles()<CR> 268 " 269 " GUI options 270 an 20.440.300 &Edit.&Global\ Settings.-SEP1- <Nop> 271 an <silent> 20.440.310 &Edit.&Global\ Settings.Toggle\ &Toolbar :call <SID>ToggleGuiOption("T")<CR> 272 an <silent> 20.440.320 &Edit.&Global\ Settings.Toggle\ &Bottom\ Scrollbar :call <SID>ToggleGuiOption("b")<CR> 273 an <silent> 20.440.330 &Edit.&Global\ Settings.Toggle\ &Left\ Scrollbar :call <SID>ToggleGuiOption("l")<CR> 274 an <silent> 20.440.340 &Edit.&Global\ Settings.Toggle\ &Right\ Scrollbar :call <SID>ToggleGuiOption("r")<CR> 275 276 def 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 endif 280 var n = inputdialog(g:menutrans_path_dialog, substitute(&path, '\\ ', ' ', 'g')) 281 if n != "" 282 &path = substitute(n, ' ', '\\ ', 'g') 283 endif 284 enddef 285 286 def 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 endif 290 var n = inputdialog(g:menutrans_tags_dialog, substitute(&tags, '\\ ', ' ', 'g')) 291 if n != "" 292 &tags = substitute(n, ' ', '\\ ', 'g') 293 endif 294 enddef 295 296 def s:ToggleGuiOption(option: string) 297 # If a:option is already set in guioptions, then we want to remove it 298 if match(&guioptions, "\\C" .. option) > -1 299 exec "set go-=" .. option 300 else 301 exec "set go+=" .. option 302 endif 303 enddef 304 305 " Edit/File Settings 306 307 " Boolean options 308 an 20.440.100 &Edit.F&ile\ Settings.Toggle\ Line\ &Numbering<Tab>:set\ nu! :set nu! nu?<CR> 309 an 20.440.105 &Edit.F&ile\ Settings.Toggle\ Relati&ve\ Line\ Numbering<Tab>:set\ rnu! :set rnu! rnu?<CR> 310 an 20.440.110 &Edit.F&ile\ Settings.Toggle\ &List\ Mode<Tab>:set\ list! :set list! list?<CR> 311 an 20.440.120 &Edit.F&ile\ Settings.Toggle\ Line\ &Wrapping<Tab>:set\ wrap! :set wrap! wrap?<CR> 312 an 20.440.130 &Edit.F&ile\ Settings.Toggle\ W&rapping\ at\ Word<Tab>:set\ lbr! :set lbr! lbr?<CR> 313 an 20.440.160 &Edit.F&ile\ Settings.Toggle\ Tab\ &Expanding<Tab>:set\ et! :set et! et?<CR> 314 an 20.440.170 &Edit.F&ile\ Settings.Toggle\ &Auto\ Indenting<Tab>:set\ ai! :set ai! ai?<CR> 315 an 20.440.180 &Edit.F&ile\ Settings.Toggle\ &C-Style\ Indenting<Tab>:set\ cin! :set cin! cin?<CR> 316 317 " other options 318 an 20.440.600 &Edit.F&ile\ Settings.-SEP2- <Nop> 319 an 20.440.610.20 &Edit.F&ile\ Settings.&Shiftwidth.2 :set sw=2 sw?<CR> 320 an 20.440.610.30 &Edit.F&ile\ Settings.&Shiftwidth.3 :set sw=3 sw?<CR> 321 an 20.440.610.40 &Edit.F&ile\ Settings.&Shiftwidth.4 :set sw=4 sw?<CR> 322 an 20.440.610.50 &Edit.F&ile\ Settings.&Shiftwidth.5 :set sw=5 sw?<CR> 323 an 20.440.610.60 &Edit.F&ile\ Settings.&Shiftwidth.6 :set sw=6 sw?<CR> 324 an 20.440.610.80 &Edit.F&ile\ Settings.&Shiftwidth.8 :set sw=8 sw?<CR> 325 326 an 20.440.620.20 &Edit.F&ile\ Settings.Soft\ &Tabstop.2 :set sts=2 sts?<CR> 327 an 20.440.620.30 &Edit.F&ile\ Settings.Soft\ &Tabstop.3 :set sts=3 sts?<CR> 328 an 20.440.620.40 &Edit.F&ile\ Settings.Soft\ &Tabstop.4 :set sts=4 sts?<CR> 329 an 20.440.620.50 &Edit.F&ile\ Settings.Soft\ &Tabstop.5 :set sts=5 sts?<CR> 330 an 20.440.620.60 &Edit.F&ile\ Settings.Soft\ &Tabstop.6 :set sts=6 sts?<CR> 331 an 20.440.620.80 &Edit.F&ile\ Settings.Soft\ &Tabstop.8 :set sts=8 sts?<CR> 332 333 an <silent> 20.440.630 &Edit.F&ile\ Settings.Te&xt\ Width\.\.\. :call <SID>TextWidth()<CR> 334 an <silent> 20.440.640 &Edit.F&ile\ Settings.&File\ Format\.\.\. :call <SID>FileFormat()<CR> 335 336 def s:TextWidth() 337 if !exists("g:menutrans_textwidth_dialog") 338 g:menutrans_textwidth_dialog = "Enter new text width (0 to disable formatting): " 339 endif 340 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 endif 347 enddef 348 349 def s:FileFormat() 350 if !exists("g:menutrans_fileformat_dialog") 351 g:menutrans_fileformat_dialog = "Select format for writing the file" 352 endif 353 if !exists("g:menutrans_fileformat_choices") 354 g:menutrans_fileformat_choices = "&Unix\n&Dos\n&Mac\n&Cancel" 355 endif 356 var def_choice: number 357 if &ff == "dos" 358 def_choice = 2 359 elseif &ff == "mac" 360 def_choice = 3 361 else 362 def_choice = 1 363 endif 364 var n = confirm(g:menutrans_fileformat_dialog, g:menutrans_fileformat_choices, def_choice, "Question") 365 if n == 1 366 set ff=unix 367 elseif n == 2 368 set ff=dos 369 elseif n == 3 370 set ff=mac 371 endif 372 enddef 373 374 let s:did_setup_color_schemes = 0 375 376 " Setup the Edit.Color Scheme submenu 377 def s:SetupColorSchemes() 378 if s:did_setup_color_schemes 379 return 380 endif 381 s:did_setup_color_schemes = 1 382 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 name 388 var names = sort(map(n, 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")'), 'i') 389 390 # define all the submenu entries 391 var idx = 100 392 for name in names 393 exe "an 20.450." .. idx .. ' &Edit.C&olor\ Scheme.' .. name .. " :colors " .. name .. "<CR>" 394 idx += 10 395 endfor 396 silent! aunmenu &Edit.Show\ C&olor\ Schemes\ in\ Menu 397 enddef 398 399 if exists("do_no_lazyload_menus") 400 call s:SetupColorSchemes() 401 else 402 an <silent> 20.450 &Edit.Show\ C&olor\ Schemes\ in\ Menu :call <SID>SetupColorSchemes()<CR> 403 endif 404 405 406 " Setup the Edit.Keymap submenu 407 if has("keymap") 408 let s:did_setup_keymaps = 0 409 410 def s:SetupKeymaps() 411 if s:did_setup_keymaps 412 return 413 endif 414 s:did_setup_keymaps = 1 415 416 var names = globpath(&runtimepath, "keymap/*.vim", 1, 1) 417 if !empty(names) 418 var idx = 100 419 an 20.460.90 &Edit.&Keymap.None :set keymap=<CR> 420 for name in names 421 # Ignore case for VMS and windows 422 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 += 10 425 endfor 426 endif 427 silent! aunmenu &Edit.Show\ &Keymaps\ in\ Menu 428 enddef 429 430 if exists("do_no_lazyload_menus") 431 call s:SetupKeymaps() 432 else 433 an <silent> 20.460 &Edit.Show\ &Keymaps\ in\ Menu :call <SID>SetupKeymaps()<CR> 434 endif 435 endif 436 437 if 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> 439 endif 440 441 " Programming menu 442 if !exists("g:ctags_command") 443 if has("vms") 444 let g:ctags_command = "mc vim:ctags *.*" 445 else 446 let g:ctags_command = "ctags -R ." 447 endif 448 endif 449 450 an 40.300 &Tools.&Jump\ to\ This\ Tag<Tab>g^] g<C-]> 451 vunmenu &Tools.&Jump\ to\ This\ Tag<Tab>g^] 452 vnoremenu &Tools.&Jump\ to\ This\ Tag<Tab>g^] g<C-]> 453 an 40.310 &Tools.Jump\ &Back<Tab>^T <C-T> 454 an 40.320 &Tools.Build\ &Tags\ File :exe "!" .. g:ctags_command<CR> 455 456 if has("folding") || has("spell") 457 an 40.330 &Tools.-SEP1- <Nop> 458 endif 459 460 " Tools.Spelling Menu 461 if 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 ]s 465 an 40.335.130 &Tools.&Spelling.To\ &Previous\ Error<Tab>[s [s 466 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_spelllang 480 exe "silent! " .. cmd 481 endfor 482 s:undo_spelllang = [] 483 484 var enc = &enc == "iso-8859-15" ? "latin1" : &enc 485 486 # Reset g:menutrans_set_lang_to when called for the EncodingChanged event. 487 if !exists("g:menutrans_set_lang_to") || encChanged 488 g:menutrans_set_lang_to = 'Set Language to' 489 endif 490 491 var found = 0 492 var _nm = '' 493 var names = globpath(&runtimepath, "spell/*." .. enc .. ".spl", 1, 1) 494 if !empty(names) 495 var n = 300 496 for f in names 497 var nm = substitute(f, '.*spell[/\\]\(..\)\.[^/\\]*\.spl', '\1', "") 498 if nm != "en" && nm !~ '/' 499 _nm = nm 500 found += 1 501 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 endif 505 n += 10 506 endfor 507 endif 508 if found == 0 509 echomsg "Could not find other spell files" 510 elseif found == 1 511 echomsg "Found spell file " .. _nm 512 else 513 echomsg "Found " .. found .. " more spell files" 514 endif 515 516 # Need to redo this when 'encoding' is changed. 517 augroup spellmenu 518 au! EncodingChanged * call SpellLang(true) 519 augroup END 520 enddef 521 endif 522 523 " Tools.Fold Menu 524 if has("folding") 525 " open close folds 526 an 40.340.110 &Tools.&Folding.&Enable/Disable\ Folds<Tab>zi zi 527 an 40.340.120 &Tools.&Folding.&View\ Cursor\ Line<Tab>zv zv 528 an 40.340.120 &Tools.&Folding.Vie&w\ Cursor\ Line\ Only<Tab>zMzx zMzx 529 inoremenu 40.340.120 &Tools.&Folding.Vie&w\ Cursor\ Line\ Only<Tab>zMzx <C-O>zM<C-O>zx 530 an 40.340.130 &Tools.&Folding.C&lose\ More\ Folds<Tab>zm zm 531 an 40.340.140 &Tools.&Folding.&Close\ All\ Folds<Tab>zM zM 532 an 40.340.150 &Tools.&Folding.O&pen\ More\ Folds<Tab>zr zr 533 an 40.340.160 &Tools.&Folding.&Open\ All\ Folds<Tab>zR zR 534 " fold method 535 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 folds 543 vnoremenu 40.340.220 &Tools.&Folding.Create\ &Fold<Tab>zf zf 544 an 40.340.230 &Tools.&Folding.&Delete\ Fold<Tab>zd zd 545 an 40.340.240 &Tools.&Folding.Delete\ &All\ Folds<Tab>zD zD 546 " moving around in folds 547 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> 556 endif " has folding 557 558 if 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\ Block 562 vnoremenu &Tools.&Diff.&Get\ Block :diffget<CR> 563 an 40.350.120 &Tools.&Diff.&Put\ Block :diffput<CR> 564 vunmenu &Tools.&Diff.&Put\ Block 565 vnoremenu &Tools.&Diff.&Put\ Block :diffput<CR> 566 endif 567 568 an 40.358 &Tools.-SEP2- <Nop> 569 an 40.360 &Tools.&Make<Tab>:make :make<CR> 570 an 40.370 &Tools.&List\ Errors<Tab>:cl :cl<CR> 571 an 40.380 &Tools.L&ist\ Messages<Tab>:cl! :cl!<CR> 572 an 40.390 &Tools.&Next\ Error<Tab>:cn :cn<CR> 573 an 40.400 &Tools.&Previous\ Error<Tab>:cp :cp<CR> 574 an 40.410 &Tools.&Older\ List<Tab>:cold :colder<CR> 575 an 40.420 &Tools.N&ewer\ List<Tab>:cnew :cnewer<CR> 576 an 40.430.50 &Tools.Error\ &Window.&Update<Tab>:cwin :cwin<CR> 577 an 40.430.60 &Tools.Error\ &Window.&Open<Tab>:copen :copen<CR> 578 an 40.430.70 &Tools.Error\ &Window.&Close<Tab>:cclose :cclose<CR> 579 580 an 40.520 &Tools.-SEP3- <Nop> 581 an <silent> 40.530 &Tools.&Convert\ to\ HEX<Tab>:%!xxd 582 \ :call <SID>XxdConv()<CR> 583 an <silent> 40.540 &Tools.Conve&rt\ Back<Tab>:%!xxd\ -r 584 \ :call <SID>XxdBack()<CR> 585 586 " Use a function to do the conversion, so that it also works with 'insertmode' 587 " set. 588 def s:XxdConv() 589 var mod = &mod 590 if has("vms") 591 :%!mc vim:xxd 592 else 593 s:XxdFind() 594 exe ':%!' .. g:xxdprogram 595 endif 596 if getline(1) =~ "^00000000:" # only if it worked 597 set ft=xxd 598 endif 599 &mod = mod 600 enddef 601 602 def s:XxdBack() 603 var mod = &mod 604 if has("vms") 605 :%!mc vim:xxd -r 606 else 607 s:XxdFind() 608 exe ':%!' .. g:xxdprogram .. ' -r' 609 endif 610 set ft= 611 if exists('#filetypedetect') && exists('#BufReadPost') 612 doautocmd filetypedetect BufReadPost 613 endif 614 &mod = mod 615 enddef 616 617 def s:XxdFind() 618 if !exists("g:xxdprogram") 619 # On the PC xxd may not be in the path but in the install directory 620 if has("win32") && !executable("xxd") 621 g:xxdprogram = $VIMRUNTIME .. (&shellslash ? '/' : '\') .. "xxd.exe" 622 if g:xxdprogram =~ ' ' 623 g:xxdprogram = '"' .. g:xxdprogram .. '"' 624 endif 625 else 626 g:xxdprogram = "xxd" 627 endif 628 endif 629 enddef 630 631 let s:did_setup_compilers = 0 632 633 " Setup the Tools.Compiler submenu 634 def s:SetupCompilers() 635 if s:did_setup_compilers 636 return 637 endif 638 s:did_setup_compilers = 1 639 640 var names = globpath(&runtimepath, "compiler/*.vim", 1, 1) 641 var idx = 100 642 for name in names 643 # Ignore case for VMS and windows 644 var cname = substitute(name, '\c.*[/\\:\]]\([^/\\:]*\)\.vim', '\1', '') 645 exe "an 30.440." .. idx .. ' &Tools.Se&t\ Compiler.' .. cname .. " :compiler " .. cname .. "<CR>" 646 idx += 10 647 endfor 648 silent! aunmenu &Tools.Show\ Compiler\ Se&ttings\ in\ Menu 649 enddef 650 651 if exists("do_no_lazyload_menus") 652 call s:SetupCompilers() 653 else 654 an <silent> 30.440 &Tools.Show\ Compiler\ Se&ttings\ in\ Menu :call <SID>SetupCompilers()<CR> 655 endif 656 657 " Load ColorScheme, Compiler Setting and Keymap menus when idle. 658 if !exists("do_no_lazyload_menus") 659 def s:SetupLazyloadMenus() 660 s:SetupColorSchemes() 661 s:SetupCompilers() 662 if has("keymap") 663 s:SetupKeymaps() 664 endif 665 enddef 666 augroup SetupLazyloadMenus 667 au! 668 au CursorHold,CursorHoldI * call <SID>SetupLazyloadMenus() | au! SetupLazyloadMenus 669 augroup END 670 endif 671 672 673 if !exists("no_buffers_menu") 674 675 " Buffer list menu -- Setup functions & actions 676 677 " wait with building the menu until after loading 'session' files. Makes 678 " startup faster. 679 let s:bmenu_wait = 1 680 681 " Dictionary of buffer number to name. This helps prevent problems where a 682 " buffer as renamed and we didn't keep track of that. 683 let s:bmenu_items = {} 684 685 if !exists("bmenu_priority") 686 let bmenu_priority = 60 687 endif 688 689 " invoked from a BufCreate or BufFilePost autocommand 690 def s:BMAdd() 691 if s:bmenu_wait == 0 692 # when adding too many buffers, redraw in short format 693 if s:bmenu_count == &menuitems && s:bmenu_short == 0 694 s:BMShow() 695 else 696 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 += 1 701 endif 702 endif 703 endif 704 enddef 705 706 " invoked from a BufDelete or BufFilePre autocommand 707 def s:BMRemove() 708 if s:bmenu_wait == 0 709 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_name 713 s:bmenu_count = s:bmenu_count - 1 714 unlet s:bmenu_items[bufnum] 715 endif 716 endif 717 enddef 718 719 " Return non-zero if buffer with number "name" / "num" is useful to add in the 720 " buffer menu. 721 def s:BMCanAdd(name: string, num: number): bool 722 # no directory or unlisted buffer 723 if isdirectory(name) || !buflisted(num) 724 return false 725 endif 726 727 # no name with control characters 728 if name =~ '[\x01-\x1f]' 729 return false 730 endif 731 732 # no special buffer, such as terminal or popup 733 var buftype = getbufvar(num, '&buftype') 734 if buftype != '' && buftype != 'nofile' && buftype != 'nowrite' 735 return false 736 endif 737 738 # only existing buffers 739 return bufexists(num) 740 enddef 741 742 " Create the buffer menu (delete an existing one first). 743 def s:BMShow() 744 s:bmenu_wait = 1 745 s:bmenu_short = 1 746 s:bmenu_count = 0 747 s:bmenu_items = {} 748 749 # Remove old menu, if it exists; keep one entry to avoid a torn off menu to 750 # disappear. Use try/catch to avoid setting v:errmsg 751 try 752 unmenu &Buffers 753 catch 754 endtry 755 exe 'noremenu ' .. g:bmenu_priority .. ".1 &Buffers.Dummy l" 756 try 757 unmenu! &Buffers 758 catch 759 endtry 760 761 # create new menu 762 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.Dummy 769 770 # figure out how many buffers there are 771 var buf = 1 772 while buf <= bufnr('$') 773 if s:BMCanAdd(bufname(buf), buf) 774 s:bmenu_count = s:bmenu_count + 1 775 endif 776 buf += 1 777 endwhile 778 if s:bmenu_count <= &menuitems 779 s:bmenu_short = 0 780 endif 781 782 # iterate through buffer list, adding each buffer to the menu: 783 buf = 1 784 while buf <= bufnr('$') 785 var name = bufname(buf) 786 if s:BMCanAdd(name, buf) 787 call s:BMFilename(name, buf) 788 endif 789 buf += 1 790 endwhile 791 s:bmenu_wait = 0 792 aug buffer_list 793 au! 794 au BufCreate,BufFilePost * call s:BMAdd() 795 au BufDelete,BufFilePre * call s:BMRemove() 796 aug END 797 enddef 798 799 def s:BMHash(name: string): number 800 # Create a sortable numeric hash of the name. This number has to be within 801 # the bounds of a signed 32-bit integer as this is what Vim GUI uses 802 # internally for the index. 803 804 # Make name all upper case, so that alphanumeric chars are between 32 and 96 805 var nm = toupper(name) 806 807 if char2nr(nm[0]) < 32 || char2nr(nm[0]) > 96 808 # We don't have an ASCII character, so just return the raw character value 809 # for first character (clamped to 2^31) and set the high bit to make it 810 # sort after other items. This means only the first character will be 811 # sorted, unfortunately. 812 return or(and(char2nr(nm), 0x7fffffff), 0x40000000) 813 endif 814 815 var sp: number 816 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') - 1 821 else 822 sp = char2nr(' ') 823 endif 824 # convert first five chars into a number for sorting by compressing each 825 # char into 5 bits (0-63), to a total of 30 bits. If any character is not 826 # 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])]) 832 enddef 833 834 def s:BMHash2(name: string): string 835 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 else 849 return '&u-z.' 850 endif 851 enddef 852 853 " Insert a buffer name into the buffer menu. 854 def s:BMFilename(name: string, num: number) 855 var munge = s:BMMunge(name, num) 856 var hash = s:BMHash(munge) 857 var cmd: string 858 if s:bmenu_short == 0 859 s:bmenu_items[num] = munge 860 cmd = 'an ' .. g:bmenu_priority .. '.' .. hash .. ' &Buffers.' .. munge 861 else 862 var menu_name = s:BMHash2(munge) .. munge 863 s:bmenu_items[num] = menu_name 864 cmd = 'an ' .. g:bmenu_priority .. '.' .. hash .. '.' .. hash .. ' &Buffers.' .. menu_name 865 endif 866 exe cmd .. ' :confirm b' .. num .. '<CR>' 867 enddef 868 869 " Truncate a long path to fit it in a menu item. 870 if !exists("g:bmenu_max_pathlen") 871 let g:bmenu_max_pathlen = 35 872 endif 873 874 def s:BMTruncName(fname: string): string 875 var name = fname 876 if g:bmenu_max_pathlen < 5 877 name = "" 878 else 879 var len = strlen(name) 880 if len > g:bmenu_max_pathlen 881 var amountl = (g:bmenu_max_pathlen / 2) - 2 882 var amountr = g:bmenu_max_pathlen - amountl - 3 883 var pattern = '^\(.\{,' .. amountl .. '}\).\{-}\(.\{,' .. amountr .. '}\)$' 884 var left = substitute(name, pattern, '\1', '') 885 var right = substitute(name, pattern, '\2', '') 886 if strlen(left) + strlen(right) < len 887 name = left .. '...' .. right 888 endif 889 endif 890 endif 891 return name 892 enddef 893 894 def s:BMMunge(fname: string, bnum: number): string 895 var name = fname 896 if name == '' 897 if !exists("g:menutrans_no_file") 898 g:menutrans_no_file = "[No Name]" 899 endif 900 name = g:menutrans_no_file 901 else 902 name = fnamemodify(name, ':p:~') 903 endif 904 # detach file name and separate it out: 905 var name2 = fnamemodify(name, ':t') 906 if bnum >= 0 907 name2 = name2 .. ' (' .. bnum .. ')' 908 endif 909 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 name 914 enddef 915 916 " When just starting Vim, load the buffer menu later 917 if has("vim_starting") 918 augroup LoadBufferMenu 919 au! VimEnter * if !exists("no_buffers_menu") | call <SID>BMShow() | endif 920 au VimEnter * au! LoadBufferMenu 921 augroup END 922 else 923 call <SID>BMShow() 924 endif 925 926 endif " !exists("no_buffers_menu") 927 928 " Window menu 929 an 70.300 &Window.&New<Tab>^Wn <C-W>n 930 an 70.310 &Window.S&plit<Tab>^Ws <C-W>s 931 an 70.320 &Window.Sp&lit\ To\ #<Tab>^W^^ <C-W><C-^> 932 an 70.330 &Window.Split\ &Vertically<Tab>^Wv <C-W>v 933 an <silent> 70.332 &Window.Split\ File\ E&xplorer :call MenuExplOpen()<CR> 934 if !exists("*MenuExplOpen") 935 def MenuExplOpen() 936 if @% == "" 937 :20vsp . 938 else 939 exe ":20vsp " .. fnameescape(expand("%:p:h")) 940 endif 941 enddef 942 endif 943 an 70.335 &Window.-SEP1- <Nop> 944 an 70.340 &Window.&Close<Tab>^Wc :confirm close<CR> 945 an 70.345 &Window.Close\ &Other(s)<Tab>^Wo :confirm only<CR> 946 an 70.350 &Window.-SEP2- <Nop> 947 an 70.355 &Window.Move\ &To.&Top<Tab>^WK <C-W>K 948 an 70.355 &Window.Move\ &To.&Bottom<Tab>^WJ <C-W>J 949 an 70.355 &Window.Move\ &To.&Left\ Side<Tab>^WH <C-W>H 950 an 70.355 &Window.Move\ &To.&Right\ Side<Tab>^WL <C-W>L 951 an 70.360 &Window.Rotate\ &Up<Tab>^WR <C-W>R 952 an 70.362 &Window.Rotate\ &Down<Tab>^Wr <C-W>r 953 an 70.365 &Window.-SEP3- <Nop> 954 an 70.370 &Window.&Equal\ Size<Tab>^W= <C-W>= 955 an 70.380 &Window.&Max\ Height<Tab>^W_ <C-W>_ 956 an 70.390 &Window.M&in\ Height<Tab>^W1_ <C-W>1_ 957 an 70.400 &Window.Max\ &Width<Tab>^W\| <C-W>\| 958 an 70.410 &Window.Min\ Widt&h<Tab>^W1\| <C-W>1\| 959 960 " The popup menu 961 an 1.10 PopUp.&Undo u 962 an 1.15 PopUp.-SEP1- <Nop> 963 vnoremenu 1.20 PopUp.Cu&t "+x 964 vnoremenu 1.30 PopUp.&Copy "+y 965 cnoremenu 1.30 PopUp.&Copy <C-Y> 966 nnoremenu 1.40 PopUp.&Paste "+gP 967 cnoremenu 1.40 PopUp.&Paste <C-R>+ 968 exe 'vnoremenu <script> 1.40 PopUp.&Paste ' .. paste#paste_cmd['v'] 969 exe 'inoremenu <script> 1.40 PopUp.&Paste ' .. paste#paste_cmd['i'] 970 vnoremenu 1.50 PopUp.&Delete x 971 an 1.55 PopUp.-SEP2- <Nop> 972 vnoremenu 1.60 PopUp.Select\ Blockwise <C-V> 973 974 nnoremenu 1.70 PopUp.Select\ &Word vaw 975 onoremenu 1.70 PopUp.Select\ &Word aw 976 vnoremenu 1.70 PopUp.Select\ &Word <C-C>vaw 977 inoremenu 1.70 PopUp.Select\ &Word <C-O>vaw 978 cnoremenu 1.70 PopUp.Select\ &Word <C-C>vaw 979 980 nnoremenu 1.73 PopUp.Select\ &Sentence vas 981 onoremenu 1.73 PopUp.Select\ &Sentence as 982 vnoremenu 1.73 PopUp.Select\ &Sentence <C-C>vas 983 inoremenu 1.73 PopUp.Select\ &Sentence <C-O>vas 984 cnoremenu 1.73 PopUp.Select\ &Sentence <C-C>vas 985 986 nnoremenu 1.77 PopUp.Select\ Pa&ragraph vap 987 onoremenu 1.77 PopUp.Select\ Pa&ragraph ap 988 vnoremenu 1.77 PopUp.Select\ Pa&ragraph <C-C>vap 989 inoremenu 1.77 PopUp.Select\ Pa&ragraph <C-O>vap 990 cnoremenu 1.77 PopUp.Select\ Pa&ragraph <C-C>vap 991 992 nnoremenu 1.80 PopUp.Select\ &Line V 993 onoremenu 1.80 PopUp.Select\ &Line <C-C>V 994 vnoremenu 1.80 PopUp.Select\ &Line <C-C>V 995 inoremenu 1.80 PopUp.Select\ &Line <C-O>V 996 cnoremenu 1.80 PopUp.Select\ &Line <C-C>V 997 998 nnoremenu 1.90 PopUp.Select\ &Block <C-V> 999 onoremenu 1.90 PopUp.Select\ &Block <C-C><C-V> 1000 vnoremenu 1.90 PopUp.Select\ &Block <C-C><C-V> 1001 inoremenu 1.90 PopUp.Select\ &Block <C-O><C-V> 1002 cnoremenu 1.90 PopUp.Select\ &Block <C-C><C-V> 1003 1004 noremenu <script> <silent> 1.100 PopUp.Select\ &All :<C-U>call <SID>SelectAll()<CR> 1005 inoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-O>:call <SID>SelectAll()<CR> 1006 cnoremenu <script> <silent> 1.100 PopUp.Select\ &All <C-U>call <SID>SelectAll()<CR> 1007 1008 if has("spell") 1009 " Spell suggestions in the popup menu. Note that this will slow down the 1010 " appearance of the menu! 1011 def s:SpellPopup() 1012 if exists("s:changeitem") && s:changeitem != '' 1013 call s:SpellDel() 1014 endif 1015 1016 # Return quickly if spell checking is not enabled. 1017 if !&spell || &spelllang == '' 1018 return 1019 endif 1020 1021 var curcol = col('.') 1022 var w: string 1023 var a: string 1024 [w, a] = spellbadword() 1025 if col('.') > curcol # don't use word after the cursor 1026 w = '' 1027 endif 1028 if w != '' 1029 if a == 'caps' 1030 s:suglist = [substitute(w, '.*', '\u&', '')] 1031 else 1032 s:suglist = spellsuggest(w, 10) 1033 endif 1034 if len(s:suglist) > 0 1035 if !exists("g:menutrans_spell_change_ARG_to") 1036 g:menutrans_spell_change_ARG_to = 'Change\ "%s"\ to' 1037 endif 1038 s:changeitem = printf(g:menutrans_spell_change_ARG_to, escape(w, ' .')) 1039 s:fromword = w 1040 var pri = 1 1041 for sug in s:suglist 1042 exe 'anoremenu 1.5.' .. pri .. ' PopUp.' .. s:changeitem .. '.' .. escape(sug, ' .') 1043 \ .. ' :call <SID>SpellReplace(' .. pri .. ')<CR>' 1044 pri += 1 1045 endfor 1046 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 endif 1050 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 endif 1056 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 endif 1061 endif 1062 call cursor(0, curcol) # put the cursor back where it was 1063 enddef 1064 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 enddef 1072 1073 def s:SpellDel() 1074 exe "aunmenu PopUp." .. s:changeitem 1075 exe "aunmenu PopUp." .. s:additem 1076 exe "aunmenu PopUp." .. s:ignoreitem 1077 aunmenu PopUp.-SpellSep- 1078 s:changeitem = '' 1079 enddef 1080 1081 augroup SpellPopupMenu 1082 au! MenuPopup * call <SID>SpellPopup() 1083 augroup END 1084 endif 1085 1086 " The GUI toolbar (for MS-Windows and GTK) 1087 if 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.Print 1095 vnoremenu ToolBar.Print :hardcopy<CR> 1096 elseif has("unix") 1097 an 1.40 ToolBar.Print :w !lpr<CR> 1098 vunmenu ToolBar.Print 1099 vnoremenu ToolBar.Print :w !lpr<CR> 1100 endif 1101 1102 an 1.45 ToolBar.-sep1- <Nop> 1103 an 1.50 ToolBar.Undo u 1104 an 1.60 ToolBar.Redo <C-R> 1105 1106 an 1.65 ToolBar.-sep2- <Nop> 1107 vnoremenu 1.70 ToolBar.Cut "+x 1108 vnoremenu 1.80 ToolBar.Copy "+y 1109 cnoremenu 1.80 ToolBar.Copy <C-Y> 1110 nnoremenu 1.90 ToolBar.Paste "+gP 1111 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.Replace 1119 vnoremenu ToolBar.Replace y:promptrepl <C-R>=<SID>FixFText()<CR><CR> 1120 an 1.110 ToolBar.FindNext n 1121 an 1.120 ToolBar.FindPrev N 1122 endif 1123 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 file 1139 if exists("*Do_toolbar_tmenu") 1140 call Do_toolbar_tmenu() 1141 else 1142 let did_toolbar_tmenu = 1 1143 tmenu ToolBar.Open Open file 1144 tmenu ToolBar.Save Save current file 1145 tmenu ToolBar.SaveAll Save all files 1146 tmenu ToolBar.Print Print 1147 tmenu ToolBar.Undo Undo 1148 tmenu ToolBar.Redo Redo 1149 tmenu ToolBar.Cut Cut to clipboard 1150 tmenu ToolBar.Copy Copy to clipboard 1151 tmenu ToolBar.Paste Paste from Clipboard 1152 if !has("gui_athena") 1153 tmenu ToolBar.Replace Find / Replace... 1154 tmenu ToolBar.FindNext Find Next 1155 tmenu ToolBar.FindPrev Find Previous 1156 endif 1157 tmenu ToolBar.LoadSesn Choose a session to load 1158 tmenu ToolBar.SaveSesn Save current session 1159 tmenu ToolBar.RunScript Choose a Vim script to run 1160 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 cursor 1163 tmenu ToolBar.Help Vim Help 1164 tmenu ToolBar.FindHelp Search Vim Help 1165 endif 1166 1167 " Select a session to load; default to current session name if present 1168 def s:LoadVimSesn() 1169 var name: string 1170 if strlen(v:this_session) > 0 1171 name = fnameescape(v:this_session) 1172 else 1173 name = "Session.vim" 1174 endif 1175 execute "browse so " .. name 1176 enddef 1177 1178 " Select a session to save; default to current session name if present 1179 def s:SaveVimSesn() 1180 if strlen(v:this_session) == 0 1181 v:this_session = "Session.vim" 1182 endif 1183 execute "browse mksession! " .. fnameescape(v:this_session) 1184 enddef 1185 1186 endif 1187 1188 endif " !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. 1192 if !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 clear 1200 else 1201 if !exists("g:syntax_on") 1202 syn manual 1203 endif 1204 set syn=ON 1205 endif 1206 enddef 1207 endif 1208 endif 1209 1210 1211 " Install the Syntax menu only when filetype.vim has been loaded or when 1212 " manual syntax highlighting is enabled. 1213 " Avoid installing the Syntax menu twice. 1214 if (exists("did_load_filetypes") || exists("syntax_on")) 1215 \ && !exists("did_install_syntax_menu") 1216 let did_install_syntax_menu = 1 1217 1218 " Skip setting up the individual syntax selection menus unless 1219 " do_syntax_sel_menu is defined (it takes quite a bit of time). 1220 if exists("do_syntax_sel_menu") 1221 runtime! synmenu.vim 1222 else 1223 an <silent> 50.10 &Syntax.&Show\ File\ Types\ in\ Menu :let do_syntax_sel_menu = 1<Bar>runtime! synmenu.vim<Bar>aunmenu &Syntax.&Show\ File\ Types\ in\ Menu<CR> 1224 an 50.195 &Syntax.-SEP1- <Nop> 1225 endif 1226 1227 an 50.210 &Syntax.&Off :syn off<CR> 1228 an 50.700 &Syntax.-SEP3- <Nop> 1229 an 50.710 &Syntax.Co&lor\ Test :sp $VIMRUNTIME/syntax/colortest.vim<Bar>so %<CR> 1230 an 50.720 &Syntax.&Highlight\ Test :runtime syntax/hitest.vim<CR> 1231 an 50.730 &Syntax.&Convert\ to\ HTML :runtime syntax/2html.vim<CR> 1232 1233 " Uncomment the next line to compile the functions early to find any mistakes 1234 " defcompile 1235 1236 endif " !exists("did_install_syntax_menu") 1237 1238 " Restore the previous value of 'cpoptions'. 1239 let &cpo = s:cpo_save 1240 unlet s:cpo_save 1241 1242 " vim: set sw=2 :