1

According to :help v a count of 1 provided to v will select the same number of characters as the previous selection, but starting from the current cursor (see full help below). When there was no previous selection, it will select count characters. Is it possible to reset this count to obtain the default behaviour?

[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].
            When the previous Visual operation was on a block both
            the width and height of the block are multiplied by
            [count].
            When there was no previous Visual operation [count]
            characters are selected.  This is like moving the
            cursor right N * [count] characters.  One less when
            'selection' is not "exclusive".
  • By "default behavior" you mean if you have a previous selection of 5 char and use 2v you want to select 2 chars instead of 2x5=10 chars? – statox Nov 29 '17 at 10:51
  • That is exactly what I mean yes. I don't really see the use-case for quickly selecting 5x2 characters (or lines etc.), but I regularly find myself wanting to select a number of lines using e.g. 2V. – Octaviour Nov 30 '17 at 13:26
  • I see I wasn't sure I understood correctly. I can't think of a better answer than Rich's one actually. – statox Nov 30 '17 at 14:16
2

One easy way to workaround this would be by typing:

v"_y

This will yank a single character into the black hole register. Therefore, it's only effect is to reset the visual count to 1.

Specifying the blackhole register with "_ isn't strictly necessary, but it prevents the operation from affecting your registers.

Note that setting the visual count to 1 only has the desired effect if 'selection' is not set to exclusive. (Its default value is inclusive.) If 'selection' is set to exclusive, then your subsequent [count]v operation will still select [count] characters, which for selection=exclusive is one too few.

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.