Block indent


#1

Is there a way to select a block of code and have all lines indent the same amount to the left or right?


#2

Don’t TAB and SHIFT-TAB do that?


#3

Also CMD+[ and CMD+] on OSX…


#4

And CTRL-[ and CTRL-] on non-macs


#5

TAB only shifts the entire block.


#6

I don’t understand. Isn’t that what you asked for?


#7

If you want to align all the lines too, you can shift them all left first until they’re all at the left margin, then shift them all right to where you want them.


#8

For example if i have:

fields: {
            username: {
                validators: {
                    notEmpty: {
                        message: 'The username is required and cannot be empty'
                    }
                }
            },
            password: {
                validators: {
                    notEmpty: {
                        message: 'The password is required and cannot be empty'
                    }
                }
            },
            email: {
                // Initially, the validators of this field are disabled
                enabled: false,
                validators: {
                    notEmpty: {
                        message: 'The email address is required and cannot be empty'
                    },
                    emailAddress: {
                        message: 'The email address is not valid'
                    }
                }
            }

Each line is tabbed over 2, I would like to select the entire block and indent all lines at the same time.


#9

If you select the block and press Tab that will indent all the lines at the same time by one additional tab length.


#10

Indent right: press tab
indent left: shift tab

hope that helps


#11

Use Alt+Shift+Up/Down(arrow keys) to create multiple cursors, then add or delete space/tabs. You can also use Ctrl+click with mouse to create multiple cursors.
https://flight-manual.atom.io/using-atom/sections/editing-and-deleting-text/#multiple-cursors-and-selections


#12

You might be interested to know:

Ctrl-[ and Ctrl-] works very well for indent and outdent of a selected block of code.


#13

That is very helpful to know, thank you!