4

I am using gvim 7.3 on Windows 7 64 bit Professional. Within vim I can type :version to get information about my vim installation. How can I copy this version information to the clipboard?

2 Answers 2

9
:redir @+> | version | redir END

Unlike @Gareth McCaughan solution this will send :version output directly to clipboard register.

4
  • Oh, nice. I didn't know about redir @+>. Apr 6, 2011 at 17:27
  • Big 'woah' moment there. That is one underrated obscure vim feature.
    – sehe
    Apr 6, 2011 at 19:27
  • 1
    @sehe This feature should be omitted in scripts whenever possible: there are no nested redirections, so any new redirection will override existing one.
    – ZyX
    Apr 6, 2011 at 20:38
  • Yeah, but it beats the crap out of e.g. let @a="" | g/buf/silent! -1,+2 yank A to get stuff into registers
    – sehe
    Apr 6, 2011 at 20:55
1
:redir > C:\path\to\my\file.txt
:version
:redir END

and then open the file and copy the data from there. If you need to do it automagically in a Vim script, you can make Vim read the file into a buffer and copy the contents into the + register. That's more work, though, and I suspect you want this for a one-off purpose for which doing it manually will suffice.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.