menu.vim 40 KB

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