Remove all the leading whitespace


I try this
to remove the whitespaces at the begining of a line.
On some test regex and Sublime that work, but on Atom, remove ALL whitespace (the trailling ws too.
Effect = minimize the file …

How proceed ?


Which version of Atom are you using? That regex works fine for me.





If I create a new file, it’s OK.
The example file was not created in Atom.



See the end of line /new line invisible chars


Is this file created under Windows? Maybe that’s a carriage return before the line feed.


I haven’t tried this package but it might work.


This package remove the white space at the end of line, not at beginning

Jean-Pol Dupont


Oh. Sorry, I guess I didn’t read the whole thing through.


@jpdupont - please consider not having your phone’s email service paste in your private telephone number.

\s is for all white spaces, which include \n and \r. So the questions (1) how is your end-of-line defined (2) how does the system define ^ the start of line.

What happens when you ask for ^([ ]|\t)+ in a find-all?
Watch out for the space between [ ].



Thanks ! Your

^([ ]|\t)+

works fine !

I use Atom on a Mac (OSX Sierra)


@danPadric -> The encoding is Windows on this sample file. I see now where modify end of line encoding. Thanks !


Thanks for the confirmation and the mention.
Happy coding… else give us a poke sometime.