DEV Community

jamesc40
jamesc40

Posted on

Vim re-binds that don't suck

On my last post I spoke about some basic keybindings that allow you to navigate Vim. I would now like to visit a few more keybindings to incorporate into your workflow and some ideas on what to change them to.

One of the first things I would advice a new user to rebind is ESC. You'll be hitting this key a lot and it by default is difficult to reach especially from the home row

imap jj <Esc>

Another popular rebind for escape is tab which you can do in your keyboard settings if you're on mac.

Additionally when working with multiple windows in vim the default key-bind can be tough to remember for windows so I would recommend these:

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

This removes the need to hit Control AND W to change when changing windows.

You should also consider changing the default behavior for tabs.

set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab

By default vim sets these as 4 and it looks a little strange coming from another Text Editor.

Lastly by default the 'p' which is put does not save to the system clipboard and does not use the system clipboard. To change this add this:

set clipboard=unnamedplus

These are some of the key-binds that helped smooth my transition to Vim. When first starting out it can seem overwhelming but by taking it one step at a time and finding ways to improve your workflow without getting discouraged is extremely rewarding.

Top comments (0)