Use of g key in vim normal mode

Vim

Vim Problem Overview


In vim's normal mode, the g prefix is used for a number of commands. Some commands go somewhere in the document, but other commands deal with file encodings and swapping upper/lower case letters.

  • ga - show character encoding
  • 10gg - go to line 10
  • gg - go to line 1
  • gH - start Select line mode
  • gr{char} - virtual replace N chars with {char}

What is the missing connection between all these commands?

Vim Solutions


Solution 1 - Vim

There's no greater connection to g-commands: it's a mixed bunch. It is an easy prefix and the unbound keys were getting extinct so the less-used maps found a good place behind g.

Solution 2 - Vim

Simply you're talking about two different things. In some cases g is the short way of "global" (for range command for example), for line moving the g stands for goto.

In VIM commands are often shortened for quick of use.

:help global may help

Btw: for line navigation I've always used the :<lineno> syntax.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNatan YellinView Question on Stackoverflow
Solution 1 - Vimmike3996View Answer on Stackoverflow
Solution 2 - VimBigMikeView Answer on Stackoverflow