📄 gui.txt
字号:
*gui-mouse-focus*The 'mousefocus' option can be set to make the keyboard focus follow themouse pointer. This means that the window where the mouse pointer is, is theactive window. Warning: this doesn't work very well when using a menu,because the menu command will always be applied to the top window.If you are on the ':' line (or '/' or '?'), then clicking the left or rightmouse button will position the cursor on the ':' line (if 'mouse' contains'c', 'a' or 'A').In any situation the middle mouse button may be clicked to paste the currentselection.3.2 Selection with Mouse *gui-mouse-select*The mouse can be used to start a selection. How depends on the 'mousemodel'option:'mousemodel' is "extend": use the right mouse button'mousemodel' is "popup": use the left mouse button, while keeping the Shiftkey pressed.If there was no selection yet, this starts a selection from the old cursorposition to the position pointed to with the mouse. If there already is aselection then the closest end will be extended.If 'selectmode' contains "mouse", then the selection will be in Select mode.This means that typing normal text will replace the selection. See|Select-mode|. Otherwise, the selection will be in Visual mode.Double clicking may be done to make the selection word-wise, triple clickingmakes it line-wise, and quadruple clicking makes it rectangular block-wise.See |gui-selections| on how the selection is used.3.3 Other Text Selection with Mouse *gui-mouse-modeless*When in Command-line mode, at the |hit-return| prompt or whenever the currentmode is not in the 'mouse' option, a different kind of selection is used.Since Vim continues like the selection isn't there, and there is no modeassociated with the selection, this is called modeless selection. Any text inthe Vim window can be selected. Select the text by pressing the left mousebutton at the start, drag to the end and release. To extend the selection,use the right mouse button when 'mousemodel' is "extend", or the left mousebutton with the shift key pressed when 'mousemodel' is "popup".The middle mouse button pasts the text.3.4 Using Mouse on Status Lines *gui-mouse-status*Clicking the left or right mouse button on the status line below a Vimwindow makes that window the current window. The mouse may then be draggedup and down to move the status line, thus resizing the windows above andbelow it.3.5 Various Mouse Clicks *gui-mouse-various* <S-LeftMouse> Search forward for the word under the mouse click. When 'mousemodel' is "popup" this starts or extends a selection. <S-RightMouse> Search backward for the word under the mouse click. <C-LeftMouse> Jump to the tag name under the mouse click. <C-RightMouse> Jump back to position before the previous tag jump (same as "CTRL-T")3.6 Mouse Mappings *gui-mouse-mapping*The mouse events, complete with modifiers, may be mapped. Eg:> :map <S-LeftMouse> <RightMouse>> :map <S-LeftDrag> <RightDrag>> :map <S-LeftRelease> <RightRelease>> :map <2-S-LeftMouse> <2-RightMouse>> :map <2-S-LeftDrag> <2-RightDrag>> :map <2-S-LeftRelease> <2-RightRelease>> :map <3-S-LeftMouse> <3-RightMouse>> :map <3-S-LeftDrag> <3-RightDrag>> :map <3-S-LeftRelease> <3-RightRelease>> :map <4-S-LeftMouse> <4-RightMouse>> :map <4-S-LeftDrag> <4-RightDrag>> :map <4-S-LeftRelease> <4-RightRelease>These mappings make selection work the way it probably should in a Motifapplication, with shift-left mouse allowing for extending the visual arearather than the right mouse button.Mouse mapping with modifiers does not work for modeless selection.==============================================================================4. Making GUI Selections *gui-selections* *quotestar*You may make selections with the mouse (see |gui-mouse-select|), or by usingVim's Visual mode (see |v|). If 'a' is present in 'guioptions', thenwhenever a selection is started (Visual or Select mode), or when the selectionis changed, Vim becomes the owner of the windowing system's primary selection(on MS-Windows the |gui-clipboard| is used).There is a special register for storing this selection, it is the "*register. Nothing is put in here unless the information about what text isselected is about to change (eg with a left mouse click somewhere), or whenanother application wants to paste the selected text. Then the text is putin the "* register. For example, to cut a line and make it the currentselection/put it on the clipboard:> "*ddSimilarly, when you want to paste a selection from another application, e.g.,by clicking the middle mouse button, the selection is put in the "* registerfirst, and then 'put' like any other register. For example, to put theselection (contents of the clipboard):> "*pNote that when pasting text from one Vim into another separate Vim, the typeof selection (character, line, or block) will also be copied. For otherapplications the type is always character.When the "unnamed" string is included in the 'clipboard' option, the unnamedregister is the same as the "* register. Thus you can yank to and paste theselection without prepending "* to commands.==============================================================================5. Menus *menus*5.1 Using Menus *using-menus*Basically, menus can be used just like mappings. You can define you ownmenus, as many as you like. There is a default set of menus, so that youdon't have to start from scratch. Long-time Vim users won't use menus much.But the power is in adding your own menus and menu items. They are mostuseful for things that you can't remember what the key sequence was. *menu.vim*The default menus are read from the file "$VIMRUNTIME/menu.vim". See|$VIMRUNTIME| for where the path comes from. You can set up your own menus.Starting off with the default set is a good idea. You can add more items, or,if you don't like the defaults at all, start with removing all menus|:unmenu-all|. You can also avoid the default menus being loaded by addingthis line to your .vimrc file (NOT your .gvimrc file!):> let did_install_default_menus = 1If you also want to avoid the Syntax menu:> let did_install_syntax_menu = 1The contents of the buffer menu can be controlled by setting the variablesbufmenu_fullpath and bufmenu_maxlen. The former specifies full path of filesto be used in the menu if set to 1. The latter specifies the maximum length ofthe path in the menu label. If the path is longer, path elements other than thefirst and last are removed. Then trailing and leading characters are removedfrom these if necessary. Last all path elements are removed. These variablesmust be set in .vimrc or similar, since .gvimrc is executed after menu.vim.Default values are bufmenu_fullpath=0 and bufmenu_maxlen=50. *console-menus*Although this documentation is in the GUI section, you can actually use menusin console mode too. You will have to load |menu.vim| explicitly then, it isnot done by default. You can use the |:emenu| command and command-linecompletion with 'wildmenu' to access the menu entries almost like a real menusystem. To do this, put these commands in your .vimrc file:> :source $VIMRUNTIME/menu.vim> :set wildmenu> :set cpo-=<> :set wcm=<C-Z>> :map <F4> :emenu <C-Z>Pressing <F4> will start the menu. You can now use the cursor keys to selecta menu entry. Hit <Return> to execute it. Hit <Esc> if you want to cancel.This does require the |+menu| feature enabled at compile time. *tear-off-menus*GTK+ and Motif support Tear-off menus. These are sort of sticky menus orpop-up menus that are present all the time. If the resizing does not workcorrectly, this may be caused by using something like "Vim*geometry" in dedefaults. Use "Vim.geometry" instead.The Win32 GUI version emulates Motif's tear-off menus. Actually, a Motif userwill spot the differences easily, but hopefully they're just as useful. Youcan also use the |:tearoff| command together with |win32-hidden-menus| tocreate floating menus that do not appear on the main menu bar.5.2 Creating New Menus *creating-menus* *:me* *:menu* *:noreme* *:noremenu* *:am* *:amenu* *:an* *:anoremenu* *:nme* *:nmenu* *:nnoreme* *:nnoremenu* *:ome* *:omenu* *:onoreme* *:onoremenu* *:vme* *:vmenu* *:vnoreme* *:vnoremenu* *:ime* *:imenu* *:inoreme* *:inoremenu* *:cme* *:cmenu* *:cnoreme* *:cnoremenu*To create a new menu item, use the ":menu" commands. They are exactly likethe ":map" set of commands but the first argument is a menu item name, givenas a path of menus and submenus with a '.' between them. eg:> :menu File.Save :w<CR>> :inoremenu File.Save <C-O>:w<CR>> :menu Edit.Big\ Changes.Delete\ All\ Spaces :%s/[ ^I]//g<CR>This last one will create a new item in the menu bar called "Edit", holdingthe mouse button down on this will pop up a menu containing the item"Big Changes", which is a sub-menu containing the item "Delete All Spaces",which when selected, performs the operation.Special characters in a menu name: & The next character is the shortcut key. Make sure each shortcut key is only used once in a (sub)menu. <Tab> Separates the menu name from right-aligned text. This can be used to show the equivalent typed command. The text "<Tab>" can be used here for convenience. If you are using a real Tab, don't forget to put a backslash before it!Example:> :amenu &File.&Open<Tab>:e :browse e<CR>[typed literally]With the shortcut "F" (while keeping the <Alt> key pressed), and then "O",this menu can be used. The second part is shown as "Open :e". The ":e"is right aligned, and the "O" is underlined, to indicate it is the shortcut.The ":amenu" command can be used to define menu entries for all modes at once.To make the command work correctly, a character is automatically inserted forsome modes: mode inserted ~ Normal nothing Visual <Esc> Insert <C-O> Cmdline <C-C> Op-pending <Esc>Example:> :amenu File.Exit :qa!^Mis equal to:> :nmenu File.Exit :qa!^M> :vmenu File.Exit ^[:qa!^M> :imenu File.Exit ^O:qa!^M> :cmenu File.Exit ^C:qa!^M> :omenu File.Exit ^[:qa!^MCareful: In Insert mode this only works for a SINGLE Normal mode command,because of the CTRL-O. If you have two or more commands, you will need to usethe ":imenu" command. For inserting text in any mode, you can use theexpression register:> :amenu Insert.foobar "='foobar'<CR>PNote that the '<' and 'k' flags in 'cpoptions' also apply here (whenincluded they make the <> form and raw key codes not being recognized).Note that <Esc> in Cmdline mode executes the command, like in a mapping. Thisis Vi compatible. Use CTRL-C to quit Cmdline mode. *menu-priority*You can give a priority to a menu. Menus with a higher priority go more tothe right. The priority is given as a number before the ":menu" command.Example:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -