gui.txt 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  1. *gui.txt* For Vim version 9.0. Last change: 2022 Nov 17
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Vim's Graphical User Interface *gui* *GUI*
  4. 1. Starting the GUI |gui-start|
  5. 2. Scrollbars |gui-scrollbars|
  6. 3. Mouse Control |gui-mouse|
  7. 4. Making GUI Selections |gui-selections|
  8. 5. Menus |menus|
  9. 6. Font |gui-font|
  10. 7. Extras |gui-extras|
  11. 8. Shell Commands |gui-shell|
  12. Other GUI documentation:
  13. |gui_x11.txt| For specific items of the X11 GUI.
  14. |gui_w32.txt| For specific items of the Win32 GUI.
  15. ==============================================================================
  16. 1. Starting the GUI *gui-start* *E229* *E233*
  17. First you must make sure you actually have a version of Vim with the GUI code
  18. included. You can check this with the ":version" command, it says "with xxx
  19. GUI", where "xxx" is X11-Motif, Photon, GTK2, GTK3, etc., or
  20. "MS-Windows 32 bit GUI version".
  21. How to start the GUI depends on the system used. Mostly you can run the
  22. GUI version of Vim with:
  23. gvim [options] [files...]
  24. The X11 version of Vim can run both in GUI and in non-GUI mode. See
  25. |gui-x11-start|.
  26. *gui-init* *gvimrc* *.gvimrc* *_gvimrc* *$MYGVIMRC*
  27. The gvimrc file is where GUI-specific startup commands should be placed. It
  28. is always sourced after the |vimrc| file. If you have one then the $MYGVIMRC
  29. environment variable has its name.
  30. When the GUI starts up initializations are carried out, in this order:
  31. - The 'term' option is set to "builtin_gui" and terminal options are reset to
  32. their default value for the GUI |terminal-options|.
  33. - If the system menu file exists, it is sourced. The name of this file is
  34. normally "$VIMRUNTIME/menu.vim". You can check this with ":version". Also
  35. see |$VIMRUNTIME|. To skip loading the system menu include 'M' in
  36. 'guioptions'. *buffers-menu* *no_buffers_menu*
  37. The system menu file includes a "Buffers" menu. If you don't want this, set
  38. the "no_buffers_menu" variable in your .vimrc (not .gvimrc!): >
  39. :let no_buffers_menu = 1
  40. < NOTE: Switching on syntax highlighting also loads the menu file, thus
  41. disabling the Buffers menu must be done before ":syntax on".
  42. The path names are truncated to 35 characters. You can truncate them at a
  43. different length, for example 50, like this: >
  44. :let bmenu_max_pathlen = 50
  45. - If the "-U {gvimrc}" command-line option has been used when starting Vim,
  46. the {gvimrc} file will be read for initializations. The following
  47. initializations are skipped. When {gvimrc} is "NONE" no file will be read
  48. for initializations.
  49. - For Unix and MS-Windows, if the system gvimrc exists, it is sourced. The
  50. name of this file is normally "$VIM/gvimrc". You can check this with
  51. ":version". Also see |$VIM|.
  52. - The following are tried, and only the first one that exists is used:
  53. - If the GVIMINIT environment variable exists and is not empty, it is
  54. executed as an Ex command.
  55. - If the user gvimrc file exists, it is sourced. The name of this file is
  56. normally "$HOME/.gvimrc". You can check this with ":version".
  57. - For Win32, $HOME is set by Vim if needed, see |$HOME-windows|.
  58. - When a "_gvimrc" file is not found, ".gvimrc" is tried too. And vice
  59. versa.
  60. The name of the first file found is stored in $MYGVIMRC, unless it was
  61. already set.
  62. - If the 'exrc' option is set (which is NOT the default) the file ./.gvimrc
  63. is sourced, if it exists and isn't the same file as the system or user
  64. gvimrc file. If this file is not owned by you, some security restrictions
  65. apply. When ".gvimrc" is not found, "_gvimrc" is tried too. For Macintosh
  66. and DOS/Win32 "_gvimrc" is tried first.
  67. NOTE: All but the first one are not carried out if Vim was started with
  68. "-u NONE" or "-u DEFAULTS" and no "-U" argument was given, or when started
  69. with "-U NONE".
  70. All this happens AFTER the normal Vim initializations, like reading your
  71. .vimrc file. See |initialization|.
  72. But the GUI window is only opened after all the initializations have been
  73. carried out. If you want some commands to be executed just after opening the
  74. GUI window, use the |GUIEnter| autocommand event. Example: >
  75. :autocmd GUIEnter * winpos 100 50
  76. You can use the gvimrc files to set up your own customized menus (see |:menu|)
  77. and initialize other things that you may want to set up differently from the
  78. terminal version.
  79. Recommended place for your personal GUI initializations:
  80. Unix $HOME/.gvimrc or $HOME/.vim/gvimrc
  81. Win32 $HOME/_gvimrc, $HOME/vimfiles/gvimrc
  82. or $VIM/_gvimrc
  83. Amiga s:.gvimrc, home:.gvimrc, home:vimfiles:gvimrc
  84. or $VIM/.gvimrc
  85. Haiku $HOME/config/settings/vim/gvimrc
  86. The personal initialization files are searched in the order specified above
  87. and only the first one that is found is read.
  88. There are a number of options which only have meaning in the GUI version of
  89. Vim. These are 'guicursor', 'guifont', 'guipty' and 'guioptions'. They are
  90. documented in |options.txt| with all the other options.
  91. If using the Motif version of the GUI (but not for the GTK+ or
  92. Win32 version), a number of X resources are available. See |gui-resources|.
  93. Another way to set the colors for different occasions is with highlight
  94. groups. The "Normal" group is used to set the background and foreground
  95. colors. Example (which looks nice): >
  96. :highlight Normal guibg=grey90
  97. The "guibg" and "guifg" settings override the normal background and
  98. foreground settings. The other settings for the Normal highlight group are
  99. not used. Use the 'guifont' option to set the font.
  100. Also check out the 'guicursor' option, to set the colors for the cursor in
  101. various modes.
  102. Vim tries to make the window fit on the screen when it starts up. This avoids
  103. that you can't see part of it. On the X Window System this requires a bit of
  104. guesswork. You can change the height that is used for the window title and a
  105. task bar with the 'guiheadroom' option.
  106. *:winp* *:winpos* *E188*
  107. :winp[os]
  108. Display current position of the top left corner of the GUI vim
  109. window in pixels. Does not work in all versions.
  110. Also see |getwinpos()|, |getwinposx()| and |getwinposy()|.
  111. :winp[os] {X} {Y} *E466*
  112. Put the GUI vim window at the given {X} and {Y} coordinates.
  113. The coordinates should specify the position in pixels of the
  114. top left corner of the window. Does not work in all versions.
  115. Does work in an (new) xterm |xterm-color|.
  116. When the GUI window has not been opened yet, the values are
  117. remembered until the window is opened. The position is
  118. adjusted to make the window fit on the screen (if possible).
  119. *:win* *:winsize* *E465*
  120. :win[size] {width} {height}
  121. Set the window height to {width} by {height} characters.
  122. It is recommended to use `:set lines=11 columns=22` instead,
  123. since it's easy to see what the numbers mean.
  124. If you get less lines than expected, check the 'guiheadroom'
  125. option.
  126. If you are running the X Window System, you can get information about the
  127. window Vim is running in with these commands: >
  128. :!xwininfo -id $WINDOWID
  129. :!xprop -id $WINDOWID
  130. :execute '!xwininfo -id ' .. v:windowid
  131. :execute '!xprop -id ' .. v:windowid
  132. <
  133. *gui-IME* *iBus*
  134. Input methods for international characters in X that rely on the XIM
  135. framework, most notably iBus, have been known to produce undesirable results
  136. in gvim. These may include an inability to enter spaces, or long delays
  137. between typing a character and it being recognized by the application.
  138. One workaround that has been successful, for unknown reasons, is to prevent
  139. gvim from forking into the background by starting it with the |-f| argument.
  140. ==============================================================================
  141. 2. Scrollbars *gui-scrollbars*
  142. There are vertical scrollbars and a horizontal scrollbar. You may
  143. configure which ones appear with the 'guioptions' option.
  144. The interface looks like this (with ":set guioptions=mlrb"):
  145. +------------------------------+ `
  146. | File Edit Help | <- Menu bar (m) `
  147. +-+--------------------------+-+ `
  148. |^| |^| `
  149. |#| Text area. |#| `
  150. | | | | `
  151. |v|__________________________|v| `
  152. Normal status line -> |-+ File.c 5,2 +-| `
  153. between Vim windows |^|""""""""""""""""""""""""""|^| `
  154. | | | | `
  155. | | Another file buffer. | | `
  156. | | | | `
  157. |#| |#| `
  158. Left scrollbar (l) -> |#| |#| <- Right `
  159. |#| |#| scrollbar (r) `
  160. | | | | `
  161. |v| |v| `
  162. +-+--------------------------+-+ `
  163. | |< #### >| | <- Bottom `
  164. +-+--------------------------+-+ scrollbar (b) `
  165. Any of the scrollbar or menu components may be turned off by not putting the
  166. appropriate letter in the 'guioptions' string. The bottom scrollbar is
  167. only useful when 'nowrap' is set.
  168. VERTICAL SCROLLBARS *gui-vert-scroll*
  169. Each Vim window has a scrollbar next to it which may be scrolled up and down
  170. to move through the text in that buffer. The size of the scrollbar-thumb
  171. indicates the fraction of the buffer which can be seen in the window.
  172. When the scrollbar is dragged all the way down, the last line of the file
  173. will appear in the top of the window.
  174. If a window is shrunk to zero height (by the growth of another window) its
  175. scrollbar disappears. It reappears when the window is restored.
  176. If a window is vertically split, it will get a scrollbar when it is the
  177. current window and when, taking the middle of the current window and drawing a
  178. vertical line, this line goes through the window.
  179. When there are scrollbars on both sides, and the middle of the current window
  180. is on the left half, the right scrollbar column will contain scrollbars for
  181. the rightmost windows. The same happens on the other side.
  182. HORIZONTAL SCROLLBARS *gui-horiz-scroll*
  183. The horizontal scrollbar (at the bottom of the Vim GUI) may be used to
  184. scroll text sideways when the 'wrap' option is turned off. The
  185. scrollbar-thumb size is such that the text of the longest visible line may be
  186. scrolled as far as possible left and right. The cursor is moved when
  187. necessary, it must remain on a visible character (unless 'virtualedit' is
  188. set).
  189. Computing the length of the longest visible line takes quite a bit of
  190. computation, and it has to be done every time something changes. If this
  191. takes too much time or you don't like the cursor jumping to another line,
  192. include the 'h' flag in 'guioptions'. Then the scrolling is limited by the
  193. text of the current cursor line.
  194. *motif-intellimouse*
  195. If you have an Intellimouse and an X server that supports using the wheel,
  196. then you can use the wheel to scroll the text up and down in gvim. This works
  197. with XFree86 4.0 and later, and with some older versions when you add patches.
  198. See |scroll-mouse-wheel|.
  199. For older versions of XFree86 you must patch your X server. The following
  200. page has a bit of information about using the Intellimouse on Linux as well as
  201. links to the patches and X server binaries (may not have the one you need
  202. though):
  203. http://www.inria.fr/koala/colas/mouse-wheel-scroll/
  204. ==============================================================================
  205. 3. Mouse Control *gui-mouse*
  206. The mouse only works if the appropriate flag in the 'mouse' option is set.
  207. When the GUI is switched on, and 'mouse' wasn't set yet, the 'mouse' option is
  208. automatically set to "a", enabling it for all modes except for the
  209. |hit-enter| prompt. If you don't want this, a good place to change the
  210. 'mouse' option is the "gvimrc" file.
  211. Other options that are relevant:
  212. 'mousefocus' window focus follows mouse pointer |gui-mouse-focus|
  213. 'mousemodel' what mouse button does which action
  214. 'mousehide' hide mouse pointer while typing text
  215. 'mousemoveevent' enable mouse move events so that <MouseMove> can be mapped
  216. 'selectmode' whether to start Select mode or Visual mode
  217. A quick way to set these is with the ":behave" command.
  218. *:behave* *:be*
  219. :be[have] {model} Set behavior for mouse and selection. Valid
  220. arguments are:
  221. mswin MS-Windows behavior
  222. xterm Xterm behavior
  223. Using ":behave" changes these options:
  224. option mswin xterm ~
  225. 'selectmode' "mouse,key" ""
  226. 'mousemodel' "popup" "extend"
  227. 'keymodel' "startsel,stopsel" ""
  228. 'selection' "exclusive" "inclusive"
  229. In the $VIMRUNTIME directory, there is a script called |mswin.vim|, which will
  230. also map a few keys to the MS-Windows cut/copy/paste commands. This is NOT
  231. compatible, since it uses the CTRL-V, CTRL-X and CTRL-C keys. If you don't
  232. mind, use this command: >
  233. :so $VIMRUNTIME/mswin.vim
  234. For scrolling with a wheel on a mouse, see |scroll-mouse-wheel|.
  235. 3.1 Moving Cursor with Mouse *gui-mouse-move*
  236. Click the left mouse button somewhere in a text buffer where you want the
  237. cursor to go, and it does!
  238. This works in when 'mouse' contains ~
  239. Normal mode 'n' or 'a'
  240. Visual mode 'v' or 'a'
  241. Insert mode 'i' or 'a'
  242. Select mode is handled like Visual mode.
  243. You may use this with an operator such as 'd' to delete text from the current
  244. cursor position to the position you point to with the mouse. That is, you hit
  245. 'd' and then click the mouse somewhere.
  246. *gui-mouse-focus*
  247. The 'mousefocus' option can be set to make the keyboard focus follow the
  248. mouse pointer. This means that the window where the mouse pointer is, is the
  249. active window. Warning: this doesn't work very well when using a menu,
  250. because the menu command will always be applied to the top window.
  251. If you are on the ':' line (or '/' or '?'), then clicking the left or right
  252. mouse button will position the cursor on the ':' line (if 'mouse' contains
  253. 'c' or 'a').
  254. In any situation the middle mouse button may be clicked to paste the current
  255. selection.
  256. 3.2 Selection with Mouse *gui-mouse-select*
  257. The mouse can be used to start a selection. How depends on the 'mousemodel'
  258. option:
  259. 'mousemodel' is "extend": use the right mouse button
  260. 'mousemodel' is "popup": use the left mouse button, while keeping the Shift
  261. key pressed.
  262. If there was no selection yet, this starts a selection from the old cursor
  263. position to the position pointed to with the mouse. If there already is a
  264. selection then the closest end will be extended.
  265. If 'selectmode' contains "mouse", then the selection will be in Select mode.
  266. This means that typing normal text will replace the selection. See
  267. |Select-mode|. Otherwise, the selection will be in Visual mode.
  268. Double clicking may be done to make the selection word-wise, triple clicking
  269. makes it line-wise, and quadruple clicking makes it rectangular block-wise.
  270. See |gui-selections| on how the selection is used.
  271. 3.3 Other Text Selection with Mouse *gui-mouse-modeless*
  272. *modeless-selection*
  273. A different kind of selection is used when:
  274. - in Command-line mode
  275. - in the Command-line window and pointing in another window
  276. - at the |hit-enter| prompt
  277. - whenever the current mode is not in the 'mouse' option
  278. - when holding the CTRL and SHIFT keys in the GUI
  279. Since Vim continues like the selection isn't there, and there is no mode
  280. associated with the selection, this is called modeless selection. Any text in
  281. the Vim window can be selected. Select the text by pressing the left mouse
  282. button at the start, drag to the end and release. To extend the selection,
  283. use the right mouse button when 'mousemodel' is "extend", or the left mouse
  284. button with the shift key pressed when 'mousemodel' is "popup".
  285. The selection is removed when the selected text is scrolled or changed.
  286. On the command line CTRL-Y can be used to copy the selection into the
  287. clipboard. To do this from Insert mode, use CTRL-O : CTRL-Y <CR>. When
  288. 'guioptions' contains a or A (default on X11), the selection is automatically
  289. copied to the "* register.
  290. The middle mouse button can then paste the text. On non-X11 systems, you can
  291. use CTRL-R +.
  292. 3.4 Using Mouse on Status Lines *gui-mouse-status*
  293. Clicking the left or right mouse button on the status line below a Vim
  294. window makes that window the current window. This actually happens on button
  295. release (to be able to distinguish a click from a drag action).
  296. With the left mouse button a status line can be dragged up and down, thus
  297. resizing the windows above and below it. This does not change window focus.
  298. The same can be used on the vertical separator: click to give the window left
  299. of it focus, drag left and right to make windows wider and narrower.
  300. 3.5 Various Mouse Clicks *gui-mouse-various*
  301. <S-LeftMouse> Search forward for the word under the mouse click.
  302. When 'mousemodel' is "popup" this starts or extends a
  303. selection.
  304. <S-RightMouse> Search backward for the word under the mouse click.
  305. <C-LeftMouse> Jump to the tag name under the mouse click.
  306. <C-RightMouse> Jump back to position before the previous tag jump
  307. (same as "CTRL-T")
  308. 3.6 Mouse Mappings *gui-mouse-mapping*
  309. The mouse events, complete with modifiers, may be mapped. Eg: >
  310. :map <S-LeftMouse> <RightMouse>
  311. :map <S-LeftDrag> <RightDrag>
  312. :map <S-LeftRelease> <RightRelease>
  313. :map <2-S-LeftMouse> <2-RightMouse>
  314. :map <2-S-LeftDrag> <2-RightDrag>
  315. :map <2-S-LeftRelease> <2-RightRelease>
  316. :map <3-S-LeftMouse> <3-RightMouse>
  317. :map <3-S-LeftDrag> <3-RightDrag>
  318. :map <3-S-LeftRelease> <3-RightRelease>
  319. :map <4-S-LeftMouse> <4-RightMouse>
  320. :map <4-S-LeftDrag> <4-RightDrag>
  321. :map <4-S-LeftRelease> <4-RightRelease>
  322. These mappings make selection work the way it probably should in a Motif
  323. application, with shift-left mouse allowing for extending the visual area
  324. rather than the right mouse button.
  325. <MouseMove> may be mapped, but 'mousemoveevent' must be enabled to use the
  326. mapping.
  327. Mouse mapping with modifiers does not work for modeless selection.
  328. 3.7 Drag and drop *drag-n-drop*
  329. You can drag and drop one or more files into the Vim window, where they will
  330. be opened as if a |:drop| command was used. You can check if this is
  331. supported with the *drop_file* feature: `has('drop_file')`.
  332. If you hold down Shift while doing this, Vim changes to the first dropped
  333. file's directory. If you hold Ctrl Vim will always split a new window for the
  334. file. Otherwise it's only done if the current buffer has been changed.
  335. You can also drop a directory on Vim. This starts the explorer plugin for
  336. that directory (assuming it was enabled, otherwise you'll get an error
  337. message). Keep Shift pressed to change to the directory instead.
  338. If Vim happens to be editing a command line, the names of the dropped files
  339. and directories will be inserted at the cursor. This allows you to use these
  340. names with any Ex command. Special characters (space, tab, double quote and
  341. '|'; backslash on non-MS-Windows systems) will be escaped.
  342. ==============================================================================
  343. 4. Making GUI Selections *gui-selections*
  344. *quotestar*
  345. You may make selections with the mouse (see |gui-mouse-select|), or by using
  346. Vim's Visual mode (see |v|). If 'a' is present in 'guioptions', then
  347. whenever a selection is started (Visual or Select mode), or when the selection
  348. is changed, Vim becomes the owner of the windowing system's primary selection
  349. (on MS-Windows the |gui-clipboard| is used; under X11, the |x11-selection| is
  350. used - you should read whichever of these is appropriate now).
  351. *clipboard*
  352. There is a special register for storing this selection, it is the "*
  353. register. Nothing is put in here unless the information about what text is
  354. selected is about to change (e.g. with a left mouse click somewhere), or when
  355. another application wants to paste the selected text. Then the text is put
  356. in the "* register. For example, to cut a line and make it the current
  357. selection/put it on the clipboard: >
  358. "*dd
  359. Similarly, when you want to paste a selection from another application, e.g.,
  360. by clicking the middle mouse button, the selection is put in the "* register
  361. first, and then 'put' like any other register. For example, to put the
  362. selection (contents of the clipboard): >
  363. "*p
  364. When using this register under X11, also see |x11-selection|. This also
  365. explains the related "+ register.
  366. Note that when pasting text from one Vim into another separate Vim, the type
  367. of selection (character, line, or block) will also be copied. For other
  368. applications the type is always character. However, if the text gets
  369. transferred via the |x11-cut-buffer|, the selection type is ALWAYS lost.
  370. When the "unnamed" string is included in the 'clipboard' option, the unnamed
  371. register is the same as the "* register. Thus you can yank to and paste the
  372. selection without prepending "* to commands.
  373. ==============================================================================
  374. 5. Menus *menus*
  375. For an introduction see |usr_42.txt| in the user manual.
  376. 5.1 Using Menus *using-menus*
  377. Basically, menus can be used just like mappings. You can define your own
  378. menus, as many as you like.
  379. Long-time Vim users won't use menus much. But the power is in adding your own
  380. menus and menu items. They are most useful for things that you can't remember
  381. what the key sequence was.
  382. For creating menus in a different language, see |:menutrans|.
  383. If you don't want to use menus at all, see |'go-M'|.
  384. *menu.vim*
  385. The default menus are read from the file "$VIMRUNTIME/menu.vim". See
  386. |$VIMRUNTIME| for where the path comes from. You can set up your own menus.
  387. Starting off with the default set is a good idea. You can add more items, or,
  388. if you don't like the defaults at all, start with removing all menus
  389. |:unmenu-all|. You can also avoid the default menus being loaded by adding
  390. this line to your .vimrc file (NOT your .gvimrc file!): >
  391. :let did_install_default_menus = 1
  392. If you also want to avoid the Syntax menu: >
  393. :let did_install_syntax_menu = 1
  394. The first item in the Syntax menu can be used to show all available filetypes
  395. in the menu (which can take a bit of time to load). If you want to have all
  396. filetypes already present at startup, add: >
  397. :let do_syntax_sel_menu = 1
  398. The following menuitems show all available color schemes, keymaps and compiler
  399. settings:
  400. Edit > Color Scheme ~
  401. Edit > Keymap ~
  402. Tools > Set Compiler ~
  403. However, they can also take a bit of time to load, because they search all
  404. related files from the directories in 'runtimepath'. Therefore they are
  405. loaded lazily (by the |CursorHold| event), or you can also load them manually.
  406. If you want to have all these items already present at startup, add: >
  407. :let do_no_lazyload_menus = 1
  408. Note that the menu.vim is sourced when `:syntax on` or `:filetype on` is
  409. executed or after your .vimrc file is sourced. This means that the 'encoding'
  410. option and the language of messages (`:language messages`) must be set before
  411. that (if you want to change them).
  412. *console-menus*
  413. Although this documentation is in the GUI section, you can actually use menus
  414. in console mode too. You will have to load |menu.vim| explicitly then, it is
  415. not done by default. You can use the |:emenu| command and command-line
  416. completion with 'wildmenu' to access the menu entries almost like a real menu
  417. system. To do this, put these commands in your .vimrc file: >
  418. :source $VIMRUNTIME/menu.vim
  419. :set wildmenu
  420. :set cpo-=<
  421. :set wcm=<C-Z>
  422. :map <F4> :emenu <C-Z>
  423. Pressing <F4> will start the menu. You can now use the cursor keys to select
  424. a menu entry. Hit <Enter> to execute it. Hit <Esc> if you want to cancel.
  425. This does require the |+menu| feature enabled at compile time.
  426. *tear-off-menus*
  427. GTK+ 2 and Motif support Tear-off menus. These are sort of sticky menus or
  428. pop-up menus that are present all the time. If the resizing does not work
  429. correctly, this may be caused by using something like "Vim*geometry" in the
  430. defaults. Use "Vim.geometry" instead.
  431. As to GTK+ 3, tear-off menus have been deprecated since GTK+ 3.4.
  432. Accordingly, they are disabled if gvim is linked against GTK+ 3.4 or later.
  433. The Win32 GUI version emulates Motif's tear-off menus. Actually, a Motif user
  434. will spot the differences easily, but hopefully they're just as useful. You
  435. can also use the |:tearoff| command together with |hidden-menus| to create
  436. floating menus that do not appear on the main menu bar.
  437. 5.2 Creating New Menus *creating-menus*
  438. *:me* *:menu* *:noreme* *:noremenu*
  439. *E330* *E327* *E331* *E336* *E333*
  440. *E328* *E329* *E337* *E792*
  441. To create a new menu item, use the ":menu" commands. They are mostly like
  442. the ":map" set of commands (see |map-modes|), but the first argument is a menu
  443. item name, given as a path of menus and submenus with a '.' between them,
  444. e.g.: >
  445. :menu File.Save :w<CR>
  446. :inoremenu File.Save <C-O>:w<CR>
  447. :menu Edit.Big\ Changes.Delete\ All\ Spaces :%s/[ ^I]//g<CR>
  448. This last one will create a new item in the menu bar called "Edit", holding
  449. the mouse button down on this will pop up a menu containing the item
  450. "Big Changes", which is a sub-menu containing the item "Delete All Spaces",
  451. which when selected, performs the operation.
  452. To create a menu for terminal mode, use |:tlmenu| instead of |:tmenu| unlike
  453. key mapping (|:tmap|). This is because |:tmenu| is already used for defining
  454. tooltips for menus. See |terminal-typing|.
  455. Special characters in a menu name:
  456. *menu-shortcut*
  457. & The next character is the shortcut key. Make sure each
  458. shortcut key is only used once in a (sub)menu. If you want to
  459. insert a literal "&" in the menu name use "&&".
  460. *menu-text*
  461. <Tab> Separates the menu name from right-aligned text. This can be
  462. used to show the equivalent typed command. The text "<Tab>"
  463. can be used here for convenience. If you are using a real
  464. tab, don't forget to put a backslash before it!
  465. Example: >
  466. :amenu &File.&Open<Tab>:e :browse e<CR>
  467. [typed literally]
  468. With the shortcut "F" (while keeping the <Alt> key pressed), and then "O",
  469. this menu can be used. The second part is shown as "Open :e". The ":e"
  470. is right aligned, and the "O" is underlined, to indicate it is the shortcut.
  471. *:am* *:amenu* *:an* *:anoremenu*
  472. The ":amenu" command can be used to define menu entries for all modes at once,
  473. except for Terminal mode. To make the command work correctly, a character is
  474. automatically inserted for some modes:
  475. mode inserted appended ~
  476. Normal nothing nothing
  477. Visual <C-C> <C-\><C-G>
  478. Insert <C-\><C-O>
  479. Cmdline <C-C> <C-\><C-G>
  480. Op-pending <C-C> <C-\><C-G>
  481. Appending CTRL-\ CTRL-G is for going back to insert mode when 'insertmode' is
  482. set. |CTRL-\_CTRL-G|
  483. Example: >
  484. :amenu File.Next :next^M
  485. is equal to: >
  486. :nmenu File.Next :next^M
  487. :vmenu File.Next ^C:next^M^\^G
  488. :imenu File.Next ^\^O:next^M
  489. :cmenu File.Next ^C:next^M^\^G
  490. :omenu File.Next ^C:next^M^\^G
  491. Careful: In Insert mode this only works for a SINGLE Normal mode command,
  492. because of the CTRL-O. If you have two or more commands, you will need to use
  493. the ":imenu" command. For inserting text in any mode, you can use the
  494. expression register: >
  495. :amenu Insert.foobar "='foobar'<CR>P
  496. The special text <Cmd> begins a "command menu", it executes the command
  497. directly without changing modes. Where you might use ":...<CR>" you can
  498. instead use "<Cmd>...<CR>". See |<Cmd>| for more info. Example: >
  499. anoremenu File.Next <Cmd>next<CR>
  500. Note that the '<' and 'k' flags in 'cpoptions' also apply here (when
  501. included they make the <> form and raw key codes not being recognized).
  502. Note that <Esc> in Cmdline mode executes the command, like in a mapping. This
  503. is Vi compatible. Use CTRL-C to quit Cmdline mode.
  504. *:nme* *:nmenu* *:nnoreme* *:nnoremenu* *:nunme* *:nunmenu*
  505. Menu commands starting with "n" work in Normal mode. |mapmode-n|
  506. *:ome* *:omenu* *:onoreme* *:onoremenu* *:ounme* *:ounmenu*
  507. Menu commands starting with "o" work in Operator-pending mode. |mapmode-o|
  508. *:vme* *:vmenu* *:vnoreme* *:vnoremenu* *:vunme* *:vunmenu*
  509. Menu commands starting with "v" work in Visual mode. |mapmode-v|
  510. *:xme* *:xmenu* *:xnoreme* *:xnoremenu* *:xunme* *:xunmenu*
  511. Menu commands starting with "x" work in Visual and Select mode. |mapmode-x|
  512. *:sme* *:smenu* *:snoreme* *:snoremenu* *:sunme* *:sunmenu*
  513. Menu commands starting with "s" work in Select mode. |mapmode-s|
  514. *:ime* *:imenu* *:inoreme* *:inoremenu* *:iunme* *:iunmenu*
  515. Menu commands starting with "i" work in Insert mode. |mapmode-i|
  516. *:cme* *:cmenu* *:cnoreme* *:cnoremenu* *:cunme* *:cunmenu*
  517. Menu commands starting with "c" work in Cmdline mode. |mapmode-c|
  518. *:tlm* *:tlmenu* *:tln* *:tlnoremenu* *:tlu* *:tlunmenu*
  519. Menu commands starting with "tl" work in Terminal mode. |mapmode-t|
  520. *:menu-<silent>* *:menu-silent*
  521. To define a menu which will not be echoed on the command line, add
  522. "<silent>" as the first argument. Example: >
  523. :menu <silent> Settings.Ignore\ case :set ic<CR>
  524. The ":set ic" will not be echoed when using this menu. Messages from the
  525. executed command are still given though. To shut them up too, add a ":silent"
  526. in the executed command: >
  527. :menu <silent> Search.Header :exe ":silent normal /Header\r"<CR>
  528. "<silent>" may also appear just after "<special>" or "<script>".
  529. *:menu-<special>* *:menu-special*
  530. Define a menu with <> notation for special keys, even though the "<" flag
  531. may appear in 'cpoptions'. This is useful if the side effect of setting
  532. 'cpoptions' is not desired. Example: >
  533. :menu <special> Search.Header /Header<CR>
  534. "<special>" must appear as the very first argument to the ":menu" command or
  535. just after "<silent>" or "<script>".
  536. *:menu-<script>* *:menu-script*
  537. The "to" part of the menu will be inspected for mappings. If you don't want
  538. this, use the ":noremenu" command (or the similar one for a specific mode).
  539. If you do want to use script-local mappings, add "<script>" as the very first
  540. argument to the ":menu" command or just after "<silent>" or "<special>".
  541. *menu-priority*
  542. You can give a priority to a menu. Menus with a higher priority go more to
  543. the right. The priority is given as a number before the ":menu" command.
  544. Example: >
  545. :80menu Buffer.next :bn<CR>
  546. The default menus have these priorities:
  547. File 10
  548. Edit 20
  549. Tools 40
  550. Syntax 50
  551. Buffers 60
  552. Window 70
  553. Help 9999
  554. When no or zero priority is given, 500 is used.
  555. The priority for the PopUp menu is not used.
  556. The Help menu will be placed on the far right side of the menu bar on systems
  557. which support this (Motif and GTK+). For GTK+ 2 and 3, this is not done
  558. anymore because right-aligning the Help menu is now discouraged UI design.
  559. You can use a priority higher than 9999, to make it go after the Help menu,
  560. but that is non-standard and is discouraged. The highest possible priority is
  561. about 32000. The lowest is 1.
  562. *sub-menu-priority*
  563. The same mechanism can be used to position a sub-menu. The priority is then
  564. given as a dot-separated list of priorities, before the menu name: >
  565. :menu 80.500 Buffer.next :bn<CR>
  566. Giving the sub-menu priority is only needed when the item is not to be put
  567. in a normal position. For example, to put a sub-menu before the other items: >
  568. :menu 80.100 Buffer.first :brew<CR>
  569. Or to put a sub-menu after the other items, and further items with default
  570. priority will be put before it: >
  571. :menu 80.900 Buffer.last :blast<CR>
  572. When a number is missing, the default value 500 will be used: >
  573. :menu .900 myMenu.test :echo "text"<CR>
  574. The menu priority is only used when creating a new menu. When it already
  575. existed, e.g., in another mode, the priority will not change. Thus, the
  576. priority only needs to be given the first time a menu is used.
  577. An exception is the PopUp menu. There is a separate menu for each mode
  578. (Normal, Op-pending, Visual, Insert, Cmdline). The order in each of these
  579. menus can be different. This is different from menu-bar menus, which have
  580. the same order for all modes.
  581. NOTE: sub-menu priorities currently don't work for all versions of the GUI.
  582. *menu-separator* *E332*
  583. Menu items can be separated by a special item that inserts some space between
  584. items. Depending on the system this is displayed as a line or a dotted line.
  585. These items must start with a '-' and end in a '-'. The part in between is
  586. used to give it a unique name. Priorities can be used as with normal items.
  587. Example: >
  588. :menu Example.item1 :do something
  589. :menu Example.-Sep- :
  590. :menu Example.item2 :do something different
  591. Note that the separator also requires a rhs. It doesn't matter what it is,
  592. because the item will never be selected. Use a single colon to keep it
  593. simple.
  594. *gui-toolbar*
  595. The toolbar is currently available in the Win32, Motif, GTK+ (X11),
  596. and Photon GUI. It should turn up in other GUIs in due course. The
  597. default toolbar is setup in menu.vim.
  598. The display of the toolbar is controlled by the 'guioptions' letter 'T'. You
  599. can thus have menu & toolbar together, or either on its own, or neither.
  600. The appearance is controlled by the 'toolbar' option. You can choose between
  601. an image, text or both.
  602. *toolbar-icon*
  603. The toolbar is defined as a special menu called ToolBar, which only has one
  604. level. Vim interprets the items in this menu as follows:
  605. 1) If an "icon=" argument was specified, the file with this name is used.
  606. The file can either be specified with the full path or with the base name.
  607. In the last case it is searched for in the "bitmaps" directory in
  608. 'runtimepath', like in point 3. Examples: >
  609. :amenu icon=/usr/local/pixmaps/foo_icon.xpm ToolBar.Foo :echo "Foo"<CR>
  610. :amenu icon=FooIcon ToolBar.Foo :echo "Foo"<CR>
  611. < Note that in the first case the extension is included, while in the second
  612. case it is omitted.
  613. If the file cannot be opened the next points are tried.
  614. A space in the file name must be escaped with a backslash.
  615. A menu priority must come _after_ the icon argument: >
  616. :amenu icon=foo 1.42 ToolBar.Foo :echo "42!"<CR>
  617. 2) An item called 'BuiltIn##', where ## is a number, is taken as number ## of
  618. the built-in bitmaps available in Vim. Currently there are 31 numbered
  619. from 0 to 30 which cover most common editing operations |builtin-tools|. >
  620. :amenu ToolBar.BuiltIn22 :call SearchNext("back")<CR>
  621. 3) An item with another name is first searched for in the directory
  622. "bitmaps" in 'runtimepath'. If found, the bitmap file is used as the
  623. toolbar button image. Note that the exact filename is OS-specific: For
  624. example, under Win32 the command >
  625. :amenu ToolBar.Hello :echo "hello"<CR>
  626. < would find the file 'hello.bmp'. Under GTK+/X11 it is 'Hello.xpm'. With
  627. GTK+ 2 the files 'Hello.png', 'Hello.xpm' and 'Hello.bmp' are checked for
  628. existence, and the first one found would be used.
  629. For MS-Windows and GTK+ 2 the bitmap is scaled to fit the button. For
  630. MS-Windows a size of 18 by 18 pixels works best.
  631. For MS-Windows the bitmap should have 16 colors with the standard palette.
  632. The light grey pixels will be changed to the Window frame color and the
  633. dark grey pixels to the window shadow color. More colors might also work,
  634. depending on your system.
  635. 4) If the bitmap is still not found, Vim checks for a match against its list
  636. of built-in names. Each built-in button image has a name.
  637. So the command >
  638. :amenu ToolBar.Open :e
  639. < will show the built-in "open a file" button image if no open.bmp exists.
  640. All the built-in names can be seen used in menu.vim.
  641. 5) If all else fails, a blank, but functioning, button is displayed.
  642. *builtin-tools*
  643. nr Name Normal action ~
  644. 00 New open new window
  645. 01 Open browse for file to open in current window
  646. 02 Save write buffer to file
  647. 03 Undo undo last change
  648. 04 Redo redo last undone change
  649. 05 Cut delete selected text to clipboard
  650. 06 Copy copy selected text to clipboard
  651. 07 Paste paste text from clipboard
  652. 08 Print print current buffer
  653. 09 Help open a buffer on Vim's builtin help
  654. 10 Find start a search command
  655. 11 SaveAll write all modified buffers to file
  656. 12 SaveSesn write session file for current situation
  657. 13 NewSesn write new session file
  658. 14 LoadSesn load session file
  659. 15 RunScript browse for file to run as a Vim script
  660. 16 Replace prompt for substitute command
  661. 17 WinClose close current window
  662. 18 WinMax make current window use many lines
  663. 19 WinMin make current window use few lines
  664. 20 WinSplit split current window
  665. 21 Shell start a shell
  666. 22 FindPrev search again, backward
  667. 23 FindNext search again, forward
  668. 24 FindHelp prompt for word to search help for
  669. 25 Make run make and jump to first error
  670. 26 TagJump jump to tag under the cursor
  671. 27 RunCtags build tags for files in current directory
  672. 28 WinVSplit split current window vertically
  673. 29 WinMaxWidth make current window use many columns
  674. 30 WinMinWidth make current window use few columns
  675. *hidden-menus* *win32-hidden-menus*
  676. In the Win32 and GTK+ GUI, starting a menu name with ']' excludes that menu
  677. from the main menu bar. You must then use the |:popup| or |:tearoff| command
  678. to display it.
  679. *window-toolbar* *WinBar*
  680. Each window can have a local toolbar. This uses the first line of the window,
  681. thus reduces the space for the text by one line. The items in the toolbar
  682. must start with "WinBar".
  683. Only text can be used. When using Unicode, special characters can be used to
  684. make the items look like icons.
  685. If the items do not fit then the last ones cannot be used. The toolbar does
  686. not wrap.
  687. Note that Vim may be in any mode when executing these commands. The menu
  688. should be defined for Normal mode and will be executed without changing the
  689. current mode. Thus if the current window is in Visual mode and the menu
  690. command does not intentionally change the mode, Vim will remain in Visual
  691. mode. Best is to use `:nnoremenu` to avoid side effects.
  692. Example for debugger tools: >
  693. nnoremenu 1.10 WinBar.Step :Step<CR>
  694. nnoremenu 1.20 WinBar.Next :Next<CR>
  695. nnoremenu 1.30 WinBar.Finish :Finish<CR>
  696. nnoremenu 1.40 WinBar.Cont :Continue<CR>
  697. <
  698. The window toolbar uses the ToolbarLine and ToolbarButton highlight groups.
  699. When splitting the window the window toolbar is not copied to the new window.
  700. *popup-menu*
  701. In the Win32, GTK+, Motif and Photon GUI, you can define the
  702. special menu "PopUp". This is the menu that is displayed when the right mouse
  703. button is pressed, if 'mousemodel' is set to popup or popup_setpos.
  704. Example: >
  705. nnoremenu 1.40 PopUp.&Paste "+gP
  706. menu PopUp
  707. 5.3 Showing What Menus Are Mapped To *showing-menus*
  708. To see what an existing menu is mapped to, use just one argument after the
  709. menu commands (just like you would with the ":map" commands). If the menu
  710. specified is a submenu, then all menus under that hierarchy will be shown.
  711. If no argument is given after :menu at all, then ALL menu items are shown
  712. for the appropriate mode (e.g., Command-line mode for :cmenu).
  713. Special characters in the list, just before the rhs:
  714. * The menu was defined with "nore" to disallow remapping.
  715. & The menu was defined with "<script>" to allow remapping script-local
  716. mappings only.
  717. s The menu was defined with "<silent>" to avoid showing what it is
  718. mapped to when triggered.
  719. - The menu was disabled.
  720. Note that hitting <Tab> while entering a menu name after a menu command may
  721. be used to complete the name of the menu item.
  722. It is not allowed to change menus while listing them. *E1310*
  723. This doesn't normally happen, only when, for example, you would have a timer
  724. callback define a menu and the user lists menus in a way it shows
  725. |more-prompt|.
  726. 5.4 Executing Menus *execute-menus*
  727. *:em* *:emenu* *E334* *E335*
  728. :[range]em[enu] {menu} Execute {menu} from the command line.
  729. The default is to execute the Normal mode
  730. menu. If a range is specified, it executes
  731. the Visual mode menu.
  732. If used from <c-o>, it executes the
  733. insert-mode menu Eg: >
  734. :emenu File.Exit
  735. :[range]em[enu] {mode} {menu} Like above, but execute the menu for {mode}:
  736. 'n': |:nmenu| Normal mode
  737. 'v': |:vmenu| Visual mode
  738. 's': |:smenu| Select mode
  739. 'o': |:omenu| Operator-pending mode
  740. 't': |:tlmenu| Terminal mode
  741. 'i': |:imenu| Insert mode
  742. 'c': |:cmenu| Cmdline mode
  743. If the console-mode vim has been compiled with WANT_MENU defined, you can
  744. use :emenu to access useful menu items you may have got used to from GUI
  745. mode. See 'wildmenu' for an option that works well with this. See
  746. |console-menus| for an example.
  747. When using a range, if the lines match with '<,'>, then the menu is executed
  748. using the last visual selection.
  749. 5.5 Deleting Menus *delete-menus*
  750. *:unme* *:unmenu*
  751. *:aun* *:aunmenu*
  752. To delete a menu item or a whole submenu, use the unmenu commands, which are
  753. analogous to the unmap commands. Eg: >
  754. :unmenu! Edit.Paste
  755. This will remove the Paste item from the Edit menu for Insert and
  756. Command-line modes.
  757. Note that hitting <Tab> while entering a menu name after an umenu command
  758. may be used to complete the name of the menu item for the appropriate mode.
  759. To remove all menus use: *:unmenu-all* >
  760. :unmenu * " remove all menus in Normal and visual mode
  761. :unmenu! * " remove all menus in Insert and Command-line mode
  762. :aunmenu * " remove all menus in all modes, except for Terminal
  763. " mode
  764. :tlunmenu * " remove all menus in Terminal mode
  765. If you want to get rid of the menu bar: >
  766. :set guioptions-=m
  767. 5.6 Disabling Menus *disable-menus*
  768. *:menu-disable* *:menu-enable*
  769. If you do not want to remove a menu, but disable it for a moment, this can be
  770. done by adding the "enable" or "disable" keyword to a ":menu" command.
  771. Examples: >
  772. :menu disable &File.&Open\.\.\.
  773. :amenu enable *
  774. :amenu disable &Tools.*
  775. The command applies to the modes as used with all menu commands. Note that
  776. characters like "&" need to be included for translated names to be found.
  777. When the argument is "*", all menus are affected. Otherwise the given menu
  778. name and all existing submenus below it are affected.
  779. 5.7 Examples for Menus *menu-examples*
  780. Here is an example on how to add menu items with menu's! You can add a menu
  781. item for the keyword under the cursor. The register "z" is used. >
  782. :nmenu Words.Add\ Var wb"zye:menu! Words.<C-R>z <C-R>z<CR>
  783. :nmenu Words.Remove\ Var wb"zye:unmenu! Words.<C-R>z<CR>
  784. :vmenu Words.Add\ Var "zy:menu! Words.<C-R>z <C-R>z <CR>
  785. :vmenu Words.Remove\ Var "zy:unmenu! Words.<C-R>z<CR>
  786. :imenu Words.Add\ Var <Esc>wb"zye:menu! Words.<C-R>z <C-R>z<CR>a
  787. :imenu Words.Remove\ Var <Esc>wb"zye:unmenu! Words.<C-R>z<CR>a
  788. (the rhs is in <> notation, you can copy/paste this text to try out the
  789. mappings, or put these lines in your gvimrc; "<C-R>" is CTRL-R, "<CR>" is
  790. the <CR> key. |<>|)
  791. *tooltips* *menu-tips*
  792. 5.8 Tooltips & Menu tips
  793. See section |42.4| in the user manual.
  794. *:tmenu* *:tm*
  795. :tm[enu] {menupath} {rhs} Define a tip for a menu or tool. {only in
  796. X11 and Win32 GUI}
  797. :tm[enu] [menupath] List menu tips. {only in X11 and Win32 GUI}
  798. *:tunmenu* *:tu*
  799. :tu[nmenu] {menupath} Remove a tip for a menu or tool.
  800. {only in X11 and Win32 GUI}
  801. Note: To create menus for terminal mode, use |:tlmenu| instead.
  802. When a tip is defined for a menu item, it appears in the command-line area
  803. when the mouse is over that item, much like a standard Windows menu hint in
  804. the status bar. (Except when Vim is in Command-line mode, when of course
  805. nothing is displayed.)
  806. When a tip is defined for a ToolBar item, it appears as a tooltip when the
  807. mouse pauses over that button, in the usual fashion. Use the |hl-Tooltip|
  808. highlight group to change its colors.
  809. A "tip" can be defined for each menu item. For example, when defining a menu
  810. item like this: >
  811. :amenu MyMenu.Hello :echo "Hello"<CR>
  812. The tip is defined like this: >
  813. :tmenu MyMenu.Hello Displays a greeting.
  814. And delete it with: >
  815. :tunmenu MyMenu.Hello
  816. Tooltips are currently only supported for the X11 and Win32 GUI. However, they
  817. should appear for the other gui platforms in the not too distant future.
  818. The ":tmenu" command works just like other menu commands, it uses the same
  819. arguments. ":tunmenu" deletes an existing menu tip, in the same way as the
  820. other unmenu commands.
  821. If a menu item becomes invalid (i.e. its actions in all modes are deleted) Vim
  822. deletes the menu tip (and the item) for you. This means that :aunmenu deletes
  823. a menu item - you don't need to do a :tunmenu as well.
  824. 5.9 Popup Menus
  825. In the Win32 and GTK+ GUI, you can cause a menu to popup at the cursor.
  826. This behaves similarly to the PopUp menus except that any menu tree can
  827. be popped up.
  828. This command is for backwards compatibility, using it is discouraged, because
  829. it behaves in a strange way.
  830. *:popup* *:popu*
  831. :popu[p] {name} Popup the menu {name}. The menu named must
  832. have at least one subentry, but need not
  833. appear on the menu-bar (see |hidden-menus|).
  834. {only available for Win32 and GTK GUI or in
  835. the terminal}
  836. :popu[p]! {name} Like above, but use the position of the mouse
  837. pointer instead of the cursor.
  838. In the terminal this is the last known
  839. position, which is usually at the last click
  840. or release (mouse movement is irrelevant).
  841. Example: >
  842. :popup File
  843. will make the "File" menu (if there is one) appear at the text cursor (mouse
  844. pointer if ! was used). >
  845. :amenu ]Toolbar.Make :make<CR>
  846. :popup ]Toolbar
  847. This creates a popup menu that doesn't exist on the main menu-bar.
  848. Note that in the GUI the :popup command will return immediately, before a
  849. selection has been made. In the terminal the commands waits for the user to
  850. make a selection.
  851. Note that a menu that starts with ']' will not be displayed.
  852. ==============================================================================
  853. 6. Font
  854. This section describes font related options.
  855. GUIFONT *gui-font*
  856. 'guifont' is the option that tells Vim what font to use. In its simplest form
  857. the value is just one font name. It can also be a list of font names
  858. separated with commas. The first valid font is used. When no valid font can
  859. be found you will get an error message.
  860. On systems where 'guifontset' is supported (X11) and 'guifontset' is not
  861. empty, then 'guifont' is not used. See |xfontset|.
  862. Note: As to the GTK GUIs, no error is given against any invalid names, and the
  863. first element of the list is always picked up and made use of. This is
  864. because, instead of identifying a given name with a font, the GTK GUIs use it
  865. to construct a pattern and try to look up a font which best matches the
  866. pattern among available fonts, and this way, the matching never fails. An
  867. invalid name doesn't matter because a number of font properties other than
  868. name will do to get the matching done.
  869. Spaces after a comma are ignored. To include a comma in a font name precede
  870. it with a backslash. Setting an option requires an extra backslash before a
  871. space and a backslash. See also |option-backslash|. For example: >
  872. :set guifont=Screen15,\ 7x13,font\\,with\\,commas
  873. will make Vim try to use the font "Screen15" first, and if it fails it will
  874. try to use "7x13" and then "font,with,commas" instead.
  875. If none of the fonts can be loaded, Vim will keep the current setting. If an
  876. empty font list is given, Vim will try using other resource settings (for X,
  877. it will use the Vim.font resource), and finally it will try some builtin
  878. default which should always be there ("7x13" in the case of X). The font
  879. names given should be "normal" fonts. Vim will try to find the related bold
  880. and italic fonts.
  881. For Win32, GTK, Motif, Mac OS and Photon: >
  882. :set guifont=*
  883. will bring up a font requester, where you can pick the font you want.
  884. The font name depends on the GUI used. See |setting-guifont| for a way to set
  885. 'guifont' for various systems.
  886. For the GTK+ 2 and 3 GUIs, the font name looks like this: >
  887. :set guifont=Andale\ Mono\ 11
  888. That's all. XLFDs are not used. For Chinese this is reported to work well: >
  889. if has("gui_gtk2")
  890. set guifont=Bitstream\ Vera\ Sans\ Mono\ 12,Fixed\ 12
  891. set guifontwide=Microsoft\ Yahei\ 12,WenQuanYi\ Zen\ Hei\ 12
  892. endif
  893. <
  894. (Replace gui_gtk2 with gui_gtk3 for the GTK+ 3 GUI)
  895. For Mac OSX you can use something like this: >
  896. :set guifont=Monaco:h10
  897. Mono-spaced fonts *E236*
  898. Note that the fonts must be mono-spaced (all characters have the same width).
  899. An exception is GTK: all fonts are accepted, but mono-spaced fonts look best.
  900. To preview a font on X11, you might be able to use the "xfontsel" program.
  901. The "xlsfonts" program gives a list of all available fonts.
  902. For the Win32 GUI *E244* *E245*
  903. - Takes these options in the font name (use a ':' to separate the options):
  904. hXX - height is XX (points, can be floating-point)
  905. wXX - width is XX (points, can be floating-point)
  906. WXX - weight is XX (see Note on Weights below)
  907. b - bold. This is equivalent to setting the weight to 700.
  908. i - italic
  909. u - underline
  910. s - strikeout
  911. cXX - character set XX. Valid charsets are: ANSI, ARABIC, BALTIC,
  912. CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK, HANGEUL,
  913. HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS, SYMBOL, THAI,
  914. TURKISH and VIETNAMESE. Normally you would use "cDEFAULT".
  915. qXX - quality XX. Valid quality names are: PROOF, DRAFT, ANTIALIASED,
  916. NONANTIALIASED, CLEARTYPE and DEFAULT. Normally you would use
  917. "qDEFAULT".
  918. Some quality values are not supported in legacy OSs.
  919. - A '_' can be used in the place of a space, so you don't need to use
  920. backslashes to escape the spaces.
  921. Examples: >
  922. :set guifont=courier_new:h12:w5:b:cRUSSIAN
  923. :set guifont=Andale_Mono:h7.5:w4.5
  924. See also |font-sizes|.
  925. Note on Weights: Fonts often come with a variety of weights. "Normal" weights
  926. in Windows have a value of 400 and, left unspecified, this is the value that
  927. will be used when attempting to find fonts. Windows will often match fonts
  928. based on their weight with higher priority than the font name which means a
  929. Book or Medium variant of a font might be used despite specifying a Light or
  930. ExtraLight variant. If you are experiencing heavier weight substitution, then
  931. explicitly setting a lower weight value may mitigate against this unwanted
  932. substitution.
  933. GUIFONTWIDE *gui-fontwide*
  934. When not empty, 'guifontwide' specifies a comma-separated list of fonts to be
  935. used for double-width characters. The first font that can be loaded is used.
  936. Note: The size of these fonts must be exactly twice as wide as the one
  937. specified with 'guifont' and the same height. If there is a mismatch then the
  938. text will not be drawn correctly.
  939. All GUI versions but GTK+:
  940. 'guifontwide' is only used when 'encoding' is set to "utf-8" and 'guifontset'
  941. is empty or invalid.
  942. When 'guifont' is set and a valid font is found in it and 'guifontwide' is
  943. empty Vim will attempt to find a matching double-width font and set
  944. 'guifontwide' to it.
  945. GTK+ GUI only: *guifontwide_gtk*
  946. If set and valid, 'guifontwide' is always used for double width characters,
  947. even if 'encoding' is not set to "utf-8".
  948. Vim does not attempt to find an appropriate value for 'guifontwide'
  949. automatically. If 'guifontwide' is empty Pango/Xft will choose the font for
  950. characters not available in 'guifont'. Thus you do not need to set
  951. 'guifontwide' at all unless you want to override the choice made by Pango/Xft.
  952. Windows +multibyte only: *guifontwide_win_mbyte*
  953. If set and valid, 'guifontwide' is used for IME instead of 'guifont'.
  954. ==============================================================================
  955. 7. Extras *gui-extras*
  956. This section describes other features which are related to the GUI.
  957. - With the GUI, there is no wait for one second after hitting escape, because
  958. the key codes don't start with <Esc>.
  959. - Typing ^V followed by a special key in the GUI will insert "<Key>", since
  960. the internal string used is meaningless. Modifiers may also be held down to
  961. get "<Modifiers-Key>".
  962. - In the GUI, the modifiers SHIFT, CTRL, and ALT (or META) may be used within
  963. mappings of special keys and mouse events.
  964. E.g.: :map <M-LeftDrag> <LeftDrag>
  965. - In the GUI, several normal keys may have modifiers in mappings etc, these
  966. are <Space>, <Tab>, <NL>, <CR>, <Esc>.
  967. - To check in a Vim script if the GUI is being used, you can use something
  968. like this: >
  969. if has("gui_running")
  970. echo "yes, we have a GUI"
  971. else
  972. echo "Boring old console"
  973. endif
  974. < *setting-guifont*
  975. - When you use the same vimrc file on various systems, you can use something
  976. like this to set options specifically for each type of GUI: >
  977. if has("gui_running")
  978. if has("gui_gtk2")
  979. :set guifont=Luxi\ Mono\ 12
  980. elseif has("x11")
  981. " Also for GTK 1
  982. :set guifont=*-lucidatypewriter-medium-r-normal-*-*-180-*-*-m-*-*
  983. elseif has("gui_win32")
  984. :set guifont=Luxi_Mono:h12:cANSI
  985. endif
  986. endif
  987. A recommended Japanese font is MS Mincho. You can find info here:
  988. http://www.lexikan.com/mincho.htm
  989. ==============================================================================
  990. 8. Shell Commands *gui-shell*
  991. For the X11 GUI the external commands are executed inside the gvim window.
  992. See |gui-pty|.
  993. WARNING: Executing an external command from the X11 GUI will not always work.
  994. "normal" commands like "ls", "grep" and "make" mostly work fine.
  995. Commands that require an intelligent terminal like "less" and "ispell" won't
  996. work. Some may even hang and need to be killed from another terminal. So be
  997. careful!
  998. For the Win32 GUI the external commands are executed in a separate window.
  999. See |gui-shell-win32|.
  1000. vim:tw=78:sw=4:ts=8:noet:ft=help:norl: