任何更快的导航技巧都可以将当前光标所在的行放置到屏幕顶部
屏幕的中心吗?
底部的屏幕?


#1 楼

z<CR>zt将当前行置于屏幕顶部(<CR> == Enter)

z.zz将当前行置于屏幕中心

z-zb将当前行置于屏幕底部屏幕的

z<CR>z.z-将光标置于第一行非空白列中。ztzzzb将光标置于当前列中)

更多有关在http://vimdoc.sourceforge.net/htmldoc/scroll.html

中滚动的信息,在vim类型:help scroll-cursor

评论


您也可以使用zz代替z。

– evilsoup
2014年1月21日在20:47

我没听说过z。之前。我想我更喜欢用两个不同的键来敲击而不是双击。您可以同时进行并行击键,只要它们以正确的顺序降落,并且击中之间的时间会很短,因此这是一个非常快速的选择。 z和。键是彼此的镜像(至少在我的en-GB键盘上)。您可以合理地选择双击z,这很好,我们有两个选择。

–德鲁·诺克斯(Drew Noakes)
17年4月29日在20:27



15年的vim,我不知道这个方便的小东西!赞!

– PnotNP
19年5月6日在21:39

z 会将行放在vim缓冲区的顶部,中心或底部的行号处。

– mljrg
20-2-19在10:59



检查滚动设置。如果scrolloff = 0,则仅将这些行放在屏幕的顶部或底部,否则光标之前或之后将出现scrolloff行。如果键入zz且当前行不在顶部,但当前行上方有行,则键入:se so = 0。请参见vimdoc.sourceforge.net/htmldoc/options.html#'scrolloff'。

–赫斯特教授
20-2-20在12:46

#2 楼

:help scroll-cursor @mtk的输出提及。请注意,zzz.之间存在区别。


相对于光标(滚动光标)滚动

以下命令重新放置编辑窗口的位置(该部分
看到的缓冲区的大小),同时将光标保持在同一行上:

z<CR>                   Redraw, line [count] at top of window (default
                        cursor line).  Put cursor at first non-blank in the
                        line.

zt                      Like "z<CR>", but leave the cursor in the same
                        column.  {not in Vi}

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.                      Redraw, line [count] at center of window (default
                        cursor line).  Put cursor at first non-blank in the
                        line.

zz                      Like "z.", but leave the cursor in the same column.
                        Careful: If caps-lock is on, this command becomes
                        "ZZ": write buffer and exit!  {not in Vi}

z-                      Redraw, line [count] at bottom of window (default
                        cursor line).  Put cursor at first non-blank in the
                        line.

zb                      Like "z-", but leave the cursor in the same column.
                        {not in Vi}


水平滚动(水平滚动)

对于以下四个命令,光标跟随屏幕。如果将光标所在的
字符移出屏幕,则光标将
移至屏幕上最近的字符。
未使用'sidescroll'的值。

z<Right>    or
zl                      Move the view on the text [count] characters to the
                        right, thus scroll the text [count] characters to the
                        left.  This only works when 'wrap' is off.  {not in
                        Vi}

z<Left>      or
zh                      Move the view on the text [count] characters to the
                        left, thus scroll the text [count] characters to the
                        right.  This only works when 'wrap' is off.  {not in
                        Vi}

zL                      Move the view on the text half a screenwidth to the
                        right, thus scroll the text half a screenwidth to the
                        left.  This only works when 'wrap' is off.  {not in
                        Vi}

zH                      Move the view on the text half a screenwidth to the
                        left, thus scroll the text half a screenwidth to the
                        right.  This only works when 'wrap' is off.  {not in
                        Vi}


对于以下两个命令,光标不在文本中移动,仅
文本在屏幕上滚动。

zs                      Scroll the text horizontally to position the cursor
                        at the start (left side) of the screen.  This only
                        works when 'wrap' is off.  {not in Vi}

ze                      Scroll the text horizontally to position the cursor
                        at the end (right side) of the screen.  This only
                        works when 'wrap' is off.  {not in Vi}