I have a line like below.
fullname = (this is a test name);
I want to double quote all the strings inside "(" and ")".
i.e fullname = ("this" "is" "a" "test" "name");
Can someone give me a vim regex to do that?
I have a line like below.
fullname = (this is a test name);
I want to double quote all the strings inside "(" and ")".
i.e fullname = ("this" "is" "a" "test" "name");
Can someone give me a vim regex to do that?
This command puts everything which is not space, tab, equals sign, paren or semicolon to quotes:
:s/[^ \t=();][^ \t=();]*/"&"/g
Please note that this quotes fullname
as well, but you can remove those quotes manually.
Sometimes it is worth doing part of the work manually, because automating it would be slower.
Run the command:
:help substi
to to get help about regexp substitution in vim.
I would do this as follows:
:s/\<\w\+\>/"&"/gc
Due to the confirmation switch 'c' you will be asked for each replacement. Answer 'n' (no) for the replacement of 'fullname' and 'a' (all) for the rest of the line.