45612Re: Calling a function from a :s command (weird results)
- Nov 30 6:47 PMOn Nov 30, David Fishburn wrote:
> I have this function (from a previous posting):Actually Preben Guldberg wrote this function.
> function! InvertString(str)
> " Courtesy of Antony Scriven
> " This will invert/reverse a string
> " This will work on arbitrary length strings, too. The /.*/ should be
> " quick, which might make it up for using a regex rather than using
> " numerous commands in a :while loop.
> " This can be used in a substitute command as follows:
> " :%s/AUTHORIZATION/\=InvertString(submatch(0))
> let inverted = substitute(a:str, '.\(.*\)\@=',
> \ '\=a:str[strlen(submatch(1))]', 'g')
> return inverted
- << Previous post in topic Next post in topic >>