2

If my line looks like this:

abcdefghi

How can I reverse the selected characters (for example: from position 2 to position 6 (5 characters)) to get the result like this:

a(fedcb)ghi

And how can I yank, reverse and paste somewhere else to get the result like this:

abcdefghi(fedcb)  

NB: parentheses used only for visualization.

Thor
  • 45,082
  • 11
  • 119
  • 130
pogibas
  • 27,303
  • 19
  • 84
  • 117

1 Answers1

3

You could use the 'revins' option to do this, as suggested here:

vnoremap <f4> c<C-O>:set ri<CR><C-R>"<Esc>:set nori<CR>

If you want to paste it somewhere else, yank it as you otherwise do and use this "reverse paste" mapping:

nnoremap <f4> :set ri<cr>i<C-r>"<Esc>:set nori<cr>
Thor
  • 45,082
  • 11
  • 119
  • 130