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