vayw2w
Last Updated: February 25, 2016
·
4.794K
· chrismckinnel
4428f6b9f4609795f25f62a352442d6a

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
Say Thanks
Respond

8 Responses
Add your response

8922
Img 1613

Some of these, and much more are here: http://amix.dk/vim/vimrc.html

over 1 year ago ·
8927
Battlemidget

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

over 1 year ago ·
8950
43084203a14bc25c8bb2c1fe9495f2ac

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 ·
8952
43084203a14bc25c8bb2c1fe9495f2ac

And there are much more to dig https://github.com/search?q=vimrc

over 1 year ago ·
8971
4428f6b9f4609795f25f62a352442d6a

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

over 1 year ago ·
9137
1f10c2fce594fe4d5bc05b6e5f466e6a

Great post.

Note that mapping ; to : is really useful, but it overrides 'repeat last f/t command', which in itself is very useful.

Anyways, here's my heavily-commented .vimrc: http://github.com/oryband/dotvim

over 1 year ago ·
9141
4428f6b9f4609795f25f62a352442d6a

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 ·
15258

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 ·