zhuang@linux:~/reading/practical-vim/10-copy-and-paste/$ less

Practical Vim / chapter 10

Copy and Paste

$ grep tags 10-copy-and-paste.md

This post extracts some knowledge from Chapter 10 – Copy and Paste.

The xp commands can be considered as transpose the next two characters.

We can specify which register we want to use by prefixing the command with "{register}.

"ayiw yanks the current word into register a. "bdd cuts the current line into register b.

"" - the unnamed register "0 - the yanked register "_ - the black hole register, Vim deletes the specified text without saving a copy of it. "+ - the system clipboard "* - the selection register, primary Selection "% - the name of the current buffer/file

When we address a named register with a lowercase letter, it overwrites the specified register, whereas when we use an uppercase letter, it appends to the specified register.

If we use the cut or copy command to capture text in an external application, then we can paste it inside Vim using "+p command (or <C-r>+ from the Insert mode). Conversely, if we prefix Vim’s yank or delete commands with "+, the specified text will be captured in the system clipboard. That means we can easily paste it inside other applications.

The X11 windowing system has a second kind of clipboard called the primary.

From Insert mode, we can insert the contents of the unnamed register by pressing <C-r>", or we can insert the contents of the yank register by pressing <C-r>0.

zhuang@linux:~/reading/practical-vim/10-copy-and-paste/$ comments