DEV Community

Yufan Lou
Yufan Lou

Posted on

3 1

Three Vim Features

To split a line at pattern:

 :5s/pattern/<c-v><cr>/g

<c-v>, or Ctrl-v, in terminal waits for the next character, and inserts it as a literal (verbatim). So upon pressing <cr> (carriage return a.k.a enter key), instead of executing the command, the literal carriage return character (would be shown as ^M) is inserted at the cursor, which is then replaced into the file.

^M is the caret notation of carriage return. Other control characters can be similarly inserted with their corresponding key in the caret notation. For example, cancel is ^Z, so to insert it type

<c-v><c-z>

To copy the whole file into clipboard:

:%y+<cr>

To insert the content of a register, for example, clipboard:

<c-r>+

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay