📄 term.txt
字号:
is sent to the terminal at a time (does not work for MS-DOS). This makes thescreen updating a lot slower, making it possible to see what is happening.==============================================================================5. Using the mouse *mouse-using*This section is about using the mouse on a terminal or a terminal window. Howto use the mouse in a GUI window is explained in |gui-mouse|. For scrollingwith a mouse wheel see |scroll-mouse-wheel|.Don't forget to enable the mouse with this commands:> :set mouse=aOtherwise Vim won't recognize the mouse in all modes (See 'mouse').Currently the mouse is supported for Unix in an xterm window, in a Linuxconsole (with GPM |gpm-mouse|), for MS-DOS and in a Windows console.Mouse clicks can be used to position the cursor, select an area and paste.These characters in the 'mouse' option tell in which situations the mouse willbe used by Vim: n Normal mode v Visual mode i Insert mode c Command-line mode h all previous modes when in a help file a all previous modes r for |hit-return| prompt A auto-select in Visual modeThe default for 'mouse' is empty, the mouse is not used. Normally you would do> :set mouse=ato start using the mouse (this is equivalent to setting 'mouse' to "nvich").If you only want to use the mouse in a few modes or also want to use it forthe two questions you will have to concatenate the letters for those modes.For example:> :set mouse=nvWill make the mouse work in Normal mode and Visual mode.> :set mouse=hWill make the mouse work in help files only (so you can use "g<LeftMouse>" tojump to tags).Whether the selection that is started with the mouse is in Visual mode orSelect mode depends on whethere "mouse" in included in the 'selectmode'option.In an xterm, with the currently active mode included in the 'mouse' option,normal mouse clicks are used by Vim, mouse clicks with the shift or ctrl keypressed go to the xterm. With the currently active mode not included in'mouse' all mouse clicks go to the xterm. *xterm-clipboard*In the Athena and Motif GUI versions, when running in an xterm and there isaccess to the X-server (DISPLAY is set), the copy and paste will behave likein the GUI. If not, the middle mouse button will insert the unnamed register.In that case, here is how you copy and paste a piece of text:Copy/paste with the mouse and Visual mode ('mouse' option must be set, seeabove):1. Press left mouse button on first letter of text, move mouse pointer to last letter of the text and release the button. This will start Visual mode and highlight the selected area.2. Press "y" to yank the Visual text in the unnamed register.3. Click the left mouse button at the insert position.4. Click the middle mouse button.Shortcut: If the insert position is on the screen at the same time as theVisual text, you can do 2, 3 and 4 all in one: Click the middle mouse buttonat the insert position. *xterm-copy-paste*NOTE: In some (older) xterms, it's not possible to move the cursor past column95. This is an xterm problem, not Vim's. Get a newer xterm |color-xterm|.Copy/paste in xterm with (current mode NOT included in 'mouse'):1. Press left mouse button on first letter of text, move mouse pointer to last letter of the text and release the button.2. Use normal Vim commands to put the cursor at the insert position.3. Press "a" to start Insert mode.4. Click the middle mouse button.5. Press ESC to end Insert mode.(The same can be done with anything in 'mouse' if you keep the shift keypressed while using the mouse)Note: if you lose the 8th bit when pasting (special characters are translatedinto other characters), you may have to do "stty cs8 -istrip -parenb" in yourshell before starting Vim.Thus in an xterm the shift and ctrl keys cannot be used with the mouse. Tomake it possible to do the mouse commands that require the ctrl modifier, the"g" key can be typed before using the mouse: "g<LeftMouse>" is "<C-LeftMouse> (jump to tag under mouse click) "g<RightMouse>" is "<C-RightMouse> ("CTRL-T") *mouse-mode-table* *mouse-overview*A short overview of what the mouse buttons do, when 'mousemodel' is "extend":Normal Mode:event position selection change action ~ cursor window ~<LeftMouse> yes end yes<C-LeftMouse> yes end yes "CTRL-]" (2)<S-LeftMouse> yes no change yes "*" (2) *<S-LeftMouse>*<LeftDrag> yes start or extend (1) no *<LeftDrag>*<LeftRelease> yes start or extend (1) no<MiddleMouse> yes if not active no put<MiddleMouse> yes if active no yank and put<RightMouse> yes start or extend yes<S-RightMouse> yes no change yes "#" (2) *<S-RightMouse>*<C-RightMouse> no no change no "CTRL-T"<RightDrag> yes extend no *<RightDrag>*<RightRelease> yes extend no *<RightRelease>*Insert or Replace Mode:event position selection change action ~ cursor window ~<LeftMouse> yes (cannot be active) yes<C-LeftMouse> yes (cannot be active) yes "CTRL-O^]" (2)<S-LeftMouse> yes (cannot be active) yes "CTRL-O*" (2)<LeftDrag> yes start or extend (1) no like CTRL-O (1)<LeftRelease> yes start or extend (1) no like CTRL-O (1)<MiddleMouse> no (cannot be active) no put register<RightMouse> yes start or extend yes like CTRL-O<S-RightMouse> yes (cannot be active) yes "CTRL-O#" (2)<C-RightMouse> no (cannot be active) no "CTRL-O CTRL-T"In a help window:event position selection change action ~ cursor window ~<2-LeftMouse> yes (cannot be active) no "^]" (jump to help tag)When 'mousemodel' is "popup", these are different:Normal Mode:event position selection change action ~ cursor window ~<S-LeftMouse> yes start or extend (1) no<RightMouse> no popup menu noInsert or Replace Mode:event position selection change action ~ cursor window ~<S-LeftMouse> yes start or extend (1) no like CTRL-O (1)<RightMouse> no popup menu no(1) only if mouse pointer moved since press(2) only if click is in same bufferClicking the left mouse button causes the cursor to be positioned. If theclick is in another window that window is made the active window. Whenediting the command-line the cursor can only be positioned on thecommand-line. When in Insert mode Vim remains in Insert mode. If 'scrolloff'is set, and the cursor is positioned within 'scrolloff' lines from the windowborder, the text is scrolled.A selection can be started by pressing the left mouse button on the firstcharacter, moving the mouse to the last character, then releasing the mousebutton. You will not always see the selection until you release the button,only in some versions (GUI, MS-DOS, WIN32) will the dragging be shownimmediately. Note that you can make the text scroll by moving the mouse atleast one character in the first/last line in the window when 'scrolloff' isnon-zero.In Normal, Visual and Select mode clicking the right mouse button causes theVisual area to be extended. When 'mousemodel' is "popup", the left button hasto be used while keeping the shift key pressed. When clicking in a windowwhich is editing another buffer, the Visual or Select mode is stopped. *double-click*Double, triple and quadruple clicks are supported when the GUI is active,for MS-DOS and Win32, and for an xterm (if the gettimeofday() function isavailable). For selecting text, extra clicks extend the selection: click select ~ double word *<2-LeftMouse>* triple line *<3-LeftMouse>* quadruple rectangular block *<4-LeftMouse>*Exception: In a Help window a double click jumps to help for the word that isclicked on.For MS-DOS and xterm the time for double clicking can be set with the'mousetime' option. For the other systems this time is defined outside ofVim.An example, for using a double click to jump to the tag under the cursor:> :map <2-LeftMouse> :exe "tag ". expand("<cword>")<CR> *gpm-mouse*The GPM mouse is only supported when the |+mouse_gpm| feature was enabled atcompile time. The GPM mouse driver (Linux console) does not support quadrupleclicks.In Insert mode, when a selection is started, Vim goes into Normal modetemporarily. When Visual or Select mode ends, it returns to Insert mode.This is like using CTRL-O in Insert mode. Select mode is used when the'selectmode' option contains "mouse". *drag-status-line*When working with several windows, the size of the windows can be changed bydragging the status line with the mouse. Point the mouse at a status line,press the left button, move the mouse to the new position of the status line,release the button. Just clicking the mouse in a status line makes that windowthe current window, without moving the cursor. If by selecting a window itwill change position or size, the dragging of the status line will lookconfusing, but it will work (just try it).Mouse clicks can be mapped. The codes for mouse clicks are: code mouse button normal action ~ <LeftMouse> left pressed set cursor position <LeftDrag> left moved while pressed extend selection <LeftRelease> left released set selection end <MiddleMouse> middle pressed paste text at cursor position <MiddleDrag> middle moved while pressed - <MiddleRelease> middle released - <RightMouse> right pressed extend selection <RightDrag> right moved while pressed extend selection <RightRelease> right released set selection endExamples:> :noremap <MiddleMouse> <LeftMouse><MiddleMouse>Paste at the position of the middle mouse button click (otherwise the pastewould be done at the cursor position).> :noremap <LeftRelease> <LeftRelease>yImmediately yank the selection, when using Visual mode.Note the use of ":noremap" instead of "map" to avoid a recursive mapping. *mouse-swap-buttons*To swap the meaning of the left and right mouse buttons:> :noremap <LeftMouse> <RightMouse>> :noremap <LeftDrag> <RightDrag>> :noremap <LeftRelease> <RightRelease>> :noremap <RightMouse> <LeftMouse>> :noremap <RightDrag> <LeftDrag>> :noremap <RightRelease> <LeftRelease>> :noremap g<LeftMouse> <C-RightMouse>> :noremap g<RightMouse> <C-LeftMouse>> :noremap! <LeftMouse> <RightMouse>> :noremap! <LeftDrag> <RightDrag>> :noremap! <LeftRelease> <RightRelease>> :noremap! <RightMouse> <LeftMouse>> :noremap! <RightDrag> <LeftDrag>> :noremap! <RightRelease> <LeftRelease> vim:tw=78:ts=8:sw=8:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -