I usually visual select a block and copy/cut it somewhere else, then I found myself always formatting the pasted text, so is there a way to quickly visually select the text again.
Every command that modified the buffer (and yanks) will set the '[
and ']
marks around the changed area. So you can reformat your pasted block via:
`[v`]=
Some people go so far as to use the following mapping to reselect last modified chunk of text:
nnoremap <expr> gV '`[' . getregtype()[0] . '`]'
With this mapping you can just do gV=
and format your just pasted text.
However if you have the unimpaired.vim plugin and you are pasting linewise you can use the =p
command it provides. This will paste and then reformat the text in one go. It also provides some other alternative paste commands >p
for example will paste one indent level deeper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With