Tutorial :How to map Meta key to control key in 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.


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.


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.


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.


As an alternative to using xmodmap and if you're using GNOME, you can go into the Control Center â†' Keyboard Preferences â†' Layout Options â†' Alt/Win behaviour â†' Control is mapped to the Win Key. (alternatively, run gnome-keyboard-properties)

Of course, this changes it for everything, not just vim.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »