要从当前位置+当前行向上拉4行,可以使用4yk
;要从当前位置+当前行向下拉4行,可以使用4yj
但是4yk
可以移动光标,而4yj
不能(至少在我使用的vim版本中是neovim)。
为什么会这样呢?
发布于 2018-06-10 15:21:35
光标移动到运动的第一行。
对于4yk
(或任何类似的向上运动),运动的第一行与当前行不同,因此光标会移动。
对于4yj
(或任何类似的向下运动),运动的第一行是当前行,因此光标不会移动。
来自:help operator
After applying the operator the cursor is mostly left at the start of the text
that was operated upon. For example, "yfe" doesn't move the cursor, but "yFe"
moves the cursor leftwards to the "e" where the yank started.
发布于 2018-06-25 02:02:11
为了向下拉,你所问的最好的解决方案是4yy
。这样,它拉出4行,加上它考虑到了任何CRs,所以如果你放在两行之间,它会为你放的任何东西腾出空间。例如:1 Shall I compare thee to a summer's day? 2 Thou art more lovely and more temperate: 3 Rough winds do shake the darling buds of May, 4 And summer's lease hath all too short a date: 5 Sometime too hot the eye of heaven shines, 6 And often is his gold complexion dimm'd; 7 And every fair from fair sometime declines, 8 By chance, or nature's changing course, untrimm'd; 9 But thy eternal summer shall not fade 10 Nor lose possession of that fair thou ow'st; 11 Nor shall Death brag thou wander'st in his shade, 12 When in eternal lines to time thou grow'st; 13 So long as men can breathe or eyes can see, 14 So long lives this, and this gives life to thee.
假设您的光标位于第5行,执行4yy
操作时,它将向下拉出4行。然后,如果(例如)转到第12行,然后按p
(或转到第13行,然后按P
,capital),您将得到:1 Shall I compare thee to a summer's day? 2 Thou art more lovely and more temperate: 3 Rough winds do shake the darling buds of May, 4 And summer's lease hath all too short a date: 5 Sometime too hot the eye of heaven shines, 6 And often is his gold complexion dimm'd; 7 And every fair from fair sometime declines, 8 By chance, or nature's changing course, untrimm'd; 9 But thy eternal summer shall not fade 10 Nor lose possession of that fair thou ow'st; 11 Nor shall Death brag thou wander'st in his shade, 12 When in eternal lines to time thou grow'st; 13 **Sometime too hot the eye of heaven shines,** 14 **And often is his gold complexion dimm'd;** 15 **And every fair from fair sometime declines,** 16 **By chance, or nature's changing course, untrimm'd;** 17 So long as men can breathe or eyes can see, 18 So long lives this, and this gives life to thee.
(星号显然是我的)。
4yj
实际上没有做任何事情,因为正如romainl所说的,第一条运动直线是当前直线,所以光标不会移动。这就是为什么你必须使用4yy
而不是4yj
。
https://stackoverflow.com/questions/50780122
复制相似问题