Brain Phrye

code cooking diy fiction personal photos politics reviews tools 

The g command in vim

[ Listen to article ]

My knowledge of g in vi is kind of ironic. I first learned about it when I learned the etymology of grep. It was from the ed command g/re/p. Ed wasn’t a visual editor. You essentially kept the file in your head and then could bring it up line by line - and change it line by line - in an editor. So the g/re/p command was really useful because you could print all lines (p) that matched a pattern (re) over the entire file (g).

I found that interesting but nearly all my uses of g in vim are g/re/d. In other words instead of printing, I use it to delete lines.

So I found cks’s more considered exploration of g really interesting. Currently busy at FOSDEM so can’t explore too much. This post is a reminder to me to go explore later!