In Vim, how do I replace a string matched by certain regexp with its length, like this:
Regexp = "\w*"
"hello" -> "5"
"bye" -> "3"
Is it possible to do it with :s or do I need to write some script?
Best regards
Replace 'hello' with your regex expression and this should work in VIM:
:s/hello/\=strlen(submatch(0))/
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