Please browse to the sublime text homepage and have a look at slide #2.

There is a "screenshot movie" showing several commands, but there is no explanation. Just CTRL+SHIFT+L for multiple selection.

So what are the shortcuts to turn something like this


into that:

["Mon", "Tue", Wed"]

Thanks in advance.

  • 1
    Please include a link to whatever it is you want us to look at. Better yet, include the screenshot! – terdon Dec 7 '12 at 12:44
  • 1
    Well that is the link sublimetext.com. It is the second slide im talking about. But thats a canvas, i can neither copy nor reference. – Tammo Dec 7 '12 at 16:12
  • 2
    That's fine, I just did not want to have to google sublime (which I had never heard of) in order to see whether I can answer your question. The more information you include in the question and the easier you make it for people to answer, the better your chances of a good answer. – terdon Dec 7 '12 at 16:15
  1. Type

  2. Select the three lines with your mouse or keyboard like you usually would do.

  3. CTRL+SHIFT+L will split this up into "each line individually selected by multiple cursors".

  4. Press " which will surround each selected line with it.

  5. Press Home to jump to the beginning of the line, hit backspace to remove the newlines.

  6. All you need to do now is type a ,, remove the first , and select everything and hit [.

Alternatively, you can do it like in the video, but I've found that placing a comma in the beginning is much easier to accomplish since your cursor is already there.

  • Can you do the reverse i.e. go from "Mon", "Tue", Wed" to each in a separate line – user Sep 30 '13 at 18:53
  • 2
    @buffer: Yes, type Mon,Tue,Wed,Thu,Fri,Sat,Sun; select the first , and then press CTRL+D five times to select the next five commas as well, then simply press enter. – Tamara Wijsman Oct 1 '13 at 9:53

An alternative to pushing home and backspace is selecting all lines to be joined and pressing ctrl+j to condense them into one line. Not sure if that was in 2, but it works great in ST3.

  • Nice trick! I can confirm it does work on Sublime Text 2 ;-) – Rob Schmuecker Sep 3 '15 at 18:52

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

  1. Command + J on Mac to join lines.
  2. CTRL+ J on Windows
  3. Edit > Lines > Join Lines

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.