How to paste from multiple clipboards vim without leaving insert mode?

8

5

Suppose you are typing in vim and there are 5 common expressions that you need to insert into the text over and over.

Is there a way you can tell vim to paste from multiple clipboards without leaving insert mode?

dggoldst

Posted 2009-08-12T10:36:38.633

Reputation: 2 372

Answers

20

ctrl-r follwed by the register lets you paste the contents of a register without leaving insert mode.

Ctrl + r" Put from the default register

Ctrl + rd Put from register d

By the way, in vim they're called "registers" not "clipboards" and the verb is "put", not "paste". (Reminder, to get a visual selection into register d, you would use "dy)

dggoldst

Posted 2009-08-12T10:36:38.633

Reputation: 2 372

This is great! Also, how did you format text to look like keyboard buttons? I looked for something in the FAQs on SuperUser markdown but didn't find it. – Nathan Long – 2010-04-08T11:01:01.250

1Try with <kbd> tag. – danadam – 2010-09-03T13:12:12.797

2

Do you need those expressions to come from clipboards?

You can easily do something like this:

:iab some_unique_string foo bar baz

And vim will replace "some_unique_string" with "foo bar baz" as soon as you enter it in insert mode.

innaM

Posted 2009-08-12T10:36:38.633

Reputation: 9 208

1

If its always the same expressions, e.g. in java programming things like "private static void main(String... args)" you can use a plugin like snipmate. You can configure it so you can just type "main<Tab>" and it will exapnd to the long java code needed, and it has more cool features...

c089

Posted 2009-08-12T10:36:38.633

Reputation: 978