The help says that virtual replace mode commands in Vim gr & GR replace characters in screen estate and not in file.

:help Virtual-Replace-mode

I am understanding this as something like changing the characters on the display but not in the buffer itself. Is that right? It seems incorrect.

I can use an explanation and probably a scenario or an example where this feature is relevant.

migrated from serverfault.com May 24 '13 at 12:19

This question came from our site for system and network administrators.


In Virtual-Replace-Mode the Buffer is harder fixed to its origin position.

1. Hello World
         ^ Cursor
2. I like cheese
3. And beer

When entering normal replace mode and hitting Internet<CR>And others the new buffer will be like this:

1. Hello Internet
2. And others
3. I like cheese
4. And beer

When doing the same in Virtual-Replace the result will be

1. Hello Internet
2. And othersese
3. And beer

Another example (tabstop=2;sts=0):

1. 012345678901234567890
2. Hello beautiful World
         ^ Cursor

Pressed keys: <Tab><Tab>

Replace-Mode result:

1. 012345678901234567890
2. Hello     autiful World

Virtual-Replace-Mode result:

1. 012345678901234567890
2. Hello     tiful World

Because in Replace mode the replacement is done char by char, where Tab is one char, no matter how many chars are displayed. In Virtual-Replace-Mode visible length of the Tab (:h 'ts', :h 'sts') is used to replace the chars.

  • (Did any characters get eaten up by comment formatting, some quoted strings look like they miss text, to me). Anyway, the last paragraph helped a lot. Im pretty sure I get it now :) Thanks a ton @krissi ! – sri May 24 '13 at 13:08

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.