adit
adit

Reputation: 33644

strip whitespace and not new lines

I am trying to remove whitespaces but not new lines in my text file in sublime text

I tried doing a find and replace of \s with nothing, but it also removes new lines, how can I remove whitespaces excluding new lines?

Upvotes: 0

Views: 44

Answers (2)

Blender
Blender

Reputation: 298166

You can use a negative lookahead:

(?!\n)\s

Upvotes: 1

Akshat Singhal
Akshat Singhal

Reputation: 1801

Replace \n by some unique string like 1@3@# (which would not be present in your document) and then replace \s by nothing and then finally replace 1@3@# by \n

Upvotes: 0

Related Questions