Live data from Hacker News

Pasting in command line Vim doesn't have to suck

userobsessed.net

31–34 of 34 posts

Re: Pasting in command line Vim doesn't have to suck

#31
post #2

... and I thought it was how to paste in vim commandline after :

ctrl-r pastes that register into your command. So I often need to find "where is this method defined" across a large project. yw (yank word to get method into the " register) :Ack " (ack plugin, paste that default " register) yay! I found it. Alternately: /foo (attempt to find foo in this file. Whoops, not there, where is it!). :Ack / (last search is in the / register). There it is!

wow! this is exactly what i was looking for. thank you.

Re: Pasting in command line Vim doesn't have to suck

#33

Another method I sometimes use for pasting large blocks of code: :r !cat (paste your stuff) ctrl - D Doesn't require any switching between paste modes.

Nice idea, and you can replace cat if you need to clean up the paste:

    :r!perltidy
    (paste coworker's ugly perl code)
    ctrl-D
and you have nice looking code pasted.

Re: Pasting in command line Vim doesn't have to suck

#34
perhaps, I'm forgetting something, but these solutions seem overly complicated.

I just have this in my .vimrc, and pasting (with formatting), is as simple as copying text, going to vim and hitting 'p' in command mode.

  for middle-click (system) clipboard:
    :set clipboard=unnamed
  for ctrl-c (X11) clipboard:
    :set clipboard=unnamedplus

  couple caveats:
  * +xterm_clipboard
  * 'unnamedplus' is only for >= 7.3.74 
see here for more info http://vim.wikia.com/wiki/Accessing_the_system_clipboard

note: I used unnamedplus for a bit, but found it to be much less desirable than using the unnamed middle-click buffer...YMMV

Post reply on HN