📄 scroll.txt
字号:
*scroll.txt* For Vim version 5.8. Last change: 2000 Jun 14 VIM REFERENCE MANUAL by Bram MoolenaarScrolling *scrolling*These commands move the contents of the window. If the cursor position ismoved off of the window, the cursor is moved onto the window (with'scrolloff' screen lines around it). A page is the number of lines in thewindow minus two. The mnemonics for these commands may be a bit confusing.Remember that the commands refer to moving the window (the part of the bufferthat you see) upwards or downwards in the buffer. When the window movesupwards in the buffer, the text in the window moves downwards on your screen.1. Scrolling downwards |scroll-down|2. Scrolling upwards |scroll-up|3. Scrolling relative to cursor |scroll-cursor|4. Scrolling horizontally |scroll-horizontal|5. Scrolling synchronously |scroll-binding|6. Scrolling with a mouse wheel |scroll-mouse-wheel|==============================================================================1. Scrolling downwards *scroll-down*The following commands move the edit window (the part of the buffer that yousee) downwards (this means that more lines downwards in the text buffer can beseen): *CTRL-E*CTRL-E Scroll window [count] lines downwards in the buffer. Mnemonic: Extra lines. *CTRL-D*CTRL-D Scroll window Downwards in the buffer. The number of lines comes from the 'scroll' option (default: half a screen). If [count] given, first set 'scroll' option to [count]. The cursor is moved the same number of lines down in the file (if possible; when lines wrap and when hitting the end of the file there may be a difference). When the cursor is on the last line of the buffer nothing happens and a beep is produced. See also 'startofline' option. {difference from vi: Vim scrolls 'scroll' screen lines, instead of file lines; makes a difference when lines wrap}<S-Down> or *<S-Down>* *<kPageDown>*<PageDown> or *<PageDown>* *CTRL-F*CTRL-F Scroll window [count] pages Forwards (downwards) in the buffer. See also 'startofline' option. *z+*z+ Without [count]: Redraw with the line just below the window at the top of the window. Put the cursor in that line, at the first non-blank in the line. With [count]: just like "z<CR>".==============================================================================2. Scrolling upwards *scroll-up*The following commands move the edit window (the part of the buffer that yousee) upwards (this means that more lines upwards in the text buffer can beseen): *CTRL-Y*CTRL-Y Scroll window [count] lines upwards in the buffer. *CTRL-U*CTRL-U Scroll window Upwards in the buffer. The number of lines comes from the 'scroll' option (default: half a screen). If [count] given, first set the 'scroll' option to [count]. The cursor is moved the same number of lines up in the file (if possible; when lines wrap and when hitting the end of the file there may be a difference). When the cursor is on the first line of the buffer nothing happens and a beep is produced. See also 'startofline' option. {difference from vi: Vim scrolls 'scroll' screen lines, instead of file lines; makes a difference when lines wrap}<S-Up> or *<S-Up>* *<kPageUp>*<PageUp> or *<PageUp>* *CTRL-B*CTRL-B Scroll window [count] pages Backwards (upwards) in the buffer. See also 'startofline' option. *z^*z^ Without [count]: Redraw with the line just above the window at the bottom of the window. Put the cursor in that line, at the first non-blank in the line. With [count]: First scroll the text to put the [count] line at the bottom of the window, then redraw with the line which is now at the top of the window at the bottom of the window. Put the cursor in that line, at the first non-blank in the line.==============================================================================3. Scrolling relative to cursor *scroll-cursor*The following commands reposition the edit window (the part of the buffer thatyou see) while keeping the cursor on the same line: *z* *z<CR>*z<CR> Redraw, line [count] at top of window (default cursor line). Put cursor at first non-blank in the line. *zt*zt Like "z<CR>", but leave the cursor in the same column. {not in Vi} *zN<CR>*z{height}<CR> Redraw, make window {height} lines tall. This is useful to make the number of lines small when screen updating is very slow. Cannot make the height more than the physical screen height. *z.*z. Redraw, line [count] at center of window (default cursor line). Put cursor at first non-blank in the line. *zz*zz Like "z.", but leave the cursor in the same column. Careful: If caps-lock is on, this commands becomes "ZZ": write buffer and exit! {not in Vi} *z-*z- Redraw, line [count] at bottom of window (default cursor line). Put cursor at first non-blank in the line. *zb*zb Like "z-", but leave the cursor in the same column. {not in Vi}==============================================================================4. Scrolling horizontally *scroll-horizontal*For the following four commands the cursor follows the screen. If thecharacter that the cursor is on is moved off the screen, the cursor is movedto the closest character that is on the screen. The value of 'sidescroll' isnot used.z<Right> or *zl* *z<Right>*zl Scroll the screen [count] characters to the left. This only works when 'wrap' is off. {not in Vi}z<Left> or *zh* *z<Left>*zh Scroll the screen [count] characters to the right. This only works when 'wrap' is off. {not in Vi} *zL*zL Scroll the screen half a screenwidth to the left. This only works when 'wrap' is off. {not in Vi} *zH*zH Scroll the screen half a screenwith to the right. This only works when 'wrap' is off. {not in Vi}For the following two commands the cursor is not moved in the text, only thetext scrolls on the screen. *zs*zs Scroll the screen horizontally to position the cursor at the start (left side) of the screen. This only works when 'wrap' is off. {not in Vi} *ze*ze Scroll the screen horizontally to position the cursor at the end (right side) of the screen. This only works when 'wrap' is off. {not in Vi}==============================================================================5. Scrolling synchronously *scroll-binding*Occasionally, it is desirable to bind two or more windows together such thatwhen one window is scrolled, the other windows are scrolled also. In Vim,windows can be given this behavior by setting the (window-specific)'scrollbind' option. When a window that has 'scrollbind' set is scrolled, allother 'scrollbind' windows are scrolled the same amount, if possible. Thebehavior of 'scrollbind' can be modified by the 'scrollopt' option. *scrollbind-relative*Each 'scrollbind' window keeps track of its "relative offset," which can bethought of as the difference between the current window's vertical scrollposition and the other window's vertical scroll position. When one of the'scrollbind' windows is asked to vertically scroll past the beginning or endlimit of its text, the window no longer scrolls, but remembers how far pastthe limit it wishes to be. The window keeps this information so that it canmaintain the same relative offset, regardless of its being asked to scrollpast its buffer's limits.However, if a 'scrollbind' window that has a relative offset that is past itsbuffer's limits is given the cursor focus, the other 'scrollbind' windows mustjump to a location where the current window's relative offset is valid. Thisbehavior can be changed by clearing the 'jump' flag from the 'scrollopt'option. *syncbind* *:syncbind*:syncbind Force all 'scrollbind' windows to have the same relative offset. I.e., when any of the 'scrollbind' windows is scrolled to the top of its buffer, all of the 'scrollbind' windows will also be at the top of their buffers. *scrollbind-quickadj*The 'scrollbind' flag is meaningful when using keyboard commands to verticallyscroll a window, and also meaningful when using the vertical scrollbar of thewindow which has the cursor focus. However, when using the vertical scrollbarof a window which doesn't have the cursor focus, 'scrollbind' is ignored.This allows quick adjustment of the relative offset of 'scrollbind' windows.==============================================================================6. Scrolling with a mouse wheel *scroll-mouse-wheel*When your mouse has a scroll wheel, it should work with Vim in the GUI. Howit works depends on your system. It might also work in an xterm|xterm-mouse-wheel|.For the Win32 GUI the scroll action is hard coded. It works just likedragging the scrollbar of the current window. How many lines are scrolleddepends on your mouse driver. If the scroll action causes input focusproblems, see |intellimouse-wheel-problems|.For the X11 GUIs (Motif, Athena and GTK) scrolling the wheel generates keypresses <MouseDown> and <MouseUp>. The default action for these keys are: <MouseDown> scroll three lines down. *<MouseDown>* <S-MouseDown> scroll a full page down. *<S-MouseDown>* <MouseUp> scroll three lines up. *<MouseUp>* <S-MouseUp> scroll a full page up. *<S-MouseUp>*This should work in all modes, except when editing the command line.You can modify this behavior by mapping the keys. For example, to make thescroll wheel move one line or half a page in Normal mode:> map <MouseDown> <C-Y>> map <S-MouseDown> <C-U>> map <MouseUp> <C-E>> map <S-MouseUp> <C-D>You can also use Alt and Ctrl modifiers.This only works when Vim gets the scroll wheel events, of course. You cancheck if this works with the "xev" program.When using Xfree86, the /etc/XF86Config file should have the correct entry foryour mouse. For FreeBSD, this entry works for a Logitech scrollmouse:> Protocol "MouseMan"> Device "/dev/psm0"> ZAxisMapping 4 5See the Xfree86 documentation for information. *xterm-mouse-wheel*To use the mouse wheel in a new xterm you only have to make the scroll wheelwork in your Xserver, as mentioned above.To use the mouse wheel in an older xterm you must do this:1. Make it work in your Xserver, as mentioned above.2. Add translations for the xterm, so that the xterm will pass a scroll event to Vim as an escape sequence.3. Add mappings in Vim, to interpret the escape sequences as <MouseUp> or <MouseDown> keys.You can do the translations by adding this to your ~.Xdefaults file (or otherfile where your X resources are kept):> XTerm*VT100.Translations: #override \n\> s<Btn4Down>: string("0x9b") string("[64~") \n\> s<Btn5Down>: string("0x9b") string("[65~") \n\> <Btn4Down>: string("0x9b") string("[62~") \n\> <Btn5Down>: string("0x9b") string("[63~") \n\> <Btn4Up>: \n\> <Btn5Up>: Add these mappings to your vimrc file:> map <M-Esc>[62~ <MouseDown>> map! <M-Esc>[62~ <MouseDown>> map <M-Esc>[63~ <MouseUp>> map! <M-Esc>[63~ <MouseUp>> map <M-Esc>[64~ <S-MouseDown>> map! <M-Esc>[64~ <S-MouseDown>> map <M-Esc>[65~ <S-MouseUp>> map! <M-Esc>[65~ <S-MouseUp> vim:tw=78:ts=8:sw=8:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -