6

I am confused about how the start visual commands work when you pass them a count. I checked the help page but I am still confused.

[count]V                Start Visual mode linewise.
                        With [count] select the same number of lines as used
                        for the last Visual operation, but at the current
                        cursor position, multiplied by [count].  When there
                        was no previous Visual operation [count] lines are
                        selected.

I want to know what [count]v, [count]V and [count]CTRL-V does and when it is useful to pass [count] to the start visual selection commands.

5

You can see what it does for yourself by performing an operation on a 1 character selection.

vy3v<esc>5v

In that command, you select 1 character and yanked it. Typing 3v causes the 3 characters starting from the cursor to be selected. Typing <esc>5v causes the 5 characters starting from the cursor to be selected. This visual selection operates per-character.

<c-v>y3v<esc>5v

This one will help if you have a large block of text. This works just like the previous one, but in visual-block mode. You started by yanking a 1x1 grid of characters, then typed 3v which selected a 3x3 grid of characters (starting from the cursor), and then selected a 5x5 grid.

Explaining the line-wise [count]V would be repetitive at this point. However, using [count]v where the last operation involved multiple lines works a little bit differently than the first example:

Lorem ipsum dolor sit amet, consetetur
sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna
aliquyam erat, sed diam voluptua.

Starting from 1,1, typing vjey will yank from 1,1 to 2,10. Typing w2v afterwards will select from 1,1 to 4,10. Instead of selecting 2x the characters, it's 2x lines except the last line will always end on the same column regardless of the starting line's column.

when it is useful to pass [count] to the start visual selection commands.

I never needed to use a [count]v in the past, but I imagine it has its uses when dealing with symmetrical text or in macros/scripting. [count]V and [count]<c-v> seem to be the most useful from a user perspective, though.

There is a unit test for this feature in test94.in, but the tests don't look like something I would consider to be practical for daily use.

If you find a useful workflow using [count]v be sure to share it 😊

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.