Last Updated: February 25, 2016
·
966
· sheerun

Auto indent pasted code in vim

Add to .vimrc:

nnoremap <silent> = V`]=

Now, press = after pasting code.

1 Response
Add your response

instead of:

V`]

you can use:

gv

which reselect last select or paste.

Also, I'm not sure if I would like to have = remapped, gv= is still ok for me :)

edit:
I was wrong. gv will work only if p or P was used in visual mode.
I've got another mapping in my .vimrc:

noremap gV `[v`]

It would select last edited/pasted lines, so you can use gV=

over 1 year ago ·