This is an automated archive made by the Lemmit Bot.
The original was posted on /r/neovim by /u/hugelung on 2023-11-05 01:13:12.
Try :help g
to see some of the most bizarre/funny keymaps in vim. It’s just such a mishmash of random functionality, I feel like I’ll never have a firm grasp on what g
is for at all. Examples:
gs go to sleep for N seconds (default 1)
Uhh yeah, this one freezes your vim instance. You can do 5gs to make it freeze for 5 seconds. I have no clue why this would ever be a keymap let alone a feature. Maybe to prank other vim developers in the office?
g& 2 repeat last ":s" on all lines
Pretty niche kind of keybind…
g CTRL-H start Select block mode
I literally can’t figure out what SELECT BLOCK mode is. It’s not a visual select, it’s like for when you select a word with the mouse or something. You can add a number n at the start, and then it goes from doing nothing to doing something very weird (selecting from the current position to column 80 * n)
gH start Select line mode
This one is very similar, but selects a line by default instead of nothing. But behaves the same way when given a repeat number
g?? 2 Rot13 encode current line
g?g? 2 Rot13 encode current line
Why… and double why?
gf start editing the file whose name is under
the cursor
gF start editing the file whose name is under
the cursor and jump to the line number
following the filename.
Actually dope, pretty much makes it into a wiki
gm 1 go to character at middle of the screenline
gM 1 go to character at middle of the text line
Does anyone have a usecase for this? Some kind of niche ascii art feature?
g_CTRL-A g CTRL-A dump a memory profile
If it dumps it, I can’t tell where
gI 2 like "I", but always start in column 1
gJ 2 join lines without inserting space
Weird but kinda useful alternates for common commands
g CTRL-G show information about current cursor
position
ga print ascii value of character under the
cursor
I actually use these all the time, great features
Anyway, hope you learned something fun, trolling the junkyard of g
. Yes, it’s a total mess, and I’m sure if we could have a do-over, garbage like rot13 would be a plugin