How to modify the following VIM regex to work with white space after commas? -
i took regex question: what vim command(s) can used quote/unquote words?
:%s/\([^,]\+\)/"\1"/g
it turns this:
foo,foo bar,bar@foo,foo# bar,bar$ foo#
into this:
"foo","foo bar","bar@foo","foo# bar","bar$ foo#"
i modify regex work this:
foo, foo bar ,bar@foo ,foo# bar, bar$ foo#
turning this:
"foo", "foo bar", "bar@foo", "foo# bar", "bar$ foo#"
any suggestions?
something work
:%s/\s*\([^,]\+\)/ "\1"/g | %s/^ //
match leading whitespace before putting capture group. put space before capture group in quotes. put , space in first column need remove space use second substitute command.
Comments
Post a Comment