I am trying to extract only the function name from a function declaration using vim script. For testing purposes I am using this simple example:
int func(int a);
In vim script I am extracting the function name by this:
:let a = substitute(getline(line('.')), ".*\(func\).*", "\1", "")
But the backreference is not working. When I echo the variable a with
:echo a
it displays the whole line, i.e. int func(int a);
How to extract only the function name with bacreference or any other method?
Thanks in advance!
Inside double quotes, backslashes must be escaped. Either use single quotes ('\1') or double all backslashes ("\\1").
See :help expr-string for details.
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