# Swap Ctrl-Left and Alt-Left on your keyboard

## Introduction

I know, not everyone is a fan of Apple, but I enjoyed quite a bit the UX of my old MacBook Pro, so I always swap the left `Ctrl` key with the left `Alt` key, like the `Command` key and `Option` key from Apple.

The thing I liked about that is the simplicity of using the `Ctrl` shortcuts with the thumb without moving the left hand that much... a personal preference, but still enjoyable IMO.

But swapping keys is not always an easy task, because, if it only works partially, it may completely break your interactions and shortcuts... definitely not a good experience.

## Configuration

The easiest and most compatible way I found is the following (it worked for me on Ubuntu and Archlinux):

1. Open a terminal
2. Type `nano ~/.Xmodmap` and then `Enter` (you can use whatever text editor you prefer: vi, vim, nvim, gedit...)
3. Type the following lines:
   ```
   clear control
   clear mod1
   keycode 37 = Alt_L Meta_L
   keycode 64 = Control_L
   add control = Control_L Control_R
   add mod1 = Alt_L Meta_L
   ```
4. Type `Ctrl-X`, then `Y` and then `Enter` (it may differ according to the text editor of your choice (`Escape`, `:wq` and `Enter` for vi, vim and nvim).
5. Finally type `xmodmap ~/.Xmodmap` to apply the new configuration.

If it doesn't work for you, it may be because of a couple of reasons:
- your keyboard is not mapped the same way (different keycodes)
- you don't have `xmodmap`
- another reason I don't know of...

If the reason is the first one, you may be interested to see [that post](https://askubuntu.com/questions/93624/how-do-i-swap-left-ctrl-with-left-alt-on-my-keyboard) (where I found that tip).