0

Sometimes, ggVG does not work to select text. It will move the cursor to the top, but not select the text. This happens seemingly randomly. I have figured out if I type ggVVG it will work as expected. I can also retype ggVG many times and it will work eventually after 4-10 tries.

4
  • 4
    do you potentially type gggV? so accidentally using gV instead of V? Commented Aug 5 at 9:35
  • 1
    Are there mappings on V? :verbose map V
    – D. Ben Knoble
    Commented Aug 5 at 14:17
  • @D.BenKnoble There aren't any mappings on V. ("No mapping found")
    – BigMistake
    Commented Aug 5 at 14:59
  • 3
    @ChristianBrabandt I think that's it! I am able to replicate the behavior and it makes sense why it was happening seemingly randomly. Why does this happen? My cursor doesn't move when I press the third g, and it seems like odd-numbered "g" presses undo the ability to enter visual mode in one button press.
    – BigMistake
    Commented Aug 5 at 15:02

1 Answer 1

5

Make sure to not accidentally typing gggVG, so after gg (to go to the top), another g, which in turn changes your V command to a gV command (see :help gV), which basically is a no-op in your case and this would explain why your V command randomly does not appear to work.

BTW: depending on your use case for the ggVG command, it might be easier to use an ex-command. I assume you want to copy the whole buffer text, which I think :%y find much easier (for yank all lines).

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