I've file in which there are some repeated parts and I want to get rid of the first occurrence. Normally I'd do %s/_exclude//
to perform substitute for all lines, however I want to replace only the first occurrence in the file, e.g. having:
name = foo
# unknown number of lines ...
features_exclude[rules_config][] = rule1
features_exclude[rules_config][] = rule2
features_exclude[rules_config][] = rule3
features_exclude[rules_config][] = rule4
I'd like to do remove first occurrence of _exclude
, so it becomes:
name = foo
# unknown number of lines ...
features[rules_config][] = rule1
features_exclude[rules_config][] = rule2
features_exclude[rules_config][] = rule3
features_exclude[rules_config][] = rule4
So if I repeat the action again, it'll remove the next one (on whichever line it is) and so on.
What's the easiest way of doing that?
:h :s
you can use a count after a substitute command like:%s/_exclude// 1
but for a reason that I don't understand it begins with the last line of the range so it would have an action onrule4
. Also you talk about removing the whole line but your substitute command only remove the word_exclude
is it what you actually want? Finally wouldn't a search/_exclude
followed by normal modedd
wouldn't be what you're looking for?_exclude
text, not the line.