Copy and Paste

category applies to 7 screencasts and 3 articles:

To the newcomer, Vim’s way of doing things may seem strange, but with familiarity it becomes natural. Many of Vim’s features seemed odd to me at first, but when I got used to them I recognised that they had their own particular elegance. However, there’s one feature of Vim that still feels awkward to me: using registers for copy and paste. The deeper my understanding of registers becomes, the more they frustrate me!

Continue reading

The copy/paste series - a retrospective

Episodes 51, 52, 53, 54, 55, 58, and 59 are all on the topic of copy and paste in Vim. I think that this is one area where Vim is especially confusing, partly because of Vim’s non-standard jargon for cut, copy and paste operations. It’s not the most intuitive copy/paste system, but it’s usable when you get the hang of certain concepts and techniques.

Continue reading
Run time:

When Vim is compiled without the +clipboard feature, we can still insert text from the clipboard using the system paste command (ctrl-v or cmd-v). This can produce strange effects, but we can avoid them by toggling the paste option each time we use the system paste command.

Watch screencast

Getting Vim with `+clipboard` support

Many systems ship with a version of Vim that was compiled with the -clipboard feature disabled, which is a damned nuisance! Being able to access the system clipboard from Vim is an essential feature. Let’s look at a few ways of getting the +clipboard feature on OS X and Ubuntu.

Continue reading
Run time:

In some environments, Vim lets us access the system clipboard using the quoteplus register, "+. When this feature is enabled, we can use it with the delete, yank and put operations in much the same way that we use Vim’s other registers. Pasting from this register usually produces better results than using the system paste command in Insert mode.

Watch screencast
Run time:

We don’t have to be in Normal mode to paste the contents of a register. The <C-r>{reg} command lets us paste a register from Insert mode (and it works in commandline mode too!) Using this command allows us to make changes that can be repeated with the dot command.

Watch screencast
Run time:

When used in Visual mode the p command replaces the selection with the contents of a register. This makes for a smooth workflow when you want to overwrite a selection, or swap the order of two regions of text.

Watch screencast
Run time:

We’ve met Vim’s default register and the yank register. This time, we’re going to look at the named registers, which are handy if you want to cut or copy some text that you intend to paste multiple times.

Watch screencast
Run time:

Vim’s default register is not a safe place to keep yanked text that you want to paste later. It’s all too easy to clobber the default register with a d or x command. Luckily, the last yanked text is kept safe in Vim’s yank register.

Watch screencast
Run time:

Vim’s default register makes it easy to perform some of the most basic types of cut, copy, and paste operations. That’s partly thanks to the p command, which behaves differently depending on whether the default register contains a characterwise or linewise region of text.

Watch screencast