When I use R and gR in vim where there are tabs, I don't notice the difference. According to Practical Vim,

Virtual Replace mode is triggered with gR and treats the tab character as though it consisted of spaces. Suppose that we position the cursor on a tab stop spanning eight columns of screen real estate. If we switch to Virtual Replace mode, we could type up to seven characters, each of which would be inserted in front of the tab character.

But I can type exactly the same in R as well.

What are the difference between R and gR?

  • 1
    You may not notice a difference if you have 'expandtab' set. – Heptite Jan 22 '14 at 1:34

R and gR do work as documented.

Let's say you have a file with the following content


and use the default tabstop (8 characters).

If you edit this file, put the cursor on the first column and enter Rxyesc, you end up with this content:


The x replaced the first tab while the y replaced the a.

On the other hand, if you enter gRxyesc, you end up with that one:


The reason being you inserted 2 characters so stayed withing the first eight columns tab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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