I would like to replace spaces with underscores inside quotes in part of a pattern.
Example input:
select
"AA" as "Long descriptive name",
"BB" as "Another long name",
"CC" as "There are many spaces here"
from
sometable;
Wanted output:
select
"AA" as "Long_descriptive_name",
"BB" as "Another_long_name",
"CC" as "There_are_many_spaces_here"
from
sometable;
I have tried doing this with the substitute() and submatch() functions like this but I can't get it to quite work (The \= part is not interpreted the substitute command is written into the file). Something is missing.
:%s/ as "\(.*\)"/ as \=substitute(submatch(1),' ', '_', 'g')/g