Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
772 views
in Technique[技术] by (71.8m points)

emacs - How to add a new line without breaking the current line?

In vim, I can do this in command mode by typing 'o', which will add a new line below the cursor, and enter the insert mode.

Is there an equivalent in emacs?

question from:https://stackoverflow.com/questions/5898448/how-to-add-a-new-line-without-breaking-the-current-line

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The command C-o open-line that others have suggested is not quite the same as o in vi, because it splits the current line and lets the cursor remain in the current line.

You get the exact same effect as vi's o with two strokes: C-e RET, which moves the cursor to the end of the current line and then inserts a new line, which leaves the cursor at the beginning of that line.

You could bind that sequence to a key of its own (perhaps overriding the existing definition of C-o), but I doubt if it's worth the trouble.

(Incidentally, the symmetric sequence C-a RET gives you the effect of vi's capital O, inserting a line before the current line.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...