vim-like ctrl+v enter in Emacs

Suppose you have a list like this

foo, bar, baz, quux

in your Emacs buffer, but you’d rather have one element per line like this


What to do? In vim this is easy:


where ^M is inserted using


But what to do in Emacs? Turns out it’s just as easy but different (who would have thought …): You can insert the newline character in your replace-string or something other using the keyboard command

C-q C-j

C-q is somewhat like Ctrl-v in vim and C-j is Enter. Easy as pi, yeah!

See also the page Newline Representations ^M ^J ^L about related issues with newline in Emacs.

This entry was posted in Tools and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.