4

After I visually select the following area enter image description here

And press Esc and move this position enter image description here

I want to be able to select the same shape in this manner enter image description here

If there is no generic and direct way to do this, any tips on how to code a vimscript function for this will also be helpful.

8

Yes, this feature is there, but it's a bit hidden. From :help v:

[count]v            Start Visual mode per character.
                    With [count] select the same number of characters or
                    lines as used for the last Visual operation, but at
                    the current cursor position, multiplied by [count].

So, if you specify a count of 1 (1v), the same number of character as the last selection had is used, but at the current cursor position.

  • This sort of works, but only "saves" the number of characters if you perform a visual operation. If you escape Visual Mode without performing an operation (yank, for example), it does not retain the character count. – Zach Thacker Sep 30 '16 at 17:49
  • It works as described by @SirBraneDamuj. Is it possible to get the same functionality without performing an operation as well? – vimKoans44 Oct 1 '16 at 7:51
  • You could perform a null operation to force the "save". For example "_y – joeytwiddle Oct 2 '16 at 9:02

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.