Reputation: 1240
I'm looking for a quick command in VI(M) where I can delete all text starting from the end of the line to a character. I can do the reverse:
:%s/.*"
But I want the opposite. I tried:
:%s/$.*"
but that didn't work (my logic was $ - start from the end of the line, find everything up to " and delete it.
Here is a sample of the text I'm trying to manipulate (EDIT: but this line occurs multiple times - the solution must work for many lines of a similar construction - single line solutions won't be sufficient - apologies for not being clear first):
APPPOOL "default app pool" (some long list of stuff, more entries here)
becomes
APPPOOL "default app pool"
Upvotes: 2
Views: 3541
Reputation: 212564
Two thoughts. First:
:s/\(.*"\).*/\1/
Or, go to the end of the line and do:
dT"x
To operate on the whole buffer:
:%normal $dT"x
Upvotes: 2
Reputation: 195229
why not just simply type $dT"
?
if you really want to do it with :s, try
:s/"[^"]*$/"/
Upvotes: 11