tags:

views:

154

answers:

1

Hello vimmers,

reading up on some vim tips, I came across :r!{command} and :.!{command}, both of which take the output of the shell <command> and put it in the current buffer. I imagine the 'r' to stand for 'read', but how am I to 'translate' the dot in the command above?

And: do they have the exact same function?

Thanks a lot for your insights!

Guba

+16  A: 

The dot is a region, referring to the current line. The ! then takes this region and pipes it through the command.

So, for example, if you do:

:.!rev

You'll reverse the order of characters in the current line.

Of course, if you use a command that ignores its input, you'll just replace the current line with whatever the output is.

:r!, on the other hand, inserts the output after the current line, without removing the current line's text.

bdonlan
Brilliant! Cheers for the quick and precise reply!
Guba
:.r! not work for me. It don't takes line and pipes this to command.
lionbest
lionbest, please note that no mention was made of :.r! . It's either :.!{command} or :r!{command}.
Guba