0

Here is a screenshot of what's happening to my wordpresss template code time after time:

https://www.box.net/shared/zrql76wiimr790587yxj

I thought at first it was a notepad++ problem. But this occured also on phpstorm.

Any idea why that's happening?

Daniel Figueroa
  • 10,348
  • 5
  • 44
  • 66
Klevis Miho
  • 851
  • 8
  • 15

1 Answers1

2

Your code isn't messed up, this is a question about how your system handles lineendings.

Linux and OSX save lineendings differently from Windows.

Linux and OSX saves lineendings with a Line Feed (LF):

\n

While windows saves it with Carriage Return + Line Feed (CR+LF):

\r\n

So what is probably happening is that your file has been written on a system that doesn't save lineendings in the windows format. Your editor most probably supports these kind of line endings and can handle it, look into the menus of your editor.

** Below is part of an edit and not part of my answer.**

You can check EditorConfig which can be helpful when you are trying to keep settings across projects and/or editors and also, if you keep your code under git, Dealing with line endings article from Github may be also helpful.

End of edit

Read more here: Wiki article

Daniel Figueroa
  • 10,348
  • 5
  • 44
  • 66
  • Thanks for the credits, but that information is already available via answer revisions. – Alexandru Guzinschi Dec 26 '12 at 17:51
  • How can I prevent this from happening? And why does it happen only on wordpress? – Klevis Miho Dec 26 '12 at 19:40
  • @KlevisMiho : Do you edit your theme files with some kind of online editor incorporated in Wordpress or within a plugin ? If so, that might be the cause. Also you might want to check if your FTP client will upload .php files in ASCII mode. If not, try it and see if that solves the problem. – Alexandru Guzinschi Dec 26 '12 at 20:13
  • Well whats probably happening is that when you upload your files, the lineendings are converted by your ftp-program. If you're using filezilla check this out: http://stackoverflow.com/questions/554960/how-can-i-stop-filezilla-changing-my-linebreaks – Daniel Figueroa Dec 26 '12 at 20:14
  • I use filezilla. @Daniel Figuerora, your suggestions make sense. Will try that out and let you know. Thanks. – Klevis Miho Dec 26 '12 at 20:17