Three Vim Features
Yufan Lou

Yufan Lou @louy2

About: Learning Rust and Haskell, tired of JavaScript. Thinks Ruby is awesome except that it is not cross-platform enough. 日本語 / 中文 OK. He/him.

Location:
NYC, NY, US
Joined:
Oct 29, 2019

Three Vim Features

Publish Date: Jul 18 '20
9 0

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>+

Comments 0 total

    Add comment