Movatterモバイル変換


[0]ホーム

URL:


Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq
Go to keyword (shortcut:k)
Site search (shortcut:s)
scroll.txt  ForVim version 9.2.  Last change: 2026 Feb 14VIM REFERENCE MANUAL  by Bram MoolenaarScrollingscrollingThese commands move the contents of the window.  If the cursor positionismoved off of the window, the cursoris moved onto thewindow (with'scrolloff' screen lines around it).A pageis the number of lines in thewindow minus two.  The mnemonics for these commands may bea bit confusing.Remember that the commands refer to moving thewindow (the part of the bufferthat you see) upwards or downwards in the buffer.  When thewindow movesupwards in the buffer, the text in thewindow moves downwards on your screen.Seesection03.7 of the user manual for an introduction.1. Scrolling downwardsscroll-down2. Scrolling upwardsscroll-up3. Scrolling relative to cursorscroll-cursor4. Scrolling horizontallyscroll-horizontal5. Scrolling synchronouslyscroll-binding6. Scrolling witha mouse wheelscroll-mouse-wheel==============================================================================1. Scrolling downwardsscroll-downThe following commands move the editwindow (the part of the buffer that yousee) downwards (this means that more lines downwards in the text buffer can beseen):CTRL-ECTRL-EScrollwindow[count] lines downwards in the buffer.The text moves upwards on the screen.Mnemonic: Extra lines.CTRL-DCTRL-DScrollwindow Downwards in the buffer.  The number oflines comes from the'scroll' option (default: halfascreen).  If[count] given, first set'scroll' optionto[count].  The cursoris moved the same number oflines down in the file (if possible; when lines wrapand when hitting theend of the file there may beadifference).  When the cursoris on the last line ofthe buffer nothing happens andabeepis produced.See also'startofline' option.<S-Down>or<S-Down><kPageDown><PageDown>or<PageDown>CTRL-F<S-CR>or<S-CR><S-NL><S-+>orSHIFT-+<S-Plus>CTRL-FScrollwindow[count] pages Forwards (downwards) inthe buffer.  See also'startofline' option.When thereis only onewindow the'window' optionmight be used.z+z+Without[count]: Redraw with the line just below thewindowat the top of the window.  Put the cursor inthat line,at the first non-blank in the line.With[count]: just like "z<CR>".==============================================================================2. Scrolling upwardsscroll-upThe following commands move the editwindow (the part of the buffer that yousee) upwards (this means that more lines upwards in the text buffer can beseen):CTRL-YCTRL-YScrollwindow[count] lines upwards in the buffer.The text moves downwards on the screen.Note: When using theMS-Windows key bindingsCTRL-Yisremapped to redo.CTRL-UCTRL-UScrollwindow Upwards in the buffer.  The number oflines comes from the'scroll' option (default: halfascreen).  If[count] given, first set the'scroll'option to[count].  The cursoris moved the samenumber of lines up in the file (if possible; whenlines wrap and when hitting theend of the file theremay bea difference).  When the cursoris on the firstline of the buffer nothing happens andabeepisproduced.  See also'startofline' option.<S-Up>or<S-Up><kPageUp><PageUp>or<PageUp>CTRL-B<S-->or<S-Minus>SHIFT-MINUSCTRL-BScrollwindow[count] pages Backwards (upwards) in thebuffer.  See also'startofline' option.When thereis only onewindow the'window' optionmight be used.z^z^Without[count]: Redraw with the line just above thewindowat the bottom of the window.  Put the cursor inthat line,at the first non-blank in the line.With[count]: First scroll the text toput the[count]lineat the bottom of the window, then redraw with theline whichis nowat the top of thewindowat thebottom of the window.  Put the cursor in that line,atthe first non-blank in the line.==============================================================================3. Scrolling relative to cursorscroll-cursorThe following commands reposition the editwindow (the part of the buffer thatyou see) while keeping the cursor on the same line.Note that the'scrolloff'option may cause context lines to show above and below the cursor.z<CR>z<CR>Redraw, line[count]at top ofwindow (defaultcursor line).  Put cursorat first non-blank in theline.ztztLike "z<CR>", but leave the cursor in the samecolumn.zN<CR>z{height}<CR>Redraw, makewindow{height} lines tall.  Thisisuseful to make the number of lines small when screenupdatingis very slow.  Cannot make the height morethan the physical screen height.z.z.Redraw, line[count]at center ofwindow (defaultcursor line).  Put cursorat first non-blank in theline.zzzzLike "z.", but leave the cursor in the same column.Careful: If caps-lockis on, this command becomes"ZZ": write buffer and exit!z-z-Redraw, line[count]at bottom ofwindow (defaultcursor line).  Put cursorat first non-blank in theline.zbzbLike "z-", but leave the cursor in the same column.==============================================================================4. Scrolling horizontallyscroll-horizontalFor the following four commands the cursor follows the screen.  If thecharacter that the cursoris onis moved off the screen, the cursoris movedto the closest character thatis on the screen.  The value of'sidescroll'isnot used.z<Right>    orzlz<Right>zlMove theview on the text[count] characters to theright, thus scroll the text[count] characters to theleft.  This only works when'wrap'is off.z<Left>      orzhz<Left>zhMove theview on the text[count] characters to theleft, thus scroll the text[count] characters to theright.  This only works when'wrap'is off.zLzLMove theview on the text halfa screenwidth to theright, thus scroll the text halfa screenwidth to theleft.  This only works when'wrap'is off.zHzHMove theview on the text halfa screenwidth to theleft, thus scroll the text halfa screenwidth to theright.  This only works when'wrap'is off.For the following two commands the cursoris not moved in the text, only thetext scrolls on the screen.zszsScroll the text horizontally to position the cursorat the start (left side) of the screen.  This onlyworks when'wrap'is off.zezeScroll the text horizontally to position the cursorat theend (right side) of the screen.  This onlyworks when'wrap'is off.==============================================================================5. Scrolling synchronouslyscroll-bindingOccasionally,itis desirable to bind two or morewindows together such thatwhen onewindowis scrolled, the otherwindows are also scrolled.  In Vim,windows can be given this behavior by setting the (window-specific)'scrollbind' option.  Whenawindow that has'scrollbind' setis scrolled, allother'scrollbind'windows are scrolled the same amount, if possible.  Thebehavior of'scrollbind' can be modified by the'scrollopt' option.When using the scrollbars or the mouse wheel, the binding only happens whenscrolling thewindow with focus (where the cursor is).  You can use this toavoidscroll-binding fora moment without resetting options.Whenawindow also has the'diff' option set, thescroll-binding uses thedifferences between the twobuffers to synchronize the position precisely.Otherwise the followingmethodis used.scrollbind-relativeEach'scrollbind'window keeps track of its "relative offset", which can bethought ofas the difference between the current window's vertical scrollposition and the other window's vertical scroll position.  When one of the'scrollbind'windowsis asked to vertically scroll past the beginning orendlimit of its text, thewindow no longer scrolls, but remembers how far pastthe limitit wishes to be.  Thewindow keeps this information so thatit canmaintain the same relative offset, regardless of its being asked to scrollpast its buffer's limits.However, ifa'scrollbind'window that hasa relative offset thatis past itsbuffer'slimitsis given the cursor focus, the other'scrollbind'windowsmustjump toa location where the current window's relative offsetis valid.  Thisbehavior can be changed by clearing the "jump" flag from the'scrollopt'option.syncbind:syncbind:sync:syncbindForce all'scrollbind'windows to have the samerelative offset.  I.e., when any of the'scrollbind'windowsis scrolled to the top of its buffer, all ofthe'scrollbind'windows will also beat the top oftheir buffers.scrollbind-quickadjThe'scrollbind' flagis meaningful when using keyboard commands to verticallyscrolla window, andis also meaningful when using the vertical scrollbar orthe mouse wheel in thewindow which has the cursor focus.  However, when usingthe vertical scrollbar or the mouse wheel inawindow which doesn't have thecursor focus,'scrollbind'is ignored.This allows quick adjustment of the relative offset of'scrollbind' windows.==============================================================================6. Scrolling witha mouse wheelscroll-mouse-wheelWhen your mouse hasa scroll wheel,it should work with Vim in the GUI.  Howit works depends on your system.  It might also work in an xtermxterm-mouse-wheel.  By default only vertical scroll wheels are supported,but some GUIs also support horizontal scroll wheels.On MS-Windows, if the scroll action causes input focus -problems, seeintellimouse-wheel-problems.ForWin32 and theX11 GUIs (Motif and GTK)scrolling the wheel generates keypresses<ScrollWheelUp>,<ScrollWheelDown>,<ScrollWheelLeft> and<ScrollWheelRight>.  For example, if you push the scroll wheel upwardsa<ScrollWheelUp> key pressis generated causing thewindow to scroll upwards(while the textis actually moving downwards).  The default action for thesekeys are:<ScrollWheelUp>    scrollN lines up<ScrollWheelUp><S-ScrollWheelUp>    scroll one page up<S-ScrollWheelUp><C-ScrollWheelUp>    scroll one page up<C-ScrollWheelUp><ScrollWheelDown>    scrollN lines down<ScrollWheelDown><S-ScrollWheelDown>    scroll one page down<S-ScrollWheelDown><C-ScrollWheelDown>    scroll one page down<C-ScrollWheelDown><ScrollWheelLeft>    scrollN columns left<ScrollWheelLeft><S-ScrollWheelLeft>    scroll one page left<S-ScrollWheelLeft><C-ScrollWheelLeft>    scroll one page left<C-ScrollWheelLeft><ScrollWheelRight>    scrollN columns right<ScrollWheelRight><S-ScrollWheelRight>    scroll one page right<S-ScrollWheelRight><C-ScrollWheelRight>    scroll one page right<C-ScrollWheelRight>This should work in all modes, except when editing the command line.The value ofN depends on the system.  By default Vim scrolls three lines whenmoving vertically, and six columns when moving horizontally.  OnMS-Windowsthe amount of lines and columns for each scroll actionis taken from thesystem-wide settings.Note that horizontalscrolling only works if'nowrap'is set.  Also, unlessthe "h" flag in'guioptions'is set, the cursor moves to the longest visibleline if the cursor lineis about to be scrolled off the screen (similarly tohow the horizontal scrollbar works).You can modify the default behavior bymapping the keys.  For example, to makethe scroll wheel move one line or halfa page inNormal mode:   :map <ScrollWheelUp> <C-Y>   :map <S-ScrollWheelUp> <C-U>   :map <ScrollWheelDown> <C-E>   :map <S-ScrollWheelDown> <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.mouse-scrolling-offIf youdo not want the mouse to causescrolling (e.g. because resting yourpalm on the touchpad causes scroll events), you can disable that with::map <ScrollWheelDown> <Nop>:map! <ScrollWheelDown> <Nop>:map <ScrollWheelUp> <Nop>:map! <ScrollWheelUp> <Nop>:map <ScrollWheelLeft> <Nop>:map! <ScrollWheelLeft> <Nop>:map <ScrollWheelRight> <Nop>:map! <ScrollWheelRight> <Nop>When using XFree86, the /etc/XF86Config file should have the correct entry foryour mouse.  For FreeBSD, this entry works fora Logitech scrollmouse:    Protocol     "MouseMan"    Device       "/dev/psm0"    ZAxisMapping 4 5See the XFree86 documentation for information.<MouseDown><MouseUp>The keys<MouseDown> and<MouseUp> have been deprecated.  Use<ScrollWheelUp>instead of<MouseDown> and use<ScrollWheelDown> instead of<MouseUp>.xterm-mouse-wheelTo use the mouse wheel ina 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 youmustdo this:1. Makeit work in your Xserver,as mentioned above.2. Add translations for the xterm, so that the xterm will passa scroll event   to Vimas anescape sequence.3. Add mappings in Vim, to interpret theescape sequencesas<ScrollWheelDown>   or<ScrollWheelUp> keys.You cando the translations by adding this to your ~.Xdefaults file (or otherfile where yourX 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 yourvimrc file::map <M-Esc>[62~ <ScrollWheelUp>:map! <M-Esc>[62~ <ScrollWheelUp>:map <M-Esc>[63~ <ScrollWheelDown>:map! <M-Esc>[63~ <ScrollWheelDown>:map <M-Esc>[64~ <S-ScrollWheelUp>:map! <M-Esc>[64~ <S-ScrollWheelUp>:map <M-Esc>[65~ <S-ScrollWheelDown>:map! <M-Esc>[65~ <S-ScrollWheelDown> vim:tw=78:ts=8:noet:ft=help:norl:

Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq


[8]ページ先頭

©2009-2026 Movatter.jp