Alex Rivera | Logout

Delete all text in line before/after highlighted search pattern

Asked 2011-06-03T09:30:21.017
14

I know in VIM how to search a string and delete the text till the start/end of line but I would like to know if it is also possible to delete all text in line before or after highlighted search pattern.

Edit
Report

1 Answer

14

To delete the text before FOO on the same line:

:s/^.*\(FOO\)/\1/

answered 2011-06-03T09:40:01.943

Your Answer