History
Article Edit this page Discussion

Get Alt key to work in terminal

From Vim Tips Wiki

Jump to: navigation, search

Tip 1129 Previous Next Created: February 12, 2006 Complexity: basic Author: Matt Zyzik Version: 5.7


xterm, by default, sets eightBitInput to true, meaning that the eighth bit is set for metacharacters (combinations with the Alt key, for instance). Not all terminals have this feature enabled by default, and therefore work differently (they send an ESC before the character key).

So for the xterm, with enables the eight bit, you can just do something like,

map <m-a> ggVG

However, with a terminal that's in 7 bit mode, you have to do this:

set <m-a> = ^[a
map <m-a> ggVG
" the ^[ is an ESC char that comes before the 'a'

My tip is to just set all terminals to work in 8 bit mode. Here are two examples:

Eterm -8
rxvt --meta8

[edit] Comments

Also, these are the settings I use in my /etc/inputrc:

set meta-flag on
set input-meta on
set convert-meta on
set output-meta on

These are so that alt keys like <m-b>, <m-f>, <m-d> will work well in shell.


See also VimTip738:fix META-keys on Unix terminals.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto Wiki
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Get Alt key to work in terminal"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation