Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Atom Editor: Fold selection onto single line

Tags:

atom-editor

Is there a way in Atom to fold an entire selection on a new line? I'm trying to make a package that lets me select multiple lines of code and fold them. My markup would look something like this:

/* Text Colors */

.text-red {
    color: red;
}

.text-green {
    color: green;
}

.text-blue {
    color: blue;
}

/* Typography */

h1 {
    font-size: 30px;
}

and then when I fold it, it would look something like this:

/* Text Colors */

[...]

/* Typography */

h1 {
    font-size: 30px;
}

This way I can view looks of sections in my code at the same time. I've tried using foldSelectedLines but unfortunately that ends up folding it like this:

/* Text Colors */

.text-red {[...]

/* Typography */

h1 {
    font-size: 30px;
}
like image 991
joshhunt Avatar asked Aug 18 '14 07:08

joshhunt


People also ask

How do you collapse code in Atom?

You can fold blocks of code by clicking the arrows that appear when you hover your mouse cursor over the gutter. You can also fold and unfold from the keyboard with the Alt+Ctrl+[ and Alt+Ctrl+] keybindings. To fold everything, use Alt+Ctrl+Shift+[ and to unfold everything use Alt+Ctrl+Shift+] .

How do you jump to a line in an Atom?

First press the Ctrl + G in your keyboard then you will redirect to command line in the Atom editor, then type line number to navigate that line Number.

How do you select multiple words in an Atom?

Highlight multiple lines however you like. Use the Selection|Split Into Lines command ( Cmd+Shift+L on OS X or press Cmd/Ctrl+Shift+P and type Split Into Lines ) to split the multiline selection into a selection for each line. Press the right arrow by itself to reveal the cursor at the end of the selections.

How do you edit multiple lines in an Atom?

Select all text ( Cmd + A on Mac, Ctrl + A elsewhere), then use the shortcut to “split the selection into lines” ( Cmd + Shift + L on Mac, Ctrl + Shift + L elsewhere). Both commands are also available from the command palette.


2 Answers

Its CTRL-ALT-F on Linux & Windows or CTRL---F on mac.

Also in Atom press CTRL-SHIFT-P (or -SHIFT-P on mac) to open the command palette and type fold to get a list of all the possible fold options and related keyboard shortcuts.

like image 79
jpd Avatar answered Sep 22 '22 16:09

jpd


I had the same problem - I wanted to fold arbitrary selections as in Textmate.

For Atom on the Mac at least ctrl-option-command-F works!

like image 34
Giant Ravens Avatar answered Sep 21 '22 16:09

Giant Ravens