Pergunta

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!

Foi útil?

Solução

Inside double quotes, backslashes must be escaped. Either use single quotes ('\1') or double all backslashes ("\\1").

See :help expr-string for details.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top