menu.vim 39 KB

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