Remove all the leading whitespace


#1

I try this
^\s+
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 ?


#2

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

50


#3

1.19.1


#4

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


#5

scan2

See the end of line /new line invisible chars


#6

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


#7

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


#8

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

Jean-Pol Dupont


#9

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


#10

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

ON-TOPIC:
\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 [ ].

dP


#11

Thanks ! Your

^([ ]|\t)+

works fine !

I use Atom on a Mac (OSX Sierra)


#12

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


#13

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