Last Updated: February 25, 2016
·
4.953K
· zgotsch

Pasting in Vim with proper indentation

Many times when moving code to a different indent level in vim, I have to adjust the indentation manually through < and > or use = to try to fix the indents automatically.

However, you can use ]p to insert after adjusting the indent level to match the current line. In a similar fashion ]P (or, strangely, [p) will adjust the indentation and paste before, rather than after.

1 Response
Add your response

You may be interested in vim-pasta plugin that does this automatically and in a smarter way: https://github.com/sickill/vim-pasta

over 1 year ago ·