Question

When I was using VIM, I got a simple question:

Replace the pattern ",\s\d\t)) with ",\s\d)).

For example:

Change the following

...roid", 1 ));
...id", 0  ));
...lite", 1  ));
...

To

...roid", 1));
...id", 0));
...lite", 1));
...

I tried %s/",\s\d\t/",\s\d))/gc, but it changed them to ...roid",sd));

Was it helpful?

Solution

Use backreferences.

%s/",(\s\d)\t/",\1))/gc

Here, (\s\d) is a capture group. The \1 refers to the capture group.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top