vim jj to esc mapping

For a single vim session (safe version)

:inoremap jj <Esc>

For every vim session (still safe)

Save this to your .vimrc file in your home directory.

" this is a comment so you remember this later
" insert mode; no recursive; map; <from>; <to>
inoremap jj <Esc> 

* change jj to anything you want, fd , jk even ;;

What is happening?

i means we are creating a mapping for the insert mode

nore means we designate “no recursive” mode (see below for more)

map means we are mapping ūüóļ

jj is the commands we are mapping from

<Esc> is the command we are mapping to

No change needed: Ctrl + [

If you already have Caps Lock mapped to Ctrl, then a solid alternative is: Ctrl + [.

Why use the safe version?

When you create mappings in vim, there is a recursive lookup to all other mappings.

We use inoremap instead of imap above because the nore (not recursive) portion, will avoid recursive mapping. An example of recursive mapping is this :nmap dd jddk where the dd in the right hand definition will actually map to the left hand into an infinite loop. Read more here.


  1. Stack Overflow
  2. Learn Vim The Hard Way
  3. vim.fandom
  4. In vim > :help inoremap


why vim?

vim is vi(improved)

vim is a powerful way that allows you to transform your thoughts into action in as little keystrokes as possible. In fact, the subtitle of the book Practical Vim is this:

“Edit Text at the Speed of Thought”

With that said, vim has a steep learning curve that often does not feel worth it if you are used to Command+c to copy, Command+v to paste and you like thinking while moving your mouse.

Its mostly mindful awareness

If vim has done one thing, its made me very cognizant of what I am trying to achieve. The emphasis on achieving as much in as little time, and the freeing of mental overhead from reaching all over the place, allows me to approach programming much more mindfully.

But as of today, “How to exit the Vim editor?” has 2644 votes on Stack Overflow!!!


Heres a tiny walkthrough.

vim intro walkthrough

Step 1: change var to const

To change var to const you simply need to type: ceconst<Esc>

where: c means change, e means until end of word, <Esc> takes you out of insert mode


Step 2: delete the word function

To get to the word “function” type: ff

where: f means find, the second f is the letter to find

To delete a word: de


Step 3: add an arrow behind the opening curly brace

To get to the char “{” type: f{

To insert “=>” type: i=><Esc>

where: i means insert, => is your input


Notice that we never touch the mouse! We never reach for the arrow keys.

In fact with the right shortcuts, you never take your fingers off the home keys. It’s really hard to state how much this frees your mind.

Until Elon Musk’s¬†Neurolink allows as to change modes AND input text by brain implants, vim will be how to change text.



Setting up .vim directory

vim¬†settings are important for every vim¬†user and you shouldn’t have to use a vanilla vim¬†setup just because you ssh into a VM or set up a new computer. Since most vim settings have zero personal data, the¬† most convenient thing to do is to upload your vim¬†directory+settings onto the internet for the world to bask in your glory and for you to pull down to any computer.

Creating a .vim directory

In your root directory, create a ~/.vim directory with an initial ~/.vim/.vimrc file

$ mkdir ~/.vim && touch ~/.vimrc

Feel free to add any vim settings you like, heres a couple to start

" This turns on syntax highlighting
syntax on
" This maps jj to the <Ecs> key in insert mode
:imap jj <Ecs>

Your directory should look like this

| .vim

|– .vimrc


vim will source the file ~/.vimrc and since our real config is located in our .vim directory, we will need to create a symlink that links our ~/.vim/.vimrc to ~/.vimrc.

$ ln -s ~/.vim/vimrc ~/.vimrc

Once you run the line above, you will have a symlink in your root directory that points to your ~/.vim/.vimrc¬†and any file changes you make to either will “update” on both.


Its incredible to have your .vim directory uploaded to Github so create a new repository called .vim

Initialize your .vim directory, add the remote branch and push your first commit.

Check out my ongoing .vim at


vim: how to turn on syntax highlighting

Normal mode

How to turn on syntax highlighting for your current session

:syntax on

.vimrc configuration

How to default syntax to “on” for all vim sessions

Remember to always  back up your config files, simply add this to your .vimrc

syntax on

Try different colors

How to cycle through available color schemes for your current session

:colorscheme <Tab>

:colo <Tab> for short

How to change your default color scheme

If you want to change the syntax highlighting colors of your vim setup, the simplest way is to select a preloaded color scheme.

On Mac, your vim files are likely in /usr/share/vim/vim<version_number>/, with your version number being unique to your setup.

How to list your available color schemes:

ls /usr/share/vim/vim<version_number

These are my available colors:

Try a bunch of these colors and find the one you like.

How to set your color scheme

Add this to your ~/.vimrc

colorscheme darkblue


Thats it! See more at the docs