首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在VIM中,为什么光标会随着4yk而不是4yj移动?

在VIM中,为什么光标会随着4yk而不是4yj移动?
EN

Stack Overflow用户
提问于 2018-06-10 10:38:26
回答 2查看 127关注 0票数 4

要从当前位置+当前行向上拉4行,可以使用4yk;要从当前位置+当前行向下拉4行,可以使用4yj

但是4yk可以移动光标,而4yj不能(至少在我使用的vim版本中是neovim)。

为什么会这样呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-06-10 15:21:35

光标移动到运动的第一行。

对于4yk (或任何类似的向上运动),运动的第一行与当前行不同,因此光标会移动。

对于4yj (或任何类似的向下运动),运动的第一行是当前行,因此光标不会移动。

来自:help operator

代码语言:javascript
复制
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.
票数 5
EN

Stack Overflow用户

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50780122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档