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 encoding10gg - go to line 10gg - go to line 1gH - start Select line modegr{char} - virtual replace N chars with {char}What is the missing connection between all these commands?
gg will move you to the first line in the file, and G will move you to the last line in the file. Alternatively, if you type nG where n is a number, you'll jump to that to that line.
g is a prefix to several commands. e.g. goto to move the cursor, but also gqip to format a paragraph.
By default, Vim starts in “normal” mode. Normal mode can be accessed from other modes by pressing Esc or <C-[> .
We can prefix the repeat factor with navigation keys (h, j, k and l). Explanation: The repeat factor can be used as a command prefix with all these four commands.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With