gui.txt 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. *gui.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Nvim Graphical User Interface *gui* *GUI*
  4. Any client that supports the Nvim |ui-protocol| can be used as a UI for Nvim.
  5. And multiple UIs can connect to the same Nvim instance! The terms "UI" and
  6. "GUI" are often used interchangeably because all Nvim UI clients have the same
  7. potential capabilities; the "TUI" refers to a UI client that outputs to your
  8. terminal, whereas a "GUI" outputs directly to the OS graphics system.
  9. Except where noted, this document describes UI capabilities available to both
  10. TUI and GUI (assuming the UI supports the given feature). See |TUI| for notes
  11. specific to the terminal UI. Help tags with the "gui-" prefix refer to UI
  12. features, whereas help tags with the "ui-" prefix refer to the |ui-protocol|.
  13. ==============================================================================
  14. Third-party GUIs *third-party-guis* *vscode*
  15. Nvim provides a builtin "terminal UI" (|TUI|), but also works with many
  16. (third-party) GUIs which may provide a fresh look or extra features on top of
  17. Nvim. For example, "vscode-neovim" essentally allows you to use VSCode as
  18. a Nvim GUI.
  19. - vscode-neovim (Nvim in VSCode!) https://github.com/vscode-neovim/vscode-neovim
  20. - Firenvim (Nvim in your web browser!) https://github.com/glacambre/firenvim
  21. - Neovide https://neovide.dev/
  22. - Goneovim https://github.com/akiyosi/goneovim
  23. - Nvy https://github.com/RMichelsen/Nvy
  24. - Neovim-Qt (Qt5) https://github.com/equalsraf/neovim-qt
  25. - VimR (macOS) https://github.com/qvacua/vimr
  26. - Others https://github.com/neovim/neovim/wiki/Related-projects#gui
  27. Type |gO| to see the table of contents.
  28. ==============================================================================
  29. Starting the GUI *gui-config* *gui-start*
  30. *ginit.vim* *gui-init* *gvimrc* *$MYGVIMRC*
  31. For GUI-specific configuration Nvim provides the |UIEnter| event. This
  32. happens after other |initialization|s, or whenever a UI attaches (multiple UIs
  33. can connect to any Nvim instance).
  34. Example: this sets "g:gui" to the value of the UI's "rgb" field: >
  35. :autocmd UIEnter * let g:gui = filter(nvim_list_uis(),{k,v-> v.chan==v:event.chan})[0].rgb
  36. <
  37. *:winp* *:winpos* *E188*
  38. :winp[os]
  39. Display current position of the top left corner of the GUI vim
  40. window in pixels. Does not work in all versions.
  41. Also see |getwinpos()|, |getwinposx()| and |getwinposy()|.
  42. :winp[os] {X} {Y} *E466*
  43. Put the GUI vim window at the given {X} and {Y} coordinates.
  44. The coordinates should specify the position in pixels of the
  45. top left corner of the window.
  46. When the GUI window has not been opened yet, the values are
  47. remembered until the window is opened. The position is
  48. adjusted to make the window fit on the screen (if possible).
  49. *:wi* *:win* *:winsize* *E465*
  50. :win[size] {width} {height}
  51. Set the window height to {width} by {height} characters.
  52. Obsolete, use ":set lines=11 columns=22".
  53. ==============================================================================
  54. Using the mouse *mouse-using*
  55. *mouse-mode-table* *mouse-overview*
  56. Overview of what the mouse buttons do, when 'mousemodel' is "extend":
  57. *<S-LeftMouse>* *<A-RightMouse>* *<S-RightMouse>* *<RightDrag>*
  58. *<RightRelease>* *<LeftDrag>*
  59. Normal Mode: >
  60. event position selection change action
  61. cursor window
  62. ---------------------------------------------------------------------------
  63. <LeftMouse> yes end yes
  64. <C-LeftMouse> yes end yes "CTRL-]" (2)
  65. <S-LeftMouse> yes no change yes "*" (2)
  66. <LeftDrag> yes start or extend (1) no
  67. <LeftRelease> yes start or extend (1) no
  68. <MiddleMouse> yes if not active no put
  69. <MiddleMouse> yes if active no yank and put
  70. <RightMouse> yes start or extend yes
  71. <A-RightMouse> yes start or extend blockw. yes
  72. <S-RightMouse> yes no change yes "#" (2)
  73. <C-RightMouse> no no change no "CTRL-T"
  74. <RightDrag> yes extend no
  75. <RightRelease> yes extend no
  76. Insert or Replace Mode: >
  77. event position selection change action
  78. cursor window
  79. ---------------------------------------------------------------------------
  80. <LeftMouse> yes (cannot be active) yes
  81. <C-LeftMouse> yes (cannot be active) yes "CTRL-O^]" (2)
  82. <S-LeftMouse> yes (cannot be active) yes "CTRL-O*" (2)
  83. <LeftDrag> yes start or extend (1) no like CTRL-O (1)
  84. <LeftRelease> yes start or extend (1) no like CTRL-O (1)
  85. <MiddleMouse> no (cannot be active) no put register
  86. <RightMouse> yes start or extend yes like CTRL-O
  87. <A-RightMouse> yes start or extend blockw. yes
  88. <S-RightMouse> yes (cannot be active) yes "CTRL-O#" (2)
  89. <C-RightMouse> no (cannot be active) no "CTRL-O CTRL-T"
  90. In a help window: >
  91. event position selection change action
  92. cursor window
  93. ---------------------------------------------------------------------------
  94. <2-LeftMouse> yes (cannot be active) no "^]" (jump to help tag)
  95. When 'mousemodel' is "popup", these are different:
  96. *<A-LeftMouse>*
  97. Normal Mode: >
  98. event position selection change action
  99. cursor window
  100. ---------------------------------------------------------------------------
  101. <S-LeftMouse> yes start or extend (1) no
  102. <A-LeftMouse> yes start/extend blockw no
  103. <RightMouse> no popup menu no
  104. Insert or Replace Mode: >
  105. event position selection change action
  106. cursor window
  107. ---------------------------------------------------------------------------
  108. <S-LeftMouse> yes start or extend (1) no like CTRL-O (1)
  109. <A-LeftMouse> yes start/extend blockw no
  110. <RightMouse> no popup menu no
  111. (1) only if mouse pointer moved since press
  112. (2) only if click is in same buffer
  113. Clicking the left mouse button causes the cursor to be positioned. If the
  114. click is in another window that window is made the active window. When
  115. editing the command-line the cursor can only be positioned on the
  116. command-line. When in Insert mode Vim remains in Insert mode. If 'scrolloff'
  117. is set, and the cursor is positioned within 'scrolloff' lines from the window
  118. border, the text is scrolled.
  119. A selection can be started by pressing the left mouse button on the first
  120. character, moving the mouse to the last character, then releasing the mouse
  121. button. You will not always see the selection until you release the button,
  122. only in some versions (GUI, Win32) will the dragging be shown immediately.
  123. Note that you can make the text scroll by moving the mouse at least one
  124. character in the first/last line in the window when 'scrolloff' is non-zero.
  125. In Normal, Visual and Select mode clicking the right mouse button causes the
  126. Visual area to be extended. When 'mousemodel' is "popup", the left button has
  127. to be used while keeping the shift key pressed. When clicking in a window
  128. which is editing another buffer, the Visual or Select mode is stopped.
  129. In Normal, Visual and Select mode clicking the right mouse button with the alt
  130. key pressed causes the Visual area to become blockwise. When 'mousemodel' is
  131. "popup" the left button has to be used with the alt key. Note that this won't
  132. work on systems where the window manager consumes the mouse events when the
  133. alt key is pressed (it may move the window).
  134. *double-click* *<2-LeftMouse>* *<3-LeftMouse>* *<4-LeftMouse>*
  135. Double, triple and quadruple clicks are supported. For selecting text, extra
  136. clicks extend the selection: >
  137. click select
  138. ---------------------------------
  139. double word or % match
  140. triple line
  141. quadruple rectangular block
  142. Exception: In a :help window, double-click jumps to help for the word that is
  143. clicked on.
  144. Double-click on a word selects that word. 'iskeyword' is used to specify
  145. which characters are included in a word. Double-click on a character that has
  146. a match selects until that match (like using "v%"). If the match is an
  147. #if/#else/#endif block, the selection becomes linewise. The time for
  148. double-clicking can be set with the 'mousetime' option.
  149. Example: configure double-click to jump to the tag under the cursor: >vim
  150. :map <2-LeftMouse> :exe "tag " .. expand("<cword>")<CR>
  151. Dragging the mouse with a double-click (button-down, button-up, button-down
  152. and then drag) will result in whole words to be selected. This continues
  153. until the button is released, at which point the selection is per character
  154. again.
  155. For scrolling with the mouse see |scroll-mouse-wheel|.
  156. In Insert mode, when a selection is started, Vim goes into Normal mode
  157. temporarily. When Visual or Select mode ends, it returns to Insert mode.
  158. This is like using CTRL-O in Insert mode. Select mode is used when the
  159. 'selectmode' option contains "mouse".
  160. *X1Mouse* *X1Drag* *X1Release*
  161. *X2Mouse* *X2Drag* *X2Release*
  162. *<MiddleRelease>* *<MiddleDrag>*
  163. Mouse clicks can be mapped using these |keycodes|: >
  164. code mouse button normal action
  165. ---------------------------------------------------------------------------
  166. <LeftMouse> left pressed set cursor position
  167. <LeftDrag> left moved while pressed extend selection
  168. <LeftRelease> left released set selection end
  169. <MiddleMouse> middle pressed paste text at cursor position
  170. <MiddleDrag> middle moved while pressed -
  171. <MiddleRelease> middle released -
  172. <RightMouse> right pressed extend selection
  173. <RightDrag> right moved while pressed extend selection
  174. <RightRelease> right released set selection end
  175. <X1Mouse> X1 button pressed -
  176. <X1Drag> X1 moved while pressed -
  177. <X1Release> X1 button release -
  178. <X2Mouse> X2 button pressed -
  179. <X2Drag> X2 moved while pressed -
  180. <X2Release> X2 button release -
  181. The X1 and X2 buttons refer to the extra buttons found on some mice (e.g. the
  182. right thumb).
  183. Examples: >vim
  184. :noremap <MiddleMouse> <LeftMouse><MiddleMouse>
  185. Paste at the position of the middle mouse button click (otherwise the paste
  186. would be done at the cursor position). >vim
  187. :noremap <LeftRelease> <LeftRelease>y
  188. Immediately yank the selection, when using Visual mode.
  189. Note the use of ":noremap" instead of "map" to avoid a recursive mapping.
  190. >vim
  191. :map <X1Mouse> <C-O>
  192. :map <X2Mouse> <C-I>
  193. Map the X1 and X2 buttons to go forwards and backwards in the jump list, see
  194. |CTRL-O| and |CTRL-I|.
  195. *mouse-swap-buttons*
  196. To swap the meaning of the left and right mouse buttons: >vim
  197. :noremap <LeftMouse> <RightMouse>
  198. :noremap <LeftDrag> <RightDrag>
  199. :noremap <LeftRelease> <RightRelease>
  200. :noremap <RightMouse> <LeftMouse>
  201. :noremap <RightDrag> <LeftDrag>
  202. :noremap <RightRelease> <LeftRelease>
  203. :noremap g<LeftMouse> <C-RightMouse>
  204. :noremap g<RightMouse> <C-LeftMouse>
  205. :noremap! <LeftMouse> <RightMouse>
  206. :noremap! <LeftDrag> <RightDrag>
  207. :noremap! <LeftRelease> <RightRelease>
  208. :noremap! <RightMouse> <LeftMouse>
  209. :noremap! <RightDrag> <LeftDrag>
  210. :noremap! <RightRelease> <LeftRelease>
  211. <
  212. ==============================================================================
  213. Scrollbars *gui-scrollbars*
  214. There are vertical scrollbars and a horizontal scrollbar. You may
  215. configure which ones appear with the 'guioptions' option.
  216. The interface looks like this (with `:set guioptions=mlrb`):
  217. >
  218. +------------------------------+ `
  219. | File Edit Help | <- Menu bar (m) `
  220. +-+--------------------------+-+ `
  221. |^| |^| `
  222. |#| Text area. |#| `
  223. | | | | `
  224. |v|__________________________|v| `
  225. Normal status line -> |-+ File.c 5,2 +-| `
  226. between Vim windows |^|""""""""""""""""""""""""""|^| `
  227. | | | | `
  228. | | Another file buffer. | | `
  229. | | | | `
  230. |#| |#| `
  231. Left scrollbar (l) -> |#| |#| <- Right `
  232. |#| |#| scrollbar (r) `
  233. | | | | `
  234. |v| |v| `
  235. +-+--------------------------+-+ `
  236. | |< #### >| | <- Bottom `
  237. +-+--------------------------+-+ scrollbar (b) `
  238. <
  239. Any of the scrollbar or menu components may be turned off by not putting the
  240. appropriate letter in the 'guioptions' string. The bottom scrollbar is
  241. only useful when 'nowrap' is set.
  242. VERTICAL SCROLLBARS *gui-vert-scroll*
  243. Each Vim window has a scrollbar next to it which may be scrolled up and down
  244. to move through the text in that buffer. The size of the scrollbar-thumb
  245. indicates the fraction of the buffer which can be seen in the window.
  246. When the scrollbar is dragged all the way down, the last line of the file
  247. will appear in the top of the window.
  248. If a window is shrunk to zero height (by the growth of another window) its
  249. scrollbar disappears. It reappears when the window is restored.
  250. If a window is vertically split, it will get a scrollbar when it is the
  251. current window and when, taking the middle of the current window and drawing a
  252. vertical line, this line goes through the window.
  253. When there are scrollbars on both sides, and the middle of the current window
  254. is on the left half, the right scrollbar column will contain scrollbars for
  255. the rightmost windows. The same happens on the other side.
  256. HORIZONTAL SCROLLBARS *gui-horiz-scroll*
  257. The horizontal scrollbar (at the bottom of the Vim GUI) may be used to
  258. scroll text sideways when the 'wrap' option is turned off. The
  259. scrollbar-thumb size is such that the text of the longest visible line may be
  260. scrolled as far as possible left and right. The cursor is moved when
  261. necessary, it must remain on a visible character (unless 'virtualedit' is
  262. set).
  263. Computing the length of the longest visible line takes quite a bit of
  264. computation, and it has to be done every time something changes. If this
  265. takes too much time or you don't like the cursor jumping to another line,
  266. include the 'h' flag in 'guioptions'. Then the scrolling is limited by the
  267. text of the current cursor line.
  268. ==============================================================================
  269. Drag and drop *drag-n-drop*
  270. You can drag and drop one or more files into the Vim window, where they will
  271. be opened as if a |:drop| command was used.
  272. If you hold down Shift while doing this, Vim changes to the first dropped
  273. file's directory. If you hold Ctrl Vim will always split a new window for the
  274. file. Otherwise it's only done if the current buffer has been changed.
  275. You can also drop a directory on Vim. This starts the explorer plugin for
  276. that directory (assuming it was enabled, otherwise you'll get an error
  277. message). Keep Shift pressed to change to the directory instead.
  278. If Vim happens to be editing a command line, the names of the dropped files
  279. and directories will be inserted at the cursor. This allows you to use these
  280. names with any Ex command. Special characters (space, tab, double quote and
  281. "|"; backslash on non-MS-Windows systems) will be escaped.
  282. ==============================================================================
  283. Menus *menus*
  284. For an introduction see |usr_42.txt| in the user manual.
  285. Using Menus *using-menus*
  286. Basically, menus can be used just like mappings. You can define your own
  287. menus, as many as you like.
  288. Long-time Vim users won't use menus much. But the power is in adding your own
  289. menus and menu items. They are most useful for things that you can't remember
  290. what the key sequence was.
  291. For creating menus in a different language, see |:menutrans|.
  292. *menu.vim*
  293. The default menus are read from the file "$VIMRUNTIME/menu.vim". See
  294. |$VIMRUNTIME| for where the path comes from. You can set up your own menus.
  295. Starting off with the default set is a good idea. You can add more items, or,
  296. if you don't like the defaults at all, start with removing all menus
  297. |:unmenu-all|. You can also avoid the default menus being loaded by adding
  298. this line to your vimrc file (NOT your gvimrc file!): >
  299. :let did_install_default_menus = 1
  300. If you also want to avoid the Syntax menu: >
  301. :let did_install_syntax_menu = 1
  302. The first item in the Syntax menu can be used to show all available filetypes
  303. in the menu (which can take a bit of time to load). If you want to have all
  304. filetypes already present at startup, add: >
  305. :let do_syntax_sel_menu = 1
  306. Note that the menu.vim is sourced when `:syntax on` or `:filetype on` is
  307. executed or after your .vimrc file is sourced. This means that the 'encoding'
  308. option and the language of messages (`:language messages`) must be set before
  309. that (if you want to change them).
  310. *console-menus*
  311. Although this documentation is in the GUI section, you can actually use menus
  312. in console mode too. You will have to load |menu.vim| explicitly then, it is
  313. not done by default. You can use the |:emenu| command and command-line
  314. completion with 'wildmenu' to access the menu entries almost like a real menu
  315. system. To do this, put these commands in your vimrc file: >
  316. :source $VIMRUNTIME/menu.vim
  317. :set wildmenu
  318. :set cpo-=<
  319. :set wcm=<C-Z>
  320. :map <F4> :emenu <C-Z>
  321. Pressing <F4> will start the menu. You can now use the cursor keys to select
  322. a menu entry. Hit <Enter> to execute it. Hit <Esc> if you want to cancel.
  323. Creating New Menus *creating-menus*
  324. *:me* *:menu* *:noreme* *:noremenu*
  325. *E330* *E327* *E331* *E336* *E333*
  326. *E328* *E329* *E337* *E792*
  327. To create a new menu item, use the ":menu" commands. They are mostly like
  328. the ":map" set of commands (see |map-modes|), but the first argument is a menu
  329. item name, given as a path of menus and submenus with a '.' between them,
  330. e.g.: >
  331. :menu File.Save :w<CR>
  332. :inoremenu File.Save <C-O>:w<CR>
  333. :menu Edit.Big\ Changes.Delete\ All\ Spaces :%s/[ ^I]//g<CR>
  334. This last one will create a new item in the menu bar called "Edit", holding
  335. the mouse button down on this will pop up a menu containing the item
  336. "Big Changes", which is a sub-menu containing the item "Delete All Spaces",
  337. which when selected, performs the operation.
  338. To create a menu for terminal mode, use |:tlmenu| instead of |:tmenu| unlike
  339. key mapping (|:tmap|). This is because |:tmenu| is already used for defining
  340. tooltips for menus. See |terminal-input|.
  341. Special characters in a menu name:
  342. *menu-shortcut*
  343. - & The next character is the shortcut key. Make sure each shortcut key is
  344. only used once in a (sub)menu. If you want to insert a literal "&" in the
  345. menu name use "&&".
  346. *menu-text*
  347. - <Tab> Separates the menu name from right-aligned text. This can be used to
  348. show the equivalent typed command. The text "<Tab>" can be used here for
  349. convenience. If you are using a real tab, don't forget to put a backslash
  350. before it!
  351. Example: >
  352. :amenu &File.&Open<Tab>:e :browse e<CR>
  353. [typed literally]
  354. With the shortcut "F" (while keeping the <Alt> key pressed), and then "O",
  355. this menu can be used. The second part is shown as "Open :e". The ":e"
  356. is right aligned, and the "O" is underlined, to indicate it is the shortcut.
  357. *:am* *:amenu* *:an* *:anoremenu*
  358. The ":amenu" command can be used to define menu entries for all modes at once,
  359. except for Terminal mode. To make the command work correctly, a character is
  360. automatically inserted for some modes: >
  361. mode inserted appended
  362. Normal nothing nothing
  363. Visual <C-C> <C-\><C-G>
  364. Insert <C-\><C-O>
  365. Cmdline <C-C> <C-\><C-G>
  366. Op-pending <C-C> <C-\><C-G>
  367. <
  368. Example: >
  369. :amenu File.Next :next^M
  370. is equal to: >
  371. :nmenu File.Next :next^M
  372. :vmenu File.Next ^C:next^M^\^G
  373. :imenu File.Next ^\^O:next^M
  374. :cmenu File.Next ^C:next^M^\^G
  375. :omenu File.Next ^C:next^M^\^G
  376. Careful: In Insert mode this only works for a SINGLE Normal mode command,
  377. because of the CTRL-O. If you have two or more commands, you will need to use
  378. the ":imenu" command. For inserting text in any mode, you can use the
  379. expression register: >
  380. :amenu Insert.foobar "='foobar'<CR>P
  381. The special text <Cmd> begins a "command menu", it executes the command
  382. directly without changing modes. Where you might use ":...<CR>" you can
  383. instead use "<Cmd>...<CR>". See |<Cmd>| for more info. Example: >
  384. anoremenu File.Next <Cmd>next<CR>
  385. Note that <Esc> in Cmdline mode executes the command, like in a mapping. This
  386. is Vi compatible. Use CTRL-C to quit Cmdline mode.
  387. *:nme* *:nmenu* *:nnoreme* *:nnoremenu* *:nunme* *:nunmenu*
  388. Menu commands starting with "n" work in Normal mode. |mapmode-n|
  389. *:ome* *:omenu* *:onoreme* *:onoremenu* *:ounme* *:ounmenu*
  390. Menu commands starting with "o" work in Operator-pending mode. |mapmode-o|
  391. *:vme* *:vmenu* *:vnoreme* *:vnoremenu* *:vunme* *:vunmenu*
  392. Menu commands starting with "v" work in Visual mode. |mapmode-v|
  393. *:xme* *:xmenu* *:xnoreme* *:xnoremenu* *:xunme* *:xunmenu*
  394. Menu commands starting with "x" work in Visual and Select mode. |mapmode-x|
  395. *:sme* *:smenu* *:snoreme* *:snoremenu* *:sunme* *:sunmenu*
  396. Menu commands starting with "s" work in Select mode. |mapmode-s|
  397. *:ime* *:imenu* *:inoreme* *:inoremenu* *:iunme* *:iunmenu*
  398. Menu commands starting with "i" work in Insert mode. |mapmode-i|
  399. *:cme* *:cmenu* *:cnoreme* *:cnoremenu* *:cunme* *:cunmenu*
  400. Menu commands starting with "c" work in Cmdline mode. |mapmode-c|
  401. *:tlm* *:tlmenu* *:tln* *:tlnoremenu* *:tlu* *:tlunmenu*
  402. Menu commands starting with "tl" work in Terminal mode. |mapmode-t|
  403. *:menu-<silent>* *:menu-silent*
  404. To define a menu which will not be echoed on the command line, add
  405. "<silent>" as the first argument. Example: >
  406. :menu <silent> Settings.Ignore\ case :set ic<CR>
  407. The ":set ic" will not be echoed when using this menu. Messages from the
  408. executed command are still given though. To shut them up too, add a ":silent"
  409. in the executed command: >
  410. :menu <silent> Search.Header :exe ":silent normal /Header\r"<CR>
  411. "<silent>" may also appear just after "<script>".
  412. *:menu-<script>* *:menu-script*
  413. The "to" part of the menu will be inspected for mappings. If you don't want
  414. this, use the ":noremenu" command (or the similar one for a specific mode).
  415. If you do want to use script-local mappings, add "<script>" as the very first
  416. argument to the ":menu" command or just after "<silent>".
  417. *menu-priority*
  418. You can give a priority to a menu. Menus with a higher priority go more to
  419. the right. The priority is given as a number before the ":menu" command.
  420. Example: >
  421. :80menu Buffer.next :bn<CR>
  422. The default menus have these priorities: >
  423. File 10
  424. Edit 20
  425. Tools 40
  426. Syntax 50
  427. Buffers 60
  428. Window 70
  429. Help 9999
  430. <
  431. When no or zero priority is given, 500 is used.
  432. The priority for the PopUp menu is not used.
  433. You can use a priority higher than 9999, to make it go after the Help menu,
  434. but that is non-standard and is discouraged. The highest possible priority is
  435. about 32000. The lowest is 1.
  436. *sub-menu-priority*
  437. The same mechanism can be used to position a sub-menu. The priority is then
  438. given as a dot-separated list of priorities, before the menu name: >
  439. :menu 80.500 Buffer.next :bn<CR>
  440. Giving the sub-menu priority is only needed when the item is not to be put
  441. in a normal position. For example, to put a sub-menu before the other items: >
  442. :menu 80.100 Buffer.first :brew<CR>
  443. Or to put a sub-menu after the other items, and further items with default
  444. priority will be put before it: >
  445. :menu 80.900 Buffer.last :blast<CR>
  446. When a number is missing, the default value 500 will be used: >
  447. :menu .900 myMenu.test :echo "text"<CR>
  448. The menu priority is only used when creating a new menu. When it already
  449. existed, e.g., in another mode, the priority will not change. Thus, the
  450. priority only needs to be given the first time a menu is used.
  451. An exception is the PopUp menu. There is a separate menu for each mode
  452. (Normal, Op-pending, Visual, Insert, Cmdline). The order in each of these
  453. menus can be different. This is different from menu-bar menus, which have
  454. the same order for all modes.
  455. NOTE: sub-menu priorities currently don't work for all versions of the GUI.
  456. *menu-separator* *E332*
  457. Menu items can be separated by a special item that inserts some space between
  458. items. Depending on the system this is displayed as a line or a dotted line.
  459. These items must start with a '-' and end in a '-'. The part in between is
  460. used to give it a unique name. Priorities can be used as with normal items.
  461. Example: >
  462. :menu Example.item1 :do something
  463. :menu Example.-Sep- :
  464. :menu Example.item2 :do something different
  465. Note that the separator also requires a rhs. It doesn't matter what it is,
  466. because the item will never be selected. Use a single colon to keep it
  467. simple.
  468. *gui-toolbar*
  469. The default toolbar is setup in menu.vim. The display of the toolbar is
  470. controlled by the 'guioptions' letter 'T'. You can thus have menu & toolbar
  471. together, or either on its own, or neither. The appearance is controlled by
  472. the 'toolbar' option. You can choose between an image, text or both.
  473. *toolbar-icon*
  474. The toolbar is defined as a special menu called ToolBar, which only has one
  475. level. Vim interprets the items in this menu as follows:
  476. - 1 If an "icon=" argument was specified, the file with this name is used.
  477. The file can either be specified with the full path or with the base name.
  478. In the last case it is searched for in the "bitmaps" directory in
  479. 'runtimepath', like in point 3. Examples: >
  480. :amenu icon=/usr/local/pixmaps/foo_icon.xpm ToolBar.Foo :echo "Foo"<CR>
  481. :amenu icon=FooIcon ToolBar.Foo :echo "Foo"<CR>
  482. < Note that in the first case the extension is included, while in the second
  483. case it is omitted.
  484. If the file cannot be opened the next points are tried.
  485. A space in the file name must be escaped with a backslash.
  486. A menu priority must come _after_ the icon argument: >
  487. :amenu icon=foo 1.42 ToolBar.Foo :echo "42!"<CR>
  488. - 2 An item called 'BuiltIn##', where ## is a number, is taken as number ## of
  489. the built-in bitmaps available in Vim. Currently there are 31 numbered
  490. from 0 to 30 which cover most common editing operations |builtin-tools|. >
  491. :amenu ToolBar.BuiltIn22 :call SearchNext("back")<CR>
  492. - 3 An item with another name is first searched for in the directory
  493. "bitmaps" in 'runtimepath'. If found, the bitmap file is used as the
  494. toolbar button image. Note that the exact filename is OS-specific: For
  495. example, under Win32 the command >
  496. :amenu ToolBar.Hello :echo "hello"<CR>
  497. < would find the file 'hello.bmp'. Under X11 it is 'Hello.xpm'.
  498. For MS-Windows and the bitmap is scaled to fit the button. For
  499. MS-Windows a size of 18 by 18 pixels works best.
  500. For MS-Windows the bitmap should have 16 colors with the standard palette.
  501. The light grey pixels will be changed to the Window frame color and the
  502. dark grey pixels to the window shadow color. More colors might also work,
  503. depending on your system.
  504. - 4 If the bitmap is still not found, Vim checks for a match against its list
  505. of built-in names. Each built-in button image has a name.
  506. So the command >
  507. :amenu ToolBar.Open :e
  508. < will show the built-in "open a file" button image if no open.bmp exists.
  509. All the built-in names can be seen used in menu.vim.
  510. - 5 If all else fails, a blank, but functioning, button is displayed.
  511. *builtin-tools*
  512. >
  513. nr Name Normal action
  514. 00 New open new window
  515. 01 Open browse for file to open in current window
  516. 02 Save write buffer to file
  517. 03 Undo undo last change
  518. 04 Redo redo last undone change
  519. 05 Cut delete selected text to clipboard
  520. 06 Copy copy selected text to clipboard
  521. 07 Paste paste text from clipboard
  522. 08 Print print current buffer
  523. 09 Help open a buffer on Vim's builtin help
  524. 10 Find start a search command
  525. 11 SaveAll write all modified buffers to file
  526. 12 SaveSesn write session file for current situation
  527. 13 NewSesn write new session file
  528. 14 LoadSesn load session file
  529. 15 RunScript browse for file to run as a Vim script
  530. 16 Replace prompt for substitute command
  531. 17 WinClose close current window
  532. 18 WinMax make current window use many lines
  533. 19 WinMin make current window use few lines
  534. 20 WinSplit split current window
  535. 21 Shell start a shell
  536. 22 FindPrev search again, backward
  537. 23 FindNext search again, forward
  538. 24 FindHelp prompt for word to search help for
  539. 25 Make run make and jump to first error
  540. 26 TagJump jump to tag under the cursor
  541. 27 RunCtags build tags for files in current directory
  542. 28 WinVSplit split current window vertically
  543. 29 WinMaxWidth make current window use many columns
  544. 30 WinMinWidth make current window use few columns
  545. <
  546. *hidden-menus* *win32-hidden-menus*
  547. In the Win32 GUI, starting a menu name with ']' excludes that menu from the
  548. main menu bar. You must then use the |:popup| command to display it.
  549. When splitting the window the window toolbar is not copied to the new window.
  550. *popup-menu*
  551. You can define the special menu "PopUp". This is the menu that is displayed
  552. when the right mouse button is pressed, if 'mousemodel' is set to popup or
  553. popup_setpos.
  554. The default "PopUp" menu is: >vim
  555. anoremenu PopUp.Go\ to\ definition <Cmd>lua vim.lsp.buf.definition()<CR>
  556. amenu PopUp.Open\ in\ web\ browser gx
  557. anoremenu PopUp.Inspect <Cmd>Inspect<CR>
  558. anoremenu PopUp.-1- <Nop>
  559. vnoremenu PopUp.Cut "+x
  560. vnoremenu PopUp.Copy "+y
  561. anoremenu PopUp.Paste "+gP
  562. vnoremenu PopUp.Paste "+P
  563. vnoremenu PopUp.Delete "_x
  564. nnoremenu PopUp.Select\ All ggVG
  565. vnoremenu PopUp.Select\ All gg0oG$
  566. inoremenu PopUp.Select\ All <C-Home><C-O>VG
  567. anoremenu PopUp.-2- <Nop>
  568. anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR>
  569. <
  570. Showing What Menus Are Mapped To *showing-menus*
  571. To see what an existing menu is mapped to, use just one argument after the
  572. menu commands (just like you would with the ":map" commands). If the menu
  573. specified is a submenu, then all menus under that hierarchy will be shown.
  574. If no argument is given after :menu at all, then ALL menu items are shown
  575. for the appropriate mode (e.g., Command-line mode for :cmenu).
  576. Special characters in the list, just before the rhs:
  577. • * Menu was defined with "nore" to disallow remapping.
  578. • & Menu was defined with "<script>" to allow remapping script-local mappings.
  579. • s Menu was defined with "<silent>" to avoid showing what it is mapped to
  580. when triggered.
  581. • - Menu was disabled.
  582. Note that hitting <Tab> while entering a menu name after a menu command may
  583. be used to complete the name of the menu item.
  584. Executing Menus *execute-menus*
  585. *:em* *:emenu* *E334* *E335*
  586. :[range]em[enu] {menu} Execute {menu} from the command line.
  587. The default is to execute the Normal mode
  588. menu. If a range is specified, it executes
  589. the Visual mode menu.
  590. If used from <c-o>, it executes the
  591. insert-mode menu Eg: >
  592. :emenu File.Exit
  593. :[range]em[enu] {mode} {menu} Like above, but execute the menu for {mode}:
  594. - 'n': |:nmenu| Normal mode
  595. - 'v': |:vmenu| Visual mode
  596. - 's': |:smenu| Select mode
  597. - 'o': |:omenu| Operator-pending mode
  598. - 't': |:tlmenu| Terminal mode
  599. - 'i': |:imenu| Insert mode
  600. - 'c': |:cmenu| Cmdline mode
  601. You can use :emenu to access useful menu items you may have got used to from
  602. GUI mode. See 'wildmenu' for an option that works well with this. See
  603. |console-menus| for an example.
  604. When using a range, if the lines match with '<,'>, then the menu is executed
  605. using the last visual selection.
  606. Deleting Menus *delete-menus*
  607. *:unme* *:unmenu*
  608. *:aun* *:aunmenu*
  609. To delete a menu item or a whole submenu, use the unmenu commands, which are
  610. analogous to the unmap commands. Eg: >
  611. :unmenu! Edit.Paste
  612. This will remove the Paste item from the Edit menu for Insert and
  613. Command-line modes.
  614. Note that hitting <Tab> while entering a menu name after an umenu command
  615. may be used to complete the name of the menu item for the appropriate mode.
  616. To remove all menus use: *:unmenu-all* >
  617. :unmenu * " remove all menus in Normal and visual mode
  618. :unmenu! * " remove all menus in Insert and Command-line mode
  619. :aunmenu * " remove all menus in all modes, except for Terminal
  620. " mode
  621. :tlunmenu * " remove all menus in Terminal mode
  622. If you want to get rid of the menu bar: >
  623. :set guioptions-=m
  624. Disabling Menus *disable-menus*
  625. *:menu-disable* *:menu-enable*
  626. If you do not want to remove a menu, but disable it for a moment, this can be
  627. done by adding the "enable" or "disable" keyword to a ":menu" command.
  628. Examples: >
  629. :menu disable &File.&Open\.\.\.
  630. :amenu enable *
  631. :amenu disable &Tools.*
  632. The command applies to the modes as used with all menu commands. Note that
  633. characters like "&" need to be included for translated names to be found.
  634. When the argument is "*", all menus are affected. Otherwise the given menu
  635. name and all existing submenus below it are affected.
  636. Examples for Menus *menu-examples*
  637. Here is an example on how to add menu items with menus! You can add a menu
  638. item for the keyword under the cursor. The register "z" is used. >
  639. :nmenu Words.Add\ Var wb"zye:menu! Words.<C-R>z <C-R>z<CR>
  640. :nmenu Words.Remove\ Var wb"zye:unmenu! Words.<C-R>z<CR>
  641. :vmenu Words.Add\ Var "zy:menu! Words.<C-R>z <C-R>z <CR>
  642. :vmenu Words.Remove\ Var "zy:unmenu! Words.<C-R>z<CR>
  643. :imenu Words.Add\ Var <Esc>wb"zye:menu! Words.<C-R>z <C-R>z<CR>a
  644. :imenu Words.Remove\ Var <Esc>wb"zye:unmenu! Words.<C-R>z<CR>a
  645. (the rhs is in <> notation, you can copy/paste this text to try out the
  646. mappings, or put these lines in your gvimrc; "<C-R>" is CTRL-R, "<CR>" is
  647. the <CR> key. |<>|)
  648. *tooltips* *menu-tips*
  649. Tooltips & Menu tips
  650. See section |42.4| in the user manual.
  651. *:tmenu*
  652. :tm[enu] {menupath} {rhs} Define a tip for a menu or tool. (only in
  653. X11 and Win32 GUI)
  654. :tm[enu] [menupath] List menu tips. (only in X11 and Win32 GUI)
  655. *:tunmenu*
  656. :tu[nmenu] {menupath} Remove a tip for a menu or tool.
  657. (only in X11 and Win32 GUI)
  658. Note: To create menus for terminal mode, use |:tlmenu| instead.
  659. When a tip is defined for a menu item, it appears in the command-line area
  660. when the mouse is over that item, much like a standard Windows menu hint in
  661. the status bar. (Except when Vim is in Command-line mode, when of course
  662. nothing is displayed.)
  663. When a tip is defined for a ToolBar item, it appears as a tooltip when the
  664. mouse pauses over that button, in the usual fashion. Use the |hl-Tooltip|
  665. highlight group to change its colors.
  666. A "tip" can be defined for each menu item. For example, when defining a menu
  667. item like this: >
  668. :amenu MyMenu.Hello :echo "Hello"<CR>
  669. The tip is defined like this: >
  670. :tmenu MyMenu.Hello Displays a greeting.
  671. And delete it with: >
  672. :tunmenu MyMenu.Hello
  673. Tooltips are currently only supported for the X11 and Win32 GUI. However, they
  674. should appear for the other gui platforms in the not too distant future.
  675. The ":tmenu" command works just like other menu commands, it uses the same
  676. arguments. ":tunmenu" deletes an existing menu tip, in the same way as the
  677. other unmenu commands.
  678. If a menu item becomes invalid (i.e. its actions in all modes are deleted) Vim
  679. deletes the menu tip (and the item) for you. This means that :aunmenu deletes
  680. a menu item - you don't need to do a :tunmenu as well.
  681. 5.9 Popup Menus
  682. You can cause a menu to popup at the cursor. This behaves similarly to the
  683. PopUp menus except that any menu tree can be popped up.
  684. *:popup* *:popu*
  685. :popu[p] {name} Popup the menu {name}. The menu named must
  686. have at least one subentry, but need not
  687. appear on the menu-bar (see |hidden-menus|).
  688. :popu[p]! {name} Like above, but use the position of the mouse
  689. pointer instead of the cursor.
  690. Example: >
  691. :popup File
  692. will make the "File" menu (if there is one) appear at the text cursor (mouse
  693. pointer if ! was used). >
  694. :amenu ]Toolbar.Make :make<CR>
  695. :popup ]Toolbar
  696. This creates a popup menu that doesn't exist on the main menu-bar.
  697. Note that a menu that starts with ']' will not be displayed.
  698. vim:tw=78:sw=4:ts=8:et:ft=help:norl: