Vim: Select and indent last paste
I stumbled upon this super useful snippet a while ago, for when you’ve pasted something and need to indent it, or whatever. This will select what you just pasted and put you in insert mode:
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
This goes in yer .vimrc obviously.
I completely forgot where I got it from (probably some StackOverflow genius), and not totally sure how it works, to be honest. I was just messing about with my .vimrc the other day and rediscovered it.
p gp >
explanation:
p = paste
gp = grab paste
\> = Indent
I love it.