My Entire .vimrc File In 2 Lines

Sat Oct 14 2017 | Thoughts  | 0 Comments

I've always been a minimalist when it comes to configuration files.

I like to be able to switch to other computers which may or may not have my settings. The fewer settings I have, the quicker I can get a working environment up and running.

If you like configuring your setup feel free to go crazy. Just don't let the overwhelm of customization and the infinite number of available plugins stop you from learning plain old Vim.

I've went years with only two settings in my configuration file. My guess is that you can too.

Configuring Vim

Vim settings are normally placed in a .vimrc file located in your home directory.

Occasionally Vim emulators, such as the one for the JetBrains line of tools, use a separate file (.ideavimrc). You'll be able to find the appropriate file location in your tools documentation.

More about your .vimrc file can be found here: http://vim.wikia.com/wiki/Open_vimrc_file

My Entire .vimrc File

ino jj <esc>

:set number relativenumber

Setting #1: Remapping the Esc Key

Vim is great because of it's efficiency.

Unfortunately, the default mapping for one of the most common tasks you do is not as convenient as it should be. When editing, you'll be switching between Normal mode and Insert mode over and over again.

By default, exiting insert mode is mapped to the Esc key. I don't know about you, but the Esc key is not easy for me to hit accurately without looking at my keyboard. It doesn't help that not all keyboard place it in the same spot.

A common configuration change is to remap the Esc functionality to an easier mapping.

My preference is to map it to the sequence jj. It seems counter-intuitive to map a single keypress to two keypresses, but once you try it you'll see how convenient it is since your finger is almost always right on top of the j key.

To remap the jj combination to the Esc key functionality I typically add the following to my .vimrc file:

ino jj <esc>

If you're not a fan of the jj sequence then feel free to come up with your own key remapping.

For more information on remaping the Esc key visit http://vim.wikia.com/wiki/Avoid_the_escape_key.

Setting #2: Configuring Line Numbers

Many of Vim's commands accept numbers to repeat the command more than once.

If you want to delete 6 lines you would press 6dd

The problems is that quickly knowing how many lines you want to work with can be a challenge.

To make life a little easier, I like to turn on relative line numbers so that I can quickly see how far away other lines are to my current line.

:set number relativenumber

For more information about line numbering in Vim visit https://jeffkreeftmeijer.com/vim-number/.


Hi.

My name is Aaron Schwartz. I write code all day long for a living. Vim (and Vim emulation in IDE's) has made coding much more pleasant.

Learning Vim can be challenging but I'm convinced that anybody can learn it with a little time and the right instruction.

My goal is to make it as easy as possible to memorize enough Vim to be comfortable using it every day.


Want To
Memorize Vim
Quickly?

Receive weekly emails with the tactics I used to go from novice to expert.


Recent Posts


This site was coded in WebStorm with Vim emulation enabled. Powered by the React Static framework.