在 Vi 中移动到行尾字符,超过行中的最后一个字符

发布于 2024-09-18 22:06:36 字数 92 浏览 10 评论 0原文

为什么在 Vi 中,当我点击 $ 时,它会转到行中的最后一个字符而不是行尾字符?如何通过一次按键到达行尾字符,以及删除行尾字符的最快方法是什么?

How come in Vi, when I hit $, it goes to the last character in the line instead of the end of the line character? How would I go to the end of the line character in one keystroke, and what is the fastest way to delete the end of the line character?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半暖夏伤 2024-09-25 22:06:36

为什么在 Vi 中,当我点击 $ 时,它会转到行中的最后一个字符而不是行尾字符?

因为这足以满足您想要实现的任何目标。

如何通过一次按键到达行字符的末尾

您基本上永远不需要。您只需在下一步中执行不同的操作,具体取决于您想要通过换行符实现的目标。例如。:

删除行尾字符最快的方法是什么?

只需按 Jj 即可。 (如果您启用了autoindent或朋友,它甚至会为您删除连接行中的缩进。)如果您不想,请跟进x您刚刚获得的额外空格字符;或使用 gJ 开始。

How come in Vi, when I hit $, it goes to the last character in the line instead of the end of the line character?

Because that’s sufficient for anything you might want to achieve.

How would I go to the end of the line character in one keystroke

You basically never need to. You just do different things in the next step depending on what you wanted to achieve by going to the newline character. Eg.:

what is the fastest way to delete the end of the line character?

Just hit J to join the lines. (If you have autoindent or friends enabled, that will even take care of removing indentation from the joined line for you.) Follow up with an x if you didn’t want the extra space character you just got; or use gJ to begin with, instead.

戏剧牡丹亭 2024-09-25 22:06:36

您可以使用序列“A Del ESC”从一行中删除换行符。

A:追加到行后

更多信息可以在这里找到:
http://www.lagmonster.org/docs/vi.html

You could use the sequence 'A Del ESC' to delete the newline character from a line.

A: Append after line

more information can be found here:
http://www.lagmonster.org/docs/vi.html

情魔剑神 2024-09-25 22:06:36

令人烦恼的是,当你学习 vi/vim 时,大多数人都会告诉你输入 "i" 来启动插入模式,但几乎所有人都跳过告诉你什么是基本的“编辑”,因为其他人如何编辑们这样做。 (很多人直到太晚才意识到这一点,也许羞于在公共场合承认,我没有)

在命令模式下,你继续找到光标闪烁的位置/字符,然后你会得到 3 个编辑选择:

  • "i" - 在该字符之前编辑(插入,继续编辑,直到按 ESC)
  • "r" - 在该字符处编辑(替换,一次性操作,返回到立即命令模式 )
  • "a" - 在该字符后编辑(追加,继续编辑直到按下 ESC),

因此,使用 "l", "$"< /code> 或 "END" 键仅带您到最后一个字符。在那里,你决定编辑的命运,在我们这里的情况下继续编辑是“a”。剩下的部分就是编辑完成后按ESC键。


编辑:添加到 i,r,a 中,还可以通过 SHIFTCAPS LOCK 使用它们的大写版本。

  • I - 跳转到行首并开始插入直到 ESC
  • R - 开始连续替换直到 ESC
  • A - 跳转到行尾 在这个问题的情况下,在最后一个字符后面的行并开始附加直到 ESC

A 会更好。

It is just annoying that when you learn vi/vim, most people out there tell you to type "i" to start insert mode, but almost all skip telling what is basic "editing" because of how other editors do it. (and many are not aware of this until too late, and maybe ashamed to admit in public, I am not)

in command mode, you go ahead and find a location/character where your cursor blinks, and you are given 3 editing choices:

  • "i" - edit before that character (insert, continue editing until you hit ESC)
  • "r" - edit at that character (replace, one-time action, returns to command mode immediately )
  • "a" - edit after that character (append, continue editing until you hit ESC)

so, using "l", "$" or "END" keys takes you only to the last character. there, you decide the fate of editing, and it is "a" to continue editing in the case we got here. the remaining part is to press ESC after editing is done.


EDIT: adding to i,r,a, it is also possible to use their capitalized versions, by SHIFT or CAPS LOCK.

  • I - jump to the beginning of the line and start inserting until ESC
  • R - start continuously replacing until ESC
  • A - jump to the end of the line after the last character and start appending until ESC

here in the situation of this question, A would be much preferable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文