From time to time I have to work with code that isn't indented to the level of indentation I have Vim set up to (4 spaces per level), usually after copy/pasting something in the file. I usually make do with << and >>. The problem is they don't jump to the next indentation level, they just add or subtract 4 spaces.If I have code like thisif condition:    do this   do thatdoing >> on do that will result in if condition:    do this       do thatI want it to go to this if condition:    do this    do thatBeside easily  matching the indentation of the line above, I want it to jump to the next level of indentation, not add 4 spaces.This is what I have in my .vimrc regarding indentation:set tabstop=4 shiftwidth=4 expandtab
Indent to next indentation level with >>
indentation
When you use one of the commands {count}>>, {count}<<, >{motion} or <{motion}, on some lines which have already been indented, and you want their new indentation level to be a multiple of your 'shiftwidth' option value, you can enable the 'shiftround' option, and add this line in your vimrc:set shiftround