Each command that has changed the buffer (and yanks) will set the labels '[ and '] around the changed area. This way you can reformat your inserted block with:
`[v`]=
Some people go so far as to use the following mapping to reselect the last modified piece of text:
nnoremap <expr> gV '`[' . getregtype()[0] . '`]'
With this mapping, you can simply make gV= and format the text just inserted.
However, if you have the unimpaired.vim plugin and you insert linewise, you can use the =p command that it provides. This inserts and then reformatts the text at a time. It also provides some other alternative insert >p commands, for example, inserts one level of indentation deeper.
source share