0

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:

https://github.com/maxbrunsfeld/vim-yankstack/wiki/Linux-terminal-configurations-for-correct-meta-key-handling

https://github.com/neovim/neovim/issues/3412#issuecomment-174333178

1
  • Please post links where this is discussed by clicking edit
    – K7AAY
    Commented May 24, 2020 at 22:30

1 Answer 1

1

The Alt key typically prefixes the sent symbol with the Esc character, e.g. pressing Alt+x generates the Esc (0x1B) byte followed by x.

As far as I know, traditionally the Meta key used to set the high bit, e.g. Meta+x used to generate the byte 0xF8 (x = 0x78; 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 Esc prefix.

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 Esc prefix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .