Line Breaks suddenly are away


#1

Hi,
in some php files the line breaks are suddenly away. Instead there are spaces. Additionally the spaces are sometimes weird, because when i want to count the spaces the cursor is not jumping constantly, but sometimes with normal space place, sometimes with less space then with more space.

I searched and found some tips for converting CRLF or LF line endings. But that has no effect.

Does anbody know whats going on?

Thanks
Johannes


#2

Hi Johannes.

Your description sounds like an indent occurrence. But I confess - I do not know PHP and know Atom only slightly. Someone else will have to step forward for helping.

Some ideas to start with in thee mean time:

  1. Do you have the “invisibles” (\n \r \t) set to be visible? These are found in the configuration of Atom.

  2. Could you please post a screen capture, someone might be able to give a hint or two. The “invisibles” should be set to be visible.

  3. The same code you show in the picture - paste in the post also. Start the code block with…

  • Back quotes x 3 & code type
  • Next lines, the exact code
  • Last line end with back quotes x 3

```php
{this is the code}

```

Hope you find a solution.


#3

Mind uploading one of these files so that I can take a look at it?


#4


Hi, here is a screenshot from one of the files. If i copy the content and import it it in dreamweaver, everything is okay and the line-breaks are back.

And here is the code:

<?php
/**
 * Post rendering content ACF
 *
 * @package understrap
 */
?>
     <?php if( get_sub_field('abstand') == 'Abstand klein' ): ?>

      <div class="container section-low">
      	<div class="row">
      		<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
            <?php the_sub_field('content-editor'); ?>
      		</div>
      	</div>
      </div>

      <?php endif; ?>

      <?php if( get_sub_field('abstand') == 'Abstand groß' ): ?>

       <div class="container section">
      	<div class="row">
      		<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
            <?php the_sub_field('content-editor'); ?>
      		</div>
      	</div>
      </div>

      <?php endif; ?>

You see, the code i pasted has its line-breaks. 

@danPadric
I don't know how to set the invisibles visible. Where do i have to put the code? In config-json? And how exactly. 

Thank you very much
Johannes


#5

What’s probably happening is that your PHP file is using “Mac” line endings (\r only). As the last OS that used those line endings was discontinued 15+ years ago, Atom has decided to stop interpreting them as line endings in Atom 1.19. I’m surprised though that converting to CRLF/LF isn’t working for you. Have you tried opening the Command Palette and choosing either Line Ending Selector: Convert to LF or Line Ending Selector: Convert to CRLF?


#6

I don’t need or care about the code. I would like to look at the file itself.


#7

http://www.smehsigns.at/download/home-content_1-column.php Here is a download link to the php-file. Direct Upload is forbidden.


#8

Yes, if i open the Command Palette and choose one or the other noihing happens, except a change in the footer of atom to show “LF” or “CRLF”.


#9

A PHP file after it has been served by the server is processed HTML and doesn’t tell me anything. If there is a company policy preventing you from uploading the file, then that’s something I can’t help you with.


#10

Sorry, that was stupid of course. I am not allowed to upload a php file within this editor. Maybe because I am a new member.

I uploaded it again on my server in a zip file. Here


#11

Okay, here’s what I see in Notepad++. Check the status bar at the bottom. It says Macintosh (CR), which indicates that the line endings are just \r, not \n or \r\n. I don’t know why Atom doesn’t know how to switch out of CR, but you can do that in N++ by right clicking on the line ending name and selecting a different one.

After that, this is what I have in Atom:

I have tried searching in Atom for \r by itself, but it doesn’t seem to recognize the line endings at all, so this might require an external program to fix.


#12

Thanks. That’s weird. The setting of line-endings in atom changes only when you copy the (broken) code and replace the code with itself. After that it looks okay. And also if i recheck it with Notepad++, the line endings changes to CRLF.

Thanks for helping
Johannes


#13

Yeah. We’re dealing with the fallout of a decades-old disagreement between the first personal computer engineers about how to represent line ending characters.