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.
Written by Zach Gotsch
Related protips
1 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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#