Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

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

like image 446
Guba Avatar asked Aug 06 '09 17:08

Guba


1 Answers

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.

like image 79
bdonlan Avatar answered Oct 26 '22 23:10

bdonlan