1 *gui.txt* For Vim version 5.8. Last change: 2000 Jun 22
4 VIM REFERENCE MANUAL by Bram Moolenaar
7 Vim's Graphical User Interface *gui* *GUI*
9 1. Starting the GUI |gui-start|
10 2. Scrollbars |gui-scrollbars|
11 3. Mouse Control |gui-mouse|
12 4. Making GUI Selections |gui-selections|
14 6. Extras |gui-extras|
15 7. Shell Commands |gui-shell|
17 Other GUI documentation:
18 |gui_x11.txt| For specific items of the X11 GUI.
19 |gui_w32.txt| For specific items of the Win32 GUI.
21 {Vi does not have any of these commands}
23 ==============================================================================
24 1. Starting the GUI *gui-start*
26 First you must make sure you actually have a version of Vim with the GUI code
27 included. You can check this with the ":version" command, it should include
28 "+GUI_Athena", "+GUI_BeOS", "+GUI_GTK", "+GUI_Motif" or "MS-Windows ... bit
31 How to start the GUI depends on the system used. Mostly you can can run the
32 GUI version of Vim with:
33 gvim [options] [files...]
35 The X11 version of Vim can run both in GUI and in non-GUI mode. See
38 *gui-init* *gvimrc* *.gvimrc* *_gvimrc*
39 When the GUI starts up initializations are carried out, in this order:
40 - The termcap options are reset to their default value for the GUI.
41 - If the system menu file exists, it is sourced. The name of this file is
42 normally "$VIMRUNTIME/menu.vim". You can check this with ":version". Also
43 see |$VIMRUNTIME|. To skip loading the system menu include 'M' in
44 'guioptions'. *buffers-menu* *no_buffers_menu*
45 The system menu file includes a "Buffers" menu. If you don't want this, set
46 the "no_buffers_menu" variable in your .vimrc (not .gvimrc!):
47 > :let no_buffers_menu = 1
48 NOTE: Switching on syntax highlighting also loads the menu file, thus
49 disabling the buffer menu must be done before ":syntax on".
50 - If the "-U {gvimrc}" command-line option has been used when starting Vim,
51 the {gvimrc} file will be read for initializations. The following
52 initializations are skipped.
53 - For Unix, if the system gvimrc exists, it is sourced. The name of this file
54 is normally "$VIM/gvimrc". You can check this with ":version". Also see
56 - The following are tried, and only the first one that exists is used:
57 - If the GVIMINIT environment variable exists and is not empty, it is
58 executed as an Ex command.
59 - If the user gvimrc file exists, it is sourced. The name of this file is
60 normally "$HOME/.gvimrc". You can check this with ":version".
61 - For Win32, when $HOME is not set, "$VIM\_gvimrc" is used.
62 - When a "_gvimrc" file is not found, ".gvimrc" is tried too. And vice
64 - If the 'exrc' option is set (which is NOT the default) the file ./.gvimrc
65 is sourced, if it exists and isn't the same file as the system or user
66 gvimrc file. If this file is not owned by you, some security restrictions
67 apply. When ".gvimrc" is not found, "_gvimrc" is tried too. For Macintosh
68 and DOS/Win32 "_gvimrc" is tried first.
70 NOTE: All but the first one are not carried out if Vim was started with
71 "-u NONE" and no "-U" argument was given, or when started with "-U NONE".
73 All this happens AFTER the normal Vim initializations, like reading your
74 .vimrc file. See |initialization|.
75 But the GUI window is only opened after all the initializations have been
76 carried out. If you want some commands to be executed just after opening the
77 GUI window, use the |GUIEnter| autocommand event. Example:
78 > autocommand GUIEnter * winpos 100 50
80 You can use the gvimrc files to set up your own customized menus (see |:menu|)
81 and initialise other things that you may want to set up differently from the
84 Recommended place for your personal GUI initializations:
86 OS/2 $HOME/.gvimrc or $VIM/.gvimrc
87 MS-DOS and Win32 $HOME/_gvimrc or $VIM/_gvimrc
88 Amiga s:.gvimrc or $VIM/.gvimrc
90 There are a number of options which only have meaning in the GUI version of
91 Vim. These are 'guicursor', 'guifont', 'guipty' and 'guioptions'. They are
92 documented in |options.txt| with all the other options.
94 If using the Motif or Athena version of the GUI (but not for the GTK+ or Win32
95 version), a number of X resources are available. See |gui-resources|.
97 Another way to set the colors for different occasions is with highlight
98 groups. The "Normal" group is used to set the background and foreground
99 colors. Example (which looks nice):
101 > :highlight Normal guibg=grey90
103 The "guibg" and "guifg" settings override the normal background and
104 foreground settings. The other settings for the Normal highlight group are
105 not used. Use the 'guifont' option to set the font.
107 Also check out the 'guicursor' option, to set the colors for the cursor in
110 Vim tries to make the window fit on the screen when it starts up. This avoids
111 that you can't see part of it. On X windows this requires a bit of guesswork.
112 You can change the height that is used for the window title and a task bar
113 with the 'guiheadroom' option.
117 Display current position of the top left corner of the GUI vim
118 window in pixels. Does not work in all versions.
121 Put the GUI vim window at the given {X} and {Y} coordinates.
122 The coordinates should specify the position in pixels of the
123 top left corner of the window. Does not work in all versions.
124 Does work in an (new) xterm |xterm-color|.
127 :win[size] {width} {height}
128 Set the window height to {width} by {height} characters.
129 Obsolete, use ":set lines=" and ":set columns=".
132 ==============================================================================
133 2. Scrollbars *gui-scrollbars*
135 There are vertical scrollbars and a horizontal scrollbars. You may
136 configure which ones appear with the 'guioptions' option.
138 The interface looks like this (with ":set guioptions=mlrb"):
140 +------------------------------+
141 | File Edit Help | <- Menu bar (m)
142 +-+--------------------------+-+
146 |v|__________________________|v|
147 Normal status line -> |-+ File.c 5,2 +-|
148 between Vim windows |^|""""""""""""""""""""""""""|^|
150 | | Another file buffer. | |
153 Left scrollbar (l) -> |#| |#| <- Right
154 |#| |#| scrollbar (r)
157 +-+--------------------------+-+
158 | |< #### >| | <- Bottom
159 +-+--------------------------+-+ scrollbar (b)
161 Any of the scrollbar or menu components may be turned off by not putting the
162 appropriate letter in the 'guioptions' string. The bottom scrollbar is
163 only useful when 'nowrap' is set.
166 Vertical Scrollbars *gui-vert-scroll*
168 Each Vim window has a scrollbar next to it which may be scrolled up and down
169 to move through the text in that buffer. The size of the scrollbar-thumb
170 indicates the fraction of the buffer which can be seen in the window.
171 When the scrollbar is dragged all the way down, the last line of the file
172 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.
177 Horizontal Scrollbars *gui-horiz-scroll*
179 The horizontal scrollbar (at the bottom of the Vim GUI) may be used to
180 scroll text sideways when the 'wrap' option is turned off. The
181 scrollbar-thumb size is such that the text of the current cursor line may be
182 scrolled as far as possible left and right.
184 *athena-intellimouse*
185 If you have an Intellimouse and are running Linux and have the proper
186 patches in your X server to use the wheel, then you can use the wheel to
187 scroll the text up and down in gvim. At the moment, it only works with the
190 In order to use this you must have a patched X server. The following page has
191 a bit of information about using the Intellimouse on Linux as well as links to
192 the patches and X server binaries (may not have the one you need though):
193 http://www.inria.fr/koala/colas/mouse-wheel-scroll/
195 To use the wheel, put the cursor in the scrollbar area and move the wheel up
196 or down. This will scroll the text one line up or down. If you hold down the
197 shift key, it will scroll a page at a time.
199 ==============================================================================
200 3. Mouse Control *gui-mouse*
202 The mouse only works if the appropriate flag in the 'mouse' option is set.
203 When the GUI is switched on, and 'mouse' wasn't set yet, the 'mouse' option is
204 automatically set to "a", enabling it for all modes except for the
205 |hit-return| prompt. If you don't want this, a good place to change the
206 'mouse' option is the "gvimrc" file.
208 Other options that are relevant:
209 'mousefocus' window focus follows mouse pointer |gui-mouse-focus|
210 'mousemodel' what mouse button does which action
211 'mousehide' hide mouse pointer while typing text
212 'selectmode' whether to start Select mode or Visual mode
214 A quick way to set these is with the ":behave" command.
216 :be[have] {model} Set behavior for mouse and selection. Valid
218 mswin MS-Windows behavior
221 Using ":behave" changes these options:
223 'selectmode' "mouse,key" ""
224 'mousemodel' "popup" "extend"
225 'keymodel' "startsel,stopsel" ""
226 'selection' "exclusive" "inclusive"
228 In the $VIMRUNTIME directory, there is a script called "mswin.vim", which will
229 also map a few keys to the MS-Windows cut/copy/paste commands. This is NOT
230 compatible, since it uses the CTRL-V, CTRL-X and CTRL-C keys. If you don't
231 mind, use this command:
232 > :so $VIMRUNTIME/mswin.vim
234 For scrolling with a wheel on a mouse, see |scroll-mouse-wheel|.
237 3.1 Moving Cursor with Mouse *gui-mouse-move*
239 Click the left mouse button somewhere in a text buffer where you want the
240 cursor to go, and it does!
241 This works in when 'mouse contains ~
242 Normal mode 'n' or 'a'
243 Visual mode 'v' or 'a'
244 Insert mode 'i' or 'a'
246 Select mode is handled like Visual mode.
248 You may use this with an operator such as 'd' to delete text from the current
249 cursor position to the position you point to with the mouse. That is, you hit
250 'd' and then click the mouse somewhere.
253 The 'mousefocus' option can be set to make the keyboard focus follow the
254 mouse pointer. This means that the window where the mouse pointer is, is the
255 active window. Warning: this doesn't work very well when using a menu,
256 because the menu command will always be applied to the top window.
258 If you are on the ':' line (or '/' or '?'), then clicking the left or right
259 mouse button will position the cursor on the ':' line (if 'mouse' contains
262 In any situation the middle mouse button may be clicked to paste the current
266 3.2 Selection with Mouse *gui-mouse-select*
268 The mouse can be used to start a selection. How depends on the 'mousemodel'
270 'mousemodel' is "extend": use the right mouse button
271 'mousemodel' is "popup": use the left mouse button, while keeping the Shift
274 If there was no selection yet, this starts a selection from the old cursor
275 position to the position pointed to with the mouse. If there already is a
276 selection then the closest end will be extended.
278 If 'selectmode' contains "mouse", then the selection will be in Select mode.
279 This means that typing normal text will replace the selection. See
280 |Select-mode|. Otherwise, the selection will be in Visual mode.
282 Double clicking may be done to make the selection word-wise, triple clicking
283 makes it line-wise, and quadruple clicking makes it rectangular block-wise.
285 See |gui-selections| on how the selection is used.
288 3.3 Other Text Selection with Mouse *gui-mouse-modeless*
290 When in Command-line mode, at the |hit-return| prompt or whenever the current
291 mode is not in the 'mouse' option, a different kind of selection is used.
292 Since Vim continues like the selection isn't there, and there is no mode
293 associated with the selection, this is called modeless selection. Any text in
294 the Vim window can be selected. Select the text by pressing the left mouse
295 button at the start, drag to the end and release. To extend the selection,
296 use the right mouse button when 'mousemodel' is "extend", or the left mouse
297 button with the shift key pressed when 'mousemodel' is "popup".
298 The middle mouse button pasts the text.
301 3.4 Using Mouse on Status Lines *gui-mouse-status*
303 Clicking the left or right mouse button on the status line below a Vim
304 window makes that window the current window. The mouse may then be dragged
305 up and down to move the status line, thus resizing the windows above and
309 3.5 Various Mouse Clicks *gui-mouse-various*
311 <S-LeftMouse> Search forward for the word under the mouse click.
312 When 'mousemodel' is "popup" this starts or extends a
314 <S-RightMouse> Search backward for the word under the mouse click.
315 <C-LeftMouse> Jump to the tag name under the mouse click.
316 <C-RightMouse> Jump back to position before the previous tag jump
320 3.6 Mouse Mappings *gui-mouse-mapping*
322 The mouse events, complete with modifiers, may be mapped. Eg:
323 > :map <S-LeftMouse> <RightMouse>
324 > :map <S-LeftDrag> <RightDrag>
325 > :map <S-LeftRelease> <RightRelease>
326 > :map <2-S-LeftMouse> <2-RightMouse>
327 > :map <2-S-LeftDrag> <2-RightDrag>
328 > :map <2-S-LeftRelease> <2-RightRelease>
329 > :map <3-S-LeftMouse> <3-RightMouse>
330 > :map <3-S-LeftDrag> <3-RightDrag>
331 > :map <3-S-LeftRelease> <3-RightRelease>
332 > :map <4-S-LeftMouse> <4-RightMouse>
333 > :map <4-S-LeftDrag> <4-RightDrag>
334 > :map <4-S-LeftRelease> <4-RightRelease>
335 These mappings make selection work the way it probably should in a Motif
336 application, with shift-left mouse allowing for extending the visual area
337 rather than the right mouse button.
339 Mouse mapping with modifiers does not work for modeless selection.
341 ==============================================================================
342 4. Making GUI Selections *gui-selections*
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).
351 There is a special register for storing this selection, it is the "*
352 register. Nothing is put in here unless the information about what text is
353 selected is about to change (eg with a left mouse click somewhere), or when
354 another application wants to paste the selected text. Then the text is put
355 in the "* register. For example, to cut a line and make it the current
356 selection/put it on the clipboard:
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):
365 Note that when pasting text from one Vim into another separate Vim, the type
366 of selection (character, line, or block) will also be copied. For other
367 applications the type is always character.
369 When the "unnamed" string is included in the 'clipboard' option, the unnamed
370 register is the same as the "* register. Thus you can yank to and paste the
371 selection without prepending "* to commands.
373 ==============================================================================
376 5.1 Using Menus *using-menus*
378 Basically, menus can be used just like mappings. You can define you own
379 menus, as many as you like. There is a default set of menus, so that you
380 don't have to start from scratch. Long-time Vim users won't use menus much.
381 But the power is in adding your own menus and menu items. They are most
382 useful for things that you can't remember what the key sequence was.
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
395 The contents of the buffer menu can be controlled by setting the variables
396 bufmenu_fullpath and bufmenu_maxlen. The former specifies full path of files
397 to be used in the menu if set to 1. The latter specifies the maximum length of
398 the path in the menu label. If the path is longer, path elements other than the
399 first and last are removed. Then trailing and leading characters are removed
400 from these if necessary. Last all path elements are removed. These variables
401 must be set in .vimrc or similar, since .gvimrc is executed after menu.vim.
402 Default values are bufmenu_fullpath=0 and bufmenu_maxlen=50.
405 Although this documentation is in the GUI section, you can actually use menus
406 in console mode too. You will have to load |menu.vim| explicitly then, it is
407 not done by default. You can use the |:emenu| command and command-line
408 completion with 'wildmenu' to access the menu entries almost like a real menu
409 system. To do this, put these commands in your .vimrc file:
410 > :source $VIMRUNTIME/menu.vim
414 > :map <F4> :emenu <C-Z>
415 Pressing <F4> will start the menu. You can now use the cursor keys to select
416 a menu entry. Hit <Return> to execute it. Hit <Esc> if you want to cancel.
417 This does require the |+menu| feature enabled at compile time.
420 GTK+ and Motif support Tear-off menus. These are sort of sticky menus or
421 pop-up menus that are present all the time. If the resizing does not work
422 correctly, this may be caused by using something like "Vim*geometry" in de
423 defaults. Use "Vim.geometry" instead.
425 The Win32 GUI version emulates Motif's tear-off menus. Actually, a Motif user
426 will spot the differences easily, but hopefully they're just as useful. You
427 can also use the |:tearoff| command together with |win32-hidden-menus| to
428 create floating menus that do not appear on the main menu bar.
431 5.2 Creating New Menus *creating-menus*
433 *:me* *:menu* *:noreme* *:noremenu*
434 *:am* *:amenu* *:an* *:anoremenu*
435 *:nme* *:nmenu* *:nnoreme* *:nnoremenu*
436 *:ome* *:omenu* *:onoreme* *:onoremenu*
437 *:vme* *:vmenu* *:vnoreme* *:vnoremenu*
438 *:ime* *:imenu* *:inoreme* *:inoremenu*
439 *:cme* *:cmenu* *:cnoreme* *:cnoremenu*
440 To create a new menu item, use the ":menu" commands. They are exactly like
441 the ":map" set of commands but the first argument is a menu item name, given
442 as a path of menus and submenus with a '.' between them. eg:
443 > :menu File.Save :w<CR>
444 > :inoremenu File.Save <C-O>:w<CR>
445 > :menu Edit.Big\ Changes.Delete\ All\ Spaces :%s/[ ^I]//g<CR>
447 This last one will create a new item in the menu bar called "Edit", holding
448 the mouse button down on this will pop up a menu containing the item
449 "Big Changes", which is a sub-menu containing the item "Delete All Spaces",
450 which when selected, performs the operation.
452 Special characters in a menu name:
453 & The next character is the shortcut key. Make sure each
454 shortcut key is only used once in a (sub)menu.
455 <Tab> Separates the menu name from right-aligned text. This can be
456 used to show the equivalent typed command. The text "<Tab>"
457 can be used here for convenience. If you are using a real
458 Tab, don't forget to put a backslash before it!
460 > :amenu &File.&Open<Tab>:e :browse e<CR>
462 With the shortcut "F" (while keeping the <Alt> key pressed), and then "O",
463 this menu can be used. The second part is shown as "Open :e". The ":e"
464 is right aligned, and the "O" is underlined, to indicate it is the shortcut.
466 The ":amenu" command can be used to define menu entries for all modes at once.
467 To make the command work correctly, a character is automatically inserted for
477 > :amenu File.Exit :qa!^M
479 > :nmenu File.Exit :qa!^M
480 > :vmenu File.Exit ^[:qa!^M
481 > :imenu File.Exit ^O:qa!^M
482 > :cmenu File.Exit ^C:qa!^M
483 > :omenu File.Exit ^[:qa!^M
485 Careful: In Insert mode this only works for a SINGLE Normal mode command,
486 because of the CTRL-O. If you have two or more commands, you will need to use
487 the ":imenu" command. For inserting text in any mode, you can use the
489 > :amenu Insert.foobar "='foobar'<CR>P
491 Note that the '<' and 'k' flags in 'cpoptions' also apply here (when
492 included they make the <> form and raw key codes not being recognized).
494 Note that <Esc> in Cmdline mode executes the command, like in a mapping. This
495 is Vi compatible. Use CTRL-C to quit Cmdline mode.
498 You can give a priority to a menu. Menus with a higher priority go more to
499 the right. The priority is given as a number before the ":menu" command.
501 > :80menu Buffer.next :bn<CR>
503 The default menus have these priorities:
512 When no or zero priority is given, 500 is used.
513 The priority for the PopUp menu is not used.
515 You can use a priority higher than 9999, to make it go after the Help menu,
516 but that is non-standard and is discouraged. The highest possible priority is
517 about 32000. The lowest is 1.
520 The same mechanism can be used to position a sub-menu. The priority is then
521 given as a dot-separated list of priorities, before the menu name:
522 > :menu 80.500 Buffer.next :bn<CR>
523 Giving the sub-menu priority is only needed when the item is not to be put
524 in a normal position. For example, to put a sub-menu before the other items:
525 > :menu 80.100 Buffer.first :brew<CR>
526 Or to put a sub-menu after the other items, and further items with default
527 priority will be put before it:
528 > :menu 80.900 Buffer.last :blast<CR>
529 When a number is missing, the default value 500 will be used:
530 > :menu .900 myMenu.test :echo "text"<CR>
531 The menu priority is only used when creating a new menu. When it already
532 existed, e.g., in another mode, the priority will not change. Thus, the
533 priority only needs to be given the first time a menu is used.
534 An exception is the PopUp menu. There is a separate menu for each mode
535 (Normal, Op-pending, Visual, Insert, Cmdline). The order in each of these
536 menus can be different. This is different from menu-bar menus, which have
537 the same order for all modes.
538 NOTE: sub-menu priorities currently don't work for all versions of the GUI.
541 Currently, the toolbar is only available in the Win32 and GTK+ (X11) GUI. It
542 should turn up in other GUIs in due course. Sample toolbar definitions are
543 given in menu.vim. The display of the toolbar is controlled by the
544 'guioptions' letter 'T'. You can thus have menu & toolbar together, or either
545 on its own, or neither.
547 The toolbar is defined as a special menu called ToolBar, which only has one
548 level. Vim interprets the items in this menu as follows:
549 1) An item called 'BuiltIn##', where ## is a number, is taken as number ## of
550 the built-in bitmaps available in Vim. Currently there are 28, numbered
551 from 0 to 27, which cover most common editing operations |builtin-tools|.
552 2) An item with another name is first searched for in the directory
553 $VIM/bitmaps. If found, the bitmap file is used as the toolbar button
554 image. Note that the exact filename is OS-specific: For example, under
556 > :amenu ToolBar.Hello :echo "hello"<CR>
557 would search for the file 'hello.bmp'. Under GTK+/X11 it is 'Hello.xpm'.
558 Loading a custom bitmap is only supported on W95, NT4, and GTK+. The
559 bitmap is scaled to fit the button in Win32, but not GTK+. For GTK+, the
560 size of the default pixmaps used is 20 by 20 pixels.
561 3) If the bitmap is not found in $VIM/bitmaps, Vim checks for a match against
562 its list of built-in names. Each built-in button image has a name.
564 > :amenu ToolBar.Open :e
565 will show the built in "open a file" button image if no open.bmp exists.
566 All the built-in names can be seen used in menu.vim.
567 4) If all else fails, a blank, but functioning, button is displayed.
570 nr Name Normal action ~
571 00 New open new window
572 01 Open browse for file to open in current window
573 02 Save write buffer to file
574 03 Undo undo last change
575 04 Redo redo last undone change
576 05 Cut delete selected text to clipboard
577 06 Copy copy selected text to clipboard
578 07 Paste paste text from clipboard
579 08 Print print current buffer
580 09 Help open a buffer on Vim's builtin help
581 10 Find start a search command
582 11 SaveAll write all modified buffers to file
583 12 SaveSesn write session file for current situation
584 13 NewSesn write new session file
585 14 LoadSesn load session file
586 15 RunScript browse for file to run as a Vim script
587 16 Replace prompt for substitute command
588 17 WinClose close current window
589 18 WinMax make current window use many lines
590 19 WinMin make current window use few lines
591 20 WinSplit split current window
592 21 Shell start a shell
593 22 FindPrev search again, backward
594 23 FindNext search again, forward
595 24 FindHelp prompt for word to search help for
596 25 Make run make and jump to first error
597 26 TagJump jump to tag under the cursor
598 27 RunCtags build tags for files in current directory
601 In the Win32 GUI, starting a menu name with ']' excludes that menu from the
602 main menu bar. You must then use the |:tearoff| command to display it.
605 In the Win32, GTK, Motif and Athena GUI, you can define the special menu
606 "PopUp". This is the menu that is displayed when the right mouse button is
607 pressed, if 'mousemodel' is set to popup or popup_setpos.
610 5.3 Showing What Menus Are Mapped To *showing-menus*
612 To see what an existing menu is mapped to, use just one argument after the
613 menu commands (just like you would with the ":map" commands). If the menu
614 specified is a submenu, then all menus under that hierarchy will be shown.
615 If no argument is given after :menu at all, then ALL menu items are shown
616 for the appropriate mode (eg, Command-line mode for :cmenu).
618 Note that hitting <Tab> while entering a menu name after a menu command may
619 be used to complete the name of the menu item.
622 5.4 Executing Menus *execute-menus*
625 To manually execute a menu item from the command line, use the :emenu
629 The normal mode command associated with the menu is executed (since that
630 is normally the one you want.)
631 If the console-mode vim has been compiled with WANT_MENU defined, you can
632 use :emenu to access useful menu items you may have got used to from GUI
633 mode. See 'wildmenu' for an option that works well with this. See
634 |console-menus| for an example.
637 5.5 Deleting Menus *delete-menus*
646 To delete a menu item or a whole submenu, use the unmenu commands, which are
647 analogous to the unmap commands. Eg:
650 This will remove the Paste item from the Edit menu for Insert and
653 Note that hitting <Tab> while entering a menu name after an umenu command
654 may be used to complete the name of the menu item for the appropriate mode.
656 To remove all menus use: *:unmenu-all*
657 > :unmenu * " remove all menus in Normal and visual mode
658 > :unmenu! * " remove all menus in Insert and Command-line mode
661 5.6 Examples for Menus *menu-examples*
663 Here is an example on how to add menu items with menu's! You can add a menu
664 item for the keyword under the cursor. The register "z" is used.
666 > :nmenu Words.Add\ Var wb"zye:menu! Words.<C-R>z <C-R>z<CR>
667 > :nmenu Words.Remove\ Var wb"zye:unmenu! Words.<C-R>z<CR>
668 > :vmenu Words.Add\ Var "zy:menu! Words.<C-R>z <C-R>z <CR>
669 > :vmenu Words.Remove\ Var "zy:unmenu! Words.<C-R>z<CR>
670 > :imenu Words.Add\ Var <Esc>wb"zye:menu! Words.<C-R>z <C-R>z<CR>a
671 > :imenu Words.Remove\ Var <Esc>wb"zye:unmenu! Words.<C-R>z<CR>a
673 (the rhs is in <> notation, you can copy/paste this text to try out the
674 mappings, or put these lines in your gvimrc; "<C-R>" is CTRL-R, "<CR>" is
679 These are currently only supported for the Win32 GUI. However, they should
680 appear for the other gui platforms in the not too distant future.
683 :tm[enu] {menupath} {rhs} Define a tip for a menu or tool. {only in
686 :tm[enu] [menupath] List menu tips. {only in GTK+ and Win32 GUI}
688 A "tip" can be defined for each menu item. For example, after defining an item
690 > :amenu MyMenu.Hello :echo "Hello"<CR>
691 The tip is defined like this:
692 > :tmenu MyMenu.Hello Displays a greeting.
694 When a tip is defined for a menu item, it appears in the command-line area
695 when the mouse is over that item, much like a standard Windows menu hint in
696 the status bar. (Except when Vim is in Command-line mode, when of course
697 nothing is displayed.)
698 When a tip is defined for a toolbar item, it appears as a tooltip when the
699 mouse pauses over that button, in the usual fashion.
701 The ":tmenu" command works just like other menu commands, it uses the same
705 :tu[nmenu] {menupath} Remove a tip for a menu or tool. {only in
708 :tunmenu deletes an existing menu tip, in the same way as the other unmenu
710 > :tunmenu MyMenu.Hello
711 If a menu item becomes invalid (i.e. its actions in all modes are deleted) Vim
712 deletes the menu tip (and the item) for you. This means that :aunmenu deletes
713 a menu item - you don't need to do a :tunmenu as well.
715 ==============================================================================
716 6. Extras *gui-extras*
718 This section describes other features which are related to the GUI.
720 - With the GUI, there is no wait for one second after hitting escape, because
721 the key codes don't start with <Esc>.
723 - Typing ^V followed by a special key in the GUI will insert "<Key>", since
724 the internal string used is meaningless. Modifiers may also be held down to
725 get "<Modifiers-Key>".
727 - In the GUI, the modifiers SHIFT, CTRL, and ALT (or META) may be used within
728 mappings of special keys and mouse events. eg: :map <M-LeftDrag> <LeftDrag>
730 - In the GUI, several normal keys may have modifiers in mappings etc, these
731 are <Space>, <Tab>, <NL>, <CR>, <Esc>.
733 ==============================================================================
734 7. Shell Commands *gui-shell*
736 For the X11 GUI the external commands are executed inside the gvim window.
739 WARNING: Executing an external command from the X11 GUI will not always
740 work. "normal" commands like "ls", "grep" and "make" mostly work fine.
741 Commands that require an intelligent terminal like "less" and "ispell" won't
742 work. Some may even hang and need to be killed from another terminal. So be
745 For the Win32 GUI the external commands are executed in a separate window.
746 See |gui-shell-win32|.