在 Vi 中移动到行尾字符,超过行中的最后一个字符
为什么在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
因为这足以满足您想要实现的任何目标。
您基本上永远不需要。您只需在下一步中执行不同的操作,具体取决于您想要通过换行符实现的目标。例如。:
只需按
J
到 j 即可。 (如果您启用了autoindent
或朋友,它甚至会为您删除连接行中的缩进。)如果您不想,请跟进x
您刚刚获得的额外空格字符;或使用gJ
开始。Because that’s sufficient for anything you might want to achieve.
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.:
Just hit
J
to join the lines. (If you haveautoindent
or friends enabled, that will even take care of removing indentation from the joined line for you.) Follow up with anx
if you didn’t want the extra space character you just got; or usegJ
to begin with, instead.您可以使用序列“
A
Del
ESC
”从一行中删除换行符。更多信息可以在这里找到:
http://www.lagmonster.org/docs/vi.html
You could use the sequence '
A
Del
ESC
' to delete the newline character from a line.more information can be found here:
http://www.lagmonster.org/docs/vi.html
令人烦恼的是,当你学习 vi/vim 时,大多数人都会告诉你输入
"i"
来启动插入模式,但几乎所有人都跳过告诉你什么是基本的“编辑”,因为其他人如何编辑们这样做。 (很多人直到太晚才意识到这一点,也许羞于在公共场合承认,我没有)在命令模式下,你继续找到光标闪烁的位置/字符,然后你会得到 3 个编辑选择:
"i"
- 在该字符之前编辑(插入,继续编辑,直到按 ESC)"r"
- 在该字符处编辑(替换,一次性操作,返回到立即命令模式 )"a"
- 在该字符后编辑(追加,继续编辑直到按下 ESC),因此,使用
"l"
,"$"< /code> 或
"END"
键仅带您到最后一个字符。在那里,你决定编辑的命运,在我们这里的情况下继续编辑是“a”
。剩下的部分就是编辑完成后按ESC键。编辑:添加到
i,r,a
中,还可以通过SHIFT
或CAPS LOCK
使用它们的大写版本。I
- 跳转到行首并开始插入直到 ESCR
- 开始连续替换直到 ESCA
- 跳转到行尾 在这个问题的情况下,在最后一个字符后面的行并开始附加直到 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, bySHIFT
orCAPS LOCK
.I
- jump to the beginning of the line and start inserting until ESCR
- start continuously replacing until ESCA
- jump to the end of the line after the last character and start appending until ESChere in the situation of this question,
A
would be much preferable.