How can I reverse a word in Vim? Preferably with a regex or normal-mode commands, but other methods are welcome too:
<word => drow
I realize I'm a little late to the game, but I thought I'd just add what I think is the simplest method.
It's two things:
pyeval
(py3eval
on recent vim releases) functionSo to reverse a word you would do the following:
"ayiw
yank word into register a
=py3eval('"".join(reversed(str(' . @a ')))')
use vim's =
(expression) register to call the py3eval
function which evaluates python code (duh) and returns the result, which is then fed via the expression register into our document.For more info on the expression register see https://www.brianstorti.com/vim-registers/#the-expression-and-the-search-registers