Reputation: 7663
I was wondering if it was possible to run a command on the search match and not on the line.
For instance, with this file:
asdf - asdf
hjkl - hjkl
If I run :g/-/normal D
it will delete the content of all lines, but I'd rather delete the content from the match to the end of the line.
Is that possible ? I don't need to have several matches per line only that the command starts at the correct position.
This is only an example, I could use substitute in that particular example, but this not what I'm looking for.
Upvotes: 1
Views: 150
Reputation: 11790
How about this:
:%norm t-D
t- .......... until before -
D ........... delete till end of line
Upvotes: 1
Reputation: 196466
You can't reuse the match in your command so you will have to move to that match explicitely:
:g/-/normal f-D
Upvotes: 1