Question
Thanks to the comment from @martin-tournoij on one of my other questions. He gave me this piece of code:
:%s/0x[a-fA-F0-9]\+/\=submatch(0)->str2nr(16)/
which looks for every hex-number like 0x10
or 0x539
and replaces it with the corresponding decimal value.
Okay now why this code only works in vim and not in neovim. Neovim throws this error:
E276: Cannot use function as method: str2nr
So Why?? Where is the problem??
:%s/0x[a-fA-F0-9]\+/\=str2nr(submatch(0), 16)/
should probably work, but I don't have Neovim installed so I can't test. I think Neovim ported methods from Vim only very recently.:help <error-code>
::help E267
, and that often gives you more detail on the error message.str2nr()
is documented as supporting the method call syntax, so either you've got an older Neovim version which doesn't support it yet, or it's a bug in NeovimE276
doesn't exist in neovim, only in vim ^^