News for hackers. Stuff that matters.
Re:Mastering Bash and Terminal by u801e on Saturday January 14, 2017 @05:10PM (#13400863)
> I didn't know about :r in combination with !

You can even use :w in combination with !. For example

    :w !xclip
to write the vim buffer contents to the clipboard. You could visually highlight part of the buffer and do the same thing for just the text you want.
Re:Mastering Bash and Terminal by EvilTerran on Saturday January 14, 2017 @05:49PM (#13401052)
This is also useful for iterating on a throw-away script - something too long to type on one line in the shell, but not significant enough to be worth saving to a file. Put it together in an unnamed buffer, and ":w !" it to the relevant interpreter (eg ":w !perl") whenever you want to run it.
Re:Mastering Bash and Terminal by dotancohen on Sunday January 15, 2017 @02:10AM (#13402788)
Though I understand that this is just an example of the power of `!r`, readers should know that VIM in fact can copy to the system clipboards natively.

    "*y
    "+y
Re:Mastering Bash and Terminal by jacobmischka on Sunday January 15, 2017 @02:31AM (#13402851)
Only if it's compiled with clipboard support. I don't know about in other places, but in the default Arch package it's not. So this command is a perfect solution for me.
Re:Mastering Bash and Terminal by Kubuxu on Sunday January 15, 2017 @07:23AM (#13403700)
You need to install `gvim` which provides `vim` with that feature.
Re:Mastering Bash and Terminal by u801e on Sunday January 15, 2017 @02:36AM (#13402868)
That requires that vim be compiled with the xterm-clipboard feature enabled. On my Fedora 24 desktop, vim doesn't have it enabled, but gvim does (according to the output of the :version command).

One advantage of the method you describe is that it can be limited to just part of a line. Piping output to xclip is limited to complete lines of text due to the nature of :w !.

Re:Mastering Bash and Terminal by ves on Saturday January 14, 2017 @07:51PM (#13401625)
for osx peeps: `:w !pbcopy`