Last Updated: April 07, 2019
· chrismckinnel

Speed up your already speedy Vim development

Add these to your vimrc to add to your already epic productivity!

Instead of hitting <Esc> :w <Enter> to save when in insert mode, why not map jj to do it for you? I find ZZ awkward to type whereas jj is lightning fast!

noremap jj <Esc>:w<CR>

As an added bonus to doing this, you can disable Vims auto-save feature if you haven't already as you'll be saving your work pretty much every time you exit insert mode. Nice!

If you're a PHP developer, most lines will end with ;, why not remap ;; to append a ; to the end of the line, save the file and exit insert mode?

inoremap ;; <End>;<Esc>:w<CR>

Tired of wasting split seconds hitting shift every time you want to enter a command with :? Swap your ; and : around - takes about a day to get used to, but makes every command super fast.

nnoremap ; :
nnoremap : ;

Changing focus of split panes can be a bit of a pain (<C-w>[direction]), let's drop the middle man!

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

And here's a bonus for Python developers - remove trailing space on file save for pep8-ified goodness:

autocmd BufWritePre *.py :%s/\s\+$//e

7 Responses
Add your response

Some of these, and much more are here:

over 1 year ago ·

Yea his stuff is cool thats what I based most of my early vim days on

over 1 year ago ·

nnoremap ; :
nnoremap : ;

That's nice, but you get used to it so fast that you realize that you mistype in non-vim environment. I would recommend putting

xmodmap -e "keycode 47 = colon semicolon"

to your .xinitrc to remap : and ; globally

xmodmap -e "keycode 47 = colon semicolon Cyrillic_ZHE"
is an advanced version that works if you have another layout you are switching to (cyrillic in this example)

over 1 year ago ·

And there are much more to dig

over 1 year ago ·

Ohhh, that's a great idea to search github for vimrc, pirj!

over 1 year ago ·

oryband, thanks for the comment. I didn't even know that semi-colon was mapped to anything in normal mode, thanks for the info.

How often do you use ; normally? I don't find myself using f or t very much, and when I do use them I usually prefix with a c and never need to jump to the next one on the same line.

over 1 year ago ·

for this one
nnoremap ; :
nnoremap : ;

i map my <space>, so you dont need to screw up your normal keymap

and another tip if you doing php ->
inoremap <C-l> ->

unless you remap your hjkl to cursor movement in input mode, which is also a nice feature, i have an ft detetion on this one, php is ->, js is var, and txt file is movement.

over 1 year ago ·