I want to understand how the alt key behaves on terminals.
From some reading it appears that the “meta key” has been replaced on modern systems with sending Esc+ instead, why is that? What is the difference between meta and Esc+?
Is there a difference between what mac does vs what linux does when you hit the alt key?
Here is some discussion related to being unable to map the meta-modifier in vim because of what I’m pointing out here:
The Alt key typically prefixes the sent symbol with the
Esc character, e.g. pressing Alt+x generates the
0x1B) byte followed by
As far as I know, traditionally the Meta key used to set the high bit, e.g. Meta+x used to generate the byte
0x78 + the 8th bit is
0xF8). Or maybe there used to be two different popular configurations for the Meta key: setting the 8th bit, as well emitting an
Then two things happened.
One is that today’s computers no longer have a physical Meta key, so in terminal emulators running on PCs the Alt key took its role.
The other is that with the widespread adoption of Unicode (UTF-8), setting the high bit no longer makes any sense; in fact, conflicts with the encoding of pretty much any non-English letter. Applications expect the terminal to send valid UTF-8, and flipping the 8th bit would break this.
That’s how terminals ended up with the current situation of Alt (or possibly Option on Mac) emitting an