what is the difference between :.! and :r!?

Tag: vim Author: kuaiji0107 Date: 2009-07-21

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!


Perhaps this should go to superuser, since it's a user question not programming? [@Guba, don't worry about moving it, it'll happen automatically if need be. The beta password is at , don't forget to link your account, see ]

Best Answer

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:


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.


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