White space between lines in paste texts


I tried so much to paste html or php text in new window, but when I paste them, many white spaces appear between lines. I’m fighting with this crazy problem since yesterday. I tried to reset atom by deleting .atom directory and I lost all the plugins…


Can you make screenshots to show us a visual example?


Sure buddy, and thanks for your reply,It almost works but this strange trouble happens only in some cases…


One quick option would be a simple search / replace.

Atom Menu:
Find > Replace in Buffer

Enable regular expressions :

Then replace multiple new lines with one:
Find: \n{2,}
Replace: \n



Another option:

I’m sure there are more elegant solutions but I had a look at some of the documentation and here’s something you can use to add a palette command to remove multiple line breaks from the current document ( or a selection if you’ve selected a section )

customScan = (from, to) ->
  editor = atom.workspace.getActiveTextEditor()
  if editor
    buffer = editor.getBuffer()
    target = from
    replacement = to
      () ->
        if !!editor.getSelectedText().length
            ({matchText, replace}) ->
                matchText.replace(target, replacement)
            ({matchText, replace}) ->
              replace( matchText.replace(target, replacement) )

normalizeLineEndings = () -> customScan(/\n{2,}/g, '\n')

atom.commands.add 'atom-text-editor',
                  'Whitespace: Normalize line endings',


I’d like to take a look at the PHP file you’re copying from. If you can upload that file to somewhere on the Internet (the actual file, not just copying and pasting its content), that would be ideal. I’m pretty sure it has to do with line endings, and if so I can identify it, but it’s much easier for me to look than for me to tell you what to look for.


You are making some good suggestions.
Do take care of what was used for line endings… not all systems are the same.
For that reason the notes…


Thanks so much everybody those who reply this question, and about the php file…actually I don’t know how I can upload that here…!


You don’t have to upload it here. Just upload it to any file sharing or cloud storage service and post a link.


This is the index.php file


Okay, yes. I can open the file in Atom and it looks normal, but when I copy and paste from the file to itself, I get newlines appearing seemingly from nowhere. However, when I open the file in Notepad++, I see something different.

Check out the words under the cursor in the right-hand side of the status bar. That’s the line ending type that the editor has detected. But if you look in Atom, it autodetects CRLF. You can click on the CRLF in Atom and a dialog will appear that offers you a choice, but that choice only includes CRLF or LF, not CR. I believe that Atom’s lack of support for CR by itself is the culprit. I was able to fix the copy/paste problem by changing the line ending in Atom to LF and then back. After that, no new lines appear.


I did everything you have described but I still have the same problem, but It doesn’t heart me much
,Thanks so much everybody anyway…


You could try opening all the files in Notepad++, changing the line endings, and saving them again.