Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map Meta key to control key in vim?

Tags:

vim

How do I map my Windows key (which is defined as the Meta_L key in Ubuntu) so that it also works as the Ctrl+L key in Vim? This is a more comfortable mapping for me in some circumstances.

like image 275
victor Avatar asked Apr 10 '09 14:04

victor


3 Answers

You have to remap all the sequences which use <C-> to use <M-> and put them in the separate .vimrc.

To receive the full list of current mappings use

:redir > ~/mappings | map | redir END 
:e ~/mappings
:g!/<C-/d

After that you will have all the mappings that use key. Add same mappings to your .vimrc substituting

:help map

It is not a one minute job but it is how it can be done.

like image 103
Mykola Golubyev Avatar answered Oct 17 '22 07:10

Mykola Golubyev


Looks like Ctrl and Alt are hard-coded into in the Vim source. You can map your Windows key to Ctrl globally if you don't mind affecting all other programs too. Some window managers will support doing this, or else you can use xmodmap. The Vim wiki has some info about mapping the Windows key to another Esc , which is similar.

like image 21
Brian Carper Avatar answered Oct 17 '22 07:10

Brian Carper


You can also go to System settings > Keyboard > and Alt/Win key behavior > Control is mapped to Alt keys, Alt is mapped to Win keys. This is much better to use control with thumb.

like image 1
Gattoo Avatar answered Oct 17 '22 05:10

Gattoo