On Mon, Jun 08, 2020 at 02:28:05AM +0100, Dan Shearer wrote: > Some g commands are implemented, but incorrectly. Examples: > * g0 is equivalent to 0, rather than 'beginning of screen line when wrapped' > * g$ is equivalent to $, rather than 'end of screen line when wrapped' > > Other g commands are not implemented, just ignored. Examples: > * gM is ignored, rather than going to the middle of the line > * gE is ignored, rather than going to the end of the last word
Those are not standard vi commands, as far as I can tell. They appear to be vim extensions. I opened /usr/bin/vi on HP-UX 11i and typed a line that was longer than my terminal's width, and then tried these commands. They do not do what you describe. In real vi, in an 80-wide terminal, with a single line of 120 or so characters, and the cursor at position 40, g$ acts just like $. With the cursor now at the end of the line, g0 acts just like 0. gE acts just like E (moves to the end of the current word). gM acts just like M (moves to the start of the middle line, which happens to be the first line, because there's only one line). I see no evidence that 'g' is even a meaningful keystroke in real vi. Maybe that's why vim chose it as the prefix for so many of their extension commands.