A Vim yellow-belt is bestowed upon a pupil after they use their first g command.

We will begin our foray of g commands with an examination of ga. It is common among the white-belts and black-belts alike to try and remember the g commands with a mnemonic, and given that ga === :ascii perhaps “Get Ascii” can work. It isn’t that bad, but It also isn’t that good… I spent 30 seconds of my life without coming up with something better than that though, so that’s what is getting left there.

Let’s start with an example, foo.json:

{
    "apple": 1,
    "banana": 2,
    "cat": 3
}

When I run :%!jq -r_ within foo.json I get the following error message “jq: parse error: Invalid numeric literal at line 2, column 6”. Well… line 2 column 6 don’t look like no invalid numeric literal to me! Let’s pretend to be Nancy Drew and pull out our investigative toolkit and inspect that character with ga.

Hint: To capture output from a command into a register for reuse at a later point you can utilize the following:

  • navigate to line 2 column 6
  • :let @a = execute('ascii')
  • navigate to line 2 column 5 for comparison
  • :let @c = execute('ascii')

Now lets see who’s really hiding under that character!

  • Register a) < > 160, Hex 00a0, Oct 240, Digr NS
  • Register c) < > 32, Hex 20, Oct 040, Digr SP

It’s Non-Breaking Space! That means our poor developer probably copied something out of a Microsoft Teams message!

“And I would have gotten away with it too if it weren’t for those meddling g commands!”

{
    "apple": 1,
    "banana": 2,
    "cat": 3
}

ga can find use outside of playing detective, it is also a way to see if a digraph is set for a certain non-standard character. A digraph I have setup is 🤮 (yes, you can set emojis up in digraphs how cool is that?!). In order to see what digraph that is set to, I can just navigate my cursor over it and use ga which shows that I have it set to pu:

<🤮> 129326, Hex 0001f92e, Oct 374456, Digr pu