Combine multiple lines into one using Sublime Text

I am very new to Sublime Text and I am sure this is a naive question. View multiple line selections at http://www.sublimetext.com/ (2/6 slide). Absolutely love it.

I understand that Ctrl (Cmd) + Shift + L are "multiple-selects" so we can do the editing at the same time. However, in the demo, they also combine all the lines into one line. What is a shortcut for this?
I used Ctrl + J , but it just deletes once, not all occurrences of a new line.

I use TextPad and use Find / Replace \n with empty space. But it seems that the person giving the demo is using some kind of shortcut.

+51
sublimetext2 sublimetext sublimetext3
Nov 27
source share
6 answers

I think that in the demo, he presses Del , with the cursor at the end of the line, in several selections. Thus, \n is deleted on every selected line.

+39
Nov 27 '12 at 8:00
source share

The only shortcut to concatenate multiple lines into 1 is “connection strings”.

  • Command + J on Mac to join lines.
  • CTRL + J on Windows
  • Edit> Lines> Merge Lines

Another approach is manifested in demo animations at sublimetext.com . Using multiple selections, CTRL + Shift + L is used to split the selection into lines, and each line is then edited at the same time. end + del will then remove all line breaks. This can be seen on slide 2/6 at http://sublimetexttips.com/7-handy-text-manipulation-tricks-sublime-text-2/

+212
Mar 10 '13 at 19:45
source share

editing

join Attaches the next line to the current line, replacing all spaces with space by one space

http://www.sublimetext.com/docs/commands

Go to the edit item in the menu, Edit → line → join lines

+6
Apr 01 '14 at 5:51 on
source share

ctrl+a and ctrl+j seem to work on sublime text 3.

+5
Sep 18 '17 at 8:46 on
source share

If you want to combine the lines into one line, which will also remove the beginning and end of the space from the line, the following expression should work:

 Find What: ^\s*(.+)\s*\n Replace With: \1 
+3
Nov 18 '13 at 20:20
source share

Join lines is a good command, but it adds spaces between the joined lines. To concatenate strings without spacing, the easiest way is as follows:

  • Find -> Replace (Command + Option + F on Mac)
  • Ctrl+Enter to enter a new line in the Find What field.
  • Do not enter anything in the Replace With field.
  • Click Replace All .
0
Feb 23 '17 at 19:16
source share



All Articles