Sublime Forum

Paste lines adds double spaced lines

#1

Cutting lines and pasting them results in pasted lines being double spaced
(an extra blank line is added in between each cut line)

To see:
Open a file containing multiple lines of text, some lines of which have the same word.
Ctrl-F to find, and type in a word that appears on some, but not all lines.
Alt-Enter to select all the found words.
Ctrl-L to extend the selection to the whole lines. (I want to select all the lines containing my search word.)
Ctrl-X to Cut the selected lines.
Ctrl-Home to go top.
Ctrl-V to Paste the lines that had been cut.

In my case these lines are all pasted with an extra blank line in between each cut line.
(Using build 2181)

0 Likes

#2

Build 2196

Host OS: Win 7 x64
Guest OS on VirtualBox 4.1.4: OpenSUSE 12.1 Gnome Desktop x64

If copy-paste Win->OpenSUSE - it’s all ok.
If copy-paste OpenSUSE->Win - double spaced lines.

See screen shots.




0 Likes

#3

This bugs me too, so was going to report it and found this.
I’m on Win 10 SublimeText 4143 and see the same issue.
Does it happen on Mac and Linux?
If not, I assume it is not a feature, and to do with Windows line endings on the clipboard.

0 Likes

#4

Internally, Sublime normalizes all text to use \n as line termination; thus the behaviour you’re seeing here is the same across all platform regardless of line endings, and is doing what it does on purpose.

When there are multiple selections and you copy, the clipboard is filled with the text of all of the selections joined together by newlines:

The reason for this is that when you paste with multiple cursors, the text in the clipboard is split on newlines into separate strings:

  • If there are exactly as many strings as cursors, one string goes to each cursor when you paste
  • If there is not a match, all of the text goes to all of the cursors.

Newline is chosen here because otherwise if you paste multi selected text with one cursor (or outside of Sublime) you don’t see what you expect.

The issue you’re seeing here (or at least the one the OP was having) has to do with what the command that expands the selection to a line does, which is (as the name suggests) expands the selection to the entire line:

As seen in the image, the cursor is visibly on the line 3, which means that the selection spans all of line 2 including the newline on the end.

If you were to do this with multiple lines at once:

What you end up getting is the two lines, plus their newlines, being joined by the newline separator. Now when you paste it, you get doubled line spacing.

If you want to do this and keep the actual lines, the selection can’t include the newlines on the end of the selection:

Here after I made the selection, I used shift+left to shorten all of the selections by a single character, so that they don’t include the newline. Things then paste as you expect

0 Likes