How to swap alt and ctrl on Linux for Emacs?

How to swap alt and ctrl on Linux for Emacs? It will be more easier to press the ctrl keys which is a very important key for Emacs.

You can make of xmodmap.

Save this as a file modmap:

clear control
clear mod1

keycode  64 = Control_L NoSymbol Control_L
keycode  37 = Alt_L Meta_L Alt_L Meta_L
keycode 108 = Control_R NoSymbol Control_R
keycode 105 = Alt_R Meta_R Alt_R Meta_R

add mod1 = Alt_R Alt_L Meta_R Meta_L
add control = Control_R Control_L

And then run:

xmodmap modmap

If you want to make it permanent (reloaded each time you start X), save the file content to ~/.xmodmap and add this line to your ~/.xsession:

xmodmap ~/.xmodmap
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *