scroll.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. *scroll.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Scrolling *scrolling*
  4. These commands move the contents of the window. If the cursor position is
  5. moved off of the window, the cursor is moved onto the window (with
  6. 'scrolloff' screen lines around it). A page is the number of lines in the
  7. window minus two. The mnemonics for these commands may be a bit confusing.
  8. Remember that the commands refer to moving the window (the part of the buffer
  9. that you see) upwards or downwards in the buffer. When the window moves
  10. upwards in the buffer, the text in the window moves downwards on your screen.
  11. See section |03.7| of the user manual for an introduction.
  12. Type |gO| to see the table of contents.
  13. ==============================================================================
  14. 1. Scrolling downwards *scroll-down*
  15. The following commands move the edit window (the part of the buffer that you
  16. see) downwards (this means that more lines downwards in the text buffer can be
  17. seen):
  18. *CTRL-E*
  19. CTRL-E Scroll window [count] lines downwards in the buffer.
  20. The text moves upwards on the screen.
  21. Mnemonic: Extra lines.
  22. *CTRL-D*
  23. CTRL-D Scroll window Downwards in the buffer. The number of
  24. lines comes from the 'scroll' option (default: half a
  25. screen). If [count] given, first set 'scroll' option
  26. to [count]. The cursor is moved the same number of
  27. lines down in the file (if possible; when lines wrap
  28. and when hitting the end of the file there may be a
  29. difference). When the cursor is on the last line of
  30. the buffer nothing happens and a beep is produced.
  31. See also 'startofline' option.
  32. {difference from vi: Vim scrolls 'scroll' screen
  33. lines, instead of file lines; makes a difference when
  34. lines wrap}
  35. <S-Down> or *<S-Down>* *<kPageDown>*
  36. <PageDown> or *<PageDown>* *CTRL-F*
  37. CTRL-F Scroll window [count] pages Forwards (downwards) in
  38. the buffer. See also 'startofline' option.
  39. When there is only one window the 'window' option
  40. might be used.
  41. *z+*
  42. z+ Without [count]: Redraw with the line just below the
  43. window at the top of the window. Put the cursor in
  44. that line, at the first non-blank in the line.
  45. With [count]: just like "z<CR>".
  46. ==============================================================================
  47. 2. Scrolling upwards *scroll-up*
  48. The following commands move the edit window (the part of the buffer that you
  49. see) upwards (this means that more lines upwards in the text buffer can be
  50. seen):
  51. *CTRL-Y*
  52. CTRL-Y Scroll window [count] lines upwards in the buffer.
  53. The text moves downwards on the screen.
  54. Note: When using the MS-Windows key bindings CTRL-Y is
  55. remapped to redo.
  56. *CTRL-U*
  57. CTRL-U Scroll window Upwards in the buffer. The number of
  58. lines comes from the 'scroll' option (default: half a
  59. screen). If [count] given, first set the 'scroll'
  60. option to [count]. The cursor is moved the same
  61. number of lines up in the file (if possible; when
  62. lines wrap and when hitting the end of the file there
  63. may be a difference). When the cursor is on the first
  64. line of the buffer nothing happens and a beep is
  65. produced. See also 'startofline' option.
  66. <S-Up> or *<S-Up>* *<kPageUp>*
  67. <PageUp> or *<PageUp>* *CTRL-B*
  68. CTRL-B Scroll window [count] pages Backwards (upwards) in the
  69. buffer. See also 'startofline' option.
  70. When there is only one window the 'window' option
  71. might be used.
  72. *z^*
  73. z^ Without [count]: Redraw with the line just above the
  74. window at the bottom of the window. Put the cursor in
  75. that line, at the first non-blank in the line.
  76. With [count]: First scroll the text to put the [count]
  77. line at the bottom of the window, then redraw with the
  78. line which is now at the top of the window at the
  79. bottom of the window. Put the cursor in that line, at
  80. the first non-blank in the line.
  81. ==============================================================================
  82. 3. Scrolling relative to cursor *scroll-cursor*
  83. The following commands reposition the edit window (the part of the buffer that
  84. you see) while keeping the cursor on the same line. Note that the 'scrolloff'
  85. option may cause context lines to show above and below the cursor.
  86. *z<CR>*
  87. z<CR> Redraw, line [count] at top of window (default
  88. cursor line). Put cursor at first non-blank in the
  89. line.
  90. *zt*
  91. zt Like "z<CR>", but leave the cursor in the same
  92. column.
  93. *zN<CR>*
  94. z{height}<CR> Redraw, make window {height} lines tall. This is
  95. useful to make the number of lines small when screen
  96. updating is very slow. Cannot make the height more
  97. than the physical screen height.
  98. *z.*
  99. z. Redraw, line [count] at center of window (default
  100. cursor line). Put cursor at first non-blank in the
  101. line.
  102. *zz*
  103. zz Like "z.", but leave the cursor in the same column.
  104. Careful: If caps-lock is on, this command becomes
  105. "ZZ": write buffer and exit!
  106. *z-*
  107. z- Redraw, line [count] at bottom of window (default
  108. cursor line). Put cursor at first non-blank in the
  109. line.
  110. *zb*
  111. zb Like "z-", but leave the cursor in the same column.
  112. ==============================================================================
  113. 4. Scrolling horizontally *scroll-horizontal*
  114. For the following four commands the cursor follows the screen. If the
  115. character that the cursor is on is moved off the screen, the cursor is moved
  116. to the closest character that is on the screen. The value of 'sidescroll' is
  117. not used.
  118. z<Right> or *zl* *z<Right>*
  119. zl Move the view on the text [count] characters to the
  120. right, thus scroll the text [count] characters to the
  121. left. This only works when 'wrap' is off.
  122. z<Left> or *zh* *z<Left>*
  123. zh Move the view on the text [count] characters to the
  124. left, thus scroll the text [count] characters to the
  125. right. This only works when 'wrap' is off.
  126. *zL*
  127. zL Move the view on the text half a screenwidth to the
  128. right, thus scroll the text half a screenwidth to the
  129. left. This only works when 'wrap' is off.
  130. *zH*
  131. zH Move the view on the text half a screenwidth to the
  132. left, thus scroll the text half a screenwidth to the
  133. right. This only works when 'wrap' is off.
  134. For the following two commands the cursor is not moved in the text, only the
  135. text scrolls on the screen.
  136. *zs*
  137. zs Scroll the text horizontally to position the cursor
  138. at the start (left side) of the screen. This only
  139. works when 'wrap' is off.
  140. *ze*
  141. ze Scroll the text horizontally to position the cursor
  142. at the end (right side) of the screen. This only
  143. works when 'wrap' is off.
  144. ==============================================================================
  145. 5. Scrolling synchronously *scroll-binding*
  146. Occasionally, it is desirable to bind two or more windows together such that
  147. when one window is scrolled, the other windows are also scrolled. In Vim,
  148. windows can be given this behavior by setting the (window-specific)
  149. 'scrollbind' option. When a window that has 'scrollbind' set is scrolled, all
  150. other 'scrollbind' windows are scrolled the same amount, if possible. The
  151. behavior of 'scrollbind' can be modified by the 'scrollopt' option.
  152. When using the scrollbars, the binding only happens when scrolling the window
  153. with focus (where the cursor is). You can use this to avoid scroll-binding
  154. for a moment without resetting options.
  155. When a window also has the 'diff' option set, the scroll-binding uses the
  156. differences between the two buffers to synchronize the position precisely.
  157. Otherwise the following method is used.
  158. *scrollbind-relative*
  159. Each 'scrollbind' window keeps track of its "relative offset," which can be
  160. thought of as the difference between the current window's vertical scroll
  161. position and the other window's vertical scroll position. When one of the
  162. 'scrollbind' windows is asked to vertically scroll past the beginning or end
  163. limit of its text, the window no longer scrolls, but remembers how far past
  164. the limit it wishes to be. The window keeps this information so that it can
  165. maintain the same relative offset, regardless of its being asked to scroll
  166. past its buffer's limits.
  167. However, if a 'scrollbind' window that has a relative offset that is past its
  168. buffer's limits is given the cursor focus, the other 'scrollbind' windows must
  169. jump to a location where the current window's relative offset is valid. This
  170. behavior can be changed by clearing the "jump" flag from the 'scrollopt'
  171. option.
  172. *syncbind* *:syncbind* *:sync*
  173. :syncbind Force all 'scrollbind' windows to have the same
  174. relative offset. I.e., when any of the 'scrollbind'
  175. windows is scrolled to the top of its buffer, all of
  176. the 'scrollbind' windows will also be at the top of
  177. their buffers.
  178. *scrollbind-quickadj*
  179. The 'scrollbind' flag is meaningful when using keyboard commands to vertically
  180. scroll a window, and also meaningful when using the vertical scrollbar of the
  181. window which has the cursor focus. However, when using the vertical scrollbar
  182. of a window which doesn't have the cursor focus, 'scrollbind' is ignored.
  183. This allows quick adjustment of the relative offset of 'scrollbind' windows.
  184. ==============================================================================
  185. 6. Scrolling with a mouse wheel *scroll-mouse-wheel*
  186. When your mouse has a scroll wheel, it should work with Nvim in the GUI and
  187. any terminal that has mouse support. By default only vertical scroll wheels
  188. are supported, but some GUIs also support horizontal scroll wheels.
  189. Note that horizontal scrolling only works if 'nowrap' is set. Also, unless
  190. the "h" flag in 'guioptions' is set, the cursor moves to the longest visible
  191. line if the cursor line is about to be scrolled off the screen (similarly to
  192. how the horizontal scrollbar works).
  193. You can control the number of lines / columns to scroll by using the
  194. 'mousescroll' option. You can also modify the default behavior by mapping
  195. the keys. For example, to scroll a page at a time in normal mode: >
  196. :map <ScrollWheelUp> <C-B>
  197. :map <ScrollWheelDown> <C-F>
  198. Scroll keys can also be combined with modifiers such as Shift, Ctrl, and Alt.
  199. When scrolling with a mouse, the window currently under the cursor is
  200. scrolled. This allows you to scroll inactive windows. Note that when scroll
  201. keys are remapped to keyboard keys, the active window is affected regardless
  202. of the current cursor position.
  203. vim:tw=78:ts=8:noet:ft=help:norl: