While browsing for the solution many of us would love, I found one more solution which could be interesting.
There is a software called Karabiner-Elements and Karabiner-Viewer, free and safe to download. It can change mappings of the keys, and you can initiate some sort of Normal and Insert Mode.
The solution below will map your keys
The mappings I use:
- Press COMMAND + CTRL + ESC = Initiate “Normal” mode (it will just remap HJKL to arrows)
- Press again COMMAND + CTRL + A = To initiate insert mode
Optional: You can also add COMMAND + CTRL + I, I removed that one because I already use that shortcut to something else.
For Linux and Windows users, please find out what is the replacement for command in your OS, you can do that by opening Karabiner-Viewer and pressing the key, it will print out the name of the button
You can easilly just switch off the rule if you don’t want to use it anymore
Steps
- Install Karabiner sofware
- Open Karabiner-Elements Settings
- Find Complex Modification > Add your own Rule
- Paste the following text below
{
"description": "VIM Mode using regular keyboard HJKL",
"manipulators": [
{
"from": {
"key_code": "escape",
"modifiers": { "mandatory": ["command", "control"] }
},
"to": [
{
"set_variable": {
"name": "vim_mode",
"value": 1
}
}
],
"type": "basic"
},
{
"from": {
"key_code": "escape",
"modifiers": { "mandatory": ["command", "control", "shift"] }
},
"to": [
{
"set_variable": {
"name": "vim_mode",
"value": 0
}
}
],
"type": "basic"
},
{
"from": {
"key_code": "a",
"modifiers": { "mandatory": ["command", "control"] }
},
"to": [
{
"set_variable": {
"name": "vim_mode",
"value": 0
}
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": { "key_code": "h" },
"to": [{ "key_code": "left_arrow" }],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "h",
"modifiers": { "mandatory": ["shift"] }
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["shift"]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": { "key_code": "j" },
"to": [{ "key_code": "down_arrow" }],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "j",
"modifiers": { "mandatory": ["shift"] }
},
"to": [
{
"key_code": "down_arrow",
"modifiers": ["shift"]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": { "key_code": "k" },
"to": [{ "key_code": "up_arrow" }],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "k",
"modifiers": { "mandatory": ["shift"] }
},
"to": [
{
"key_code": "up_arrow",
"modifiers": ["shift"]
}
],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": { "key_code": "l" },
"to": [{ "key_code": "right_arrow" }],
"type": "basic"
},
{
"conditions": [
{
"name": "vim_mode",
"type": "variable_if",
"value": 1
}
],
"from": {
"key_code": "l",
"modifiers": { "mandatory": ["shift"] }
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["shift"]
}
],
"type": "basic"
}
]
}