Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge multiple lines into one using Sublime Text

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

I understand that Ctrl (Cmd)+Shift+L "multiple-selects" so that we could do the edit simultaneously. However, in the demo, they also merge all the lines into 1 single line. What is the shortcut for that?
I used Ctrl+J but it just deletes once and not all the occurrences of new line.

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

like image 825
Arun Manivannan Avatar asked Nov 27 '12 06:11

Arun Manivannan


People also ask

How do I combine multiple lines in one?

The paste command can merge lines from multiple input files. By default, it merges lines in a way that entries in the first column belong to the first file, those in the second column are for the second file, and so on. The -s option can let it merge lines row-wise.

How edit multiple lines sublime?

To select multiple regions using the keyboard, select a block of text, then press Ctrl+Shift+L to split it into one selection per line. When you're done with using multiple selections, just press Ctrl+K to trim all but the first.

How do I comment multiple lines in Sublime Text?

To add single-line comments, put the text cursor on the line to comment-out or highlight multiple lines and type CMD + / on Mac, for Linux and Windows use CTRL + / .

How do you merge rows in notepad?

Select the lines & press Ctrl + J --> Easiest option :) On small structures, manual method is often quicker and more effective than elaborated (programmatic) one.


1 Answers

A single command shortcut for merging multiple lines into 1 is "join lines".

  • Command + Shift + J on the Mac to join lines.
  • CTRL + Shift + J on Windows
  • Edit > Lines > Join Lines

Important note: This keyboard shortcut changed in versions of sublime text released after around mid-2021. For older versions, use Command + J, or CTRL + J.

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

like image 170
uroc Avatar answered Oct 02 '22 02:10

uroc