Live data from Hacker News

Pasting Text Into Vim

stackoverflow.com

31–38 of 38 posts

Re: Pasting Text Into Vim

#31
post #2

"I'd like to paste yanked text into Vim command line." While the top voted answer is very complete, I prefer editing the command history. In normal mode, type: q: This will give you a list of recent commands, editable and searchable with normal vim commands. You'll start on a blank command line at the bottom. For the exact thing that the article asks, pasting a yanked line (or yanked anything) into a command line, ya…

Holy mother of god, this is one amazing tip. I never knew about this mode. Thank you for sharing!

Re: Pasting Text Into Vim

#34
post #11

You can also yank from Vim to the system clipboard with "+y Took me a year or so to learn that one

Of course it only works for non-terminal vim. Someone may make it work on Mac though by leveraging pb{copy,paste} in some clever way (can't remember the X11 equivalent ATM)

The X11 equivalents are:

    pbcopy = xsel -bi
    pbpaste = xsel -b

Re: Pasting Text Into Vim

#35
post #6
post #2

"I'd like to paste yanked text into Vim command line." While the top voted answer is very complete, I prefer editing the command history. In normal mode, type: q: This will give you a list of recent commands, editable and searchable with normal vim commands. You'll start on a blank command line at the bottom. For the exact thing that the article asks, pasting a yanked line (or yanked anything) into a command line, ya…

Oh this is what that is! I accidentally reach this mode now and then and wonder how I got there and what it does. I must be accidentally pressing q: instead of :q ! This is great and useful. Thanks!

You can get to search history mode this way too. E.g.:

  q/ - Search string history
  q: - Ex cmdline history
  q? - Search string history
Also note that if you normally use Ctrl-C to exit Insert mode, that fails here as Ctrl-C will close the history buffer. You need to use Escape or Ctrl-[.

Re: Pasting Text Into Vim

#36
post #2

"I'd like to paste yanked text into Vim command line." While the top voted answer is very complete, I prefer editing the command history. In normal mode, type: q: This will give you a list of recent commands, editable and searchable with normal vim commands. You'll start on a blank command line at the bottom. For the exact thing that the article asks, pasting a yanked line (or yanked anything) into a command line, ya…

another way to get into this mode is to start doing a complex command.. so :%s/ and when you realise it's not as simple as you first thought.. doing ^f will take you "command line" buffer where you can do all the normal vim commands.. as for copy/paste .. if your vim is compiled with the option "+clipboard" then you can use the "+" register to interact with all your system copy/pasting.. however, what I most frequent…

You, sir, are a genius and a scholar.

Do you have any idea how many tutorials there are out there that involve some kind of obscure plugin or xclip incantation for something as simple as pasting text over ssh with formatting?

To think all I needed to do was :set paste... Extraordinary.

Re: Pasting Text Into Vim

#38
post #7

You can also yank from Vim to the system clipboard with "+y Took me a year or so to learn that one

Or, you can add this to your vimrc to always yank to system clipboard: set clipboard+=unnamed

A very helpful setting. Thanks!

I've been using the "+ register intensively. Your tip will save me from quite a lot of keystrokes in the future.

Post reply on HN