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