Sublime Forum

Delete entire line if it contains certain string

#1

Hi - I want to do a “find in files” operation to go through a list of hundreds of .OBJ files. to delete all of their faces (leaving only the vertices). Faces in an obj file look like this:
f 20824/20824 20668/20668 20667/20667
and vertices like this:
v 0.211181 0.436763 1.052000

Each obj file has about 100,000 lines of these coordinates. Is there an operation in sublime text to say:

“If line starts with f, delete line, else do nothing”? How could I go about deleting all faces in the obj file in sublime text?

0 Likes

#2

Turn on regular expression in search and replace.
Search for ^f\s.*\n
Replace with nothing.

Not sure how Sublime Text will handle the hundreds of file with millions of lines though.

0 Likes

#3

[quote=“svenax”]Turn on regular expression in search and replace.
Search for ^f\s.*\n
Replace with nothing.

Not sure how Sublime Text will handle the hundreds of file with millions of lines though.[/quote]

Indeed. This sounds like a job for sed.

0 Likes

#4

I think the replace may go much faster if you first switch the syntax to plain text - I seem to recall Sublime reparses the syntax coloring between replaces or something? I don’t remember if that’s actually true, but feel free to give it a shot. :smile:

0 Likes