Move to the end of line character in Vi, past the last character in the line

喜夏-厌秋 提交于 2020-01-02 01:54:09

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/3664924/move-to-the-end-of-line-character-in-vi-past-the-last-character-in-the-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!