Sublime Forum

Indent selection behavior: indent blank lines as well?

#1

Hi,

When indenting selections with the Tab key, I would like blank lines to be indented as well (currently they remain blank). (cf. attached screenshot)

Is there a configuration option to do that?

Cheers,

Julien




2 Likes

#2

Bump :smile:

By the way, for what it’s worth, the desired behavior I described is also the behavior in TextMate.

0 Likes

#3

add this to your user config file -** “auto_indent”: true, “trim_automatic_white_space”: false**

0 Likes

#4

I remember this working for me in Sublime Text 2, but these settings no longer have the same behaviour in Sublime Text 3. :cry:

0 Likes

#5

For what it’s worth, trim_automatic_white_space is currently supported in Sublime 3, and the default value is true. Turning it off results in the originally desired behaviour.

0 Likes

#6

it doesn’t seem to for me… ST3 build 3120.

  1. set "trim_automatic_white_space": false in your user preferences
  2. create a new tab
  3. type lorem TabEnterEnter lorem Tab
  4. select all
  5. Tab

line 7 remains unindented

0 Likes

#7

You’re right, and I didn’t try that case. It appears that if a line is entirely empty, it will not get indented when you increase the indentation level. If a line consists of only tabs, though, then it will be indented as lines with non-whitespace characters are.

See: lorem tab, enter, tab, enter lorem tab (not sure how to do the buttons)

Then select all and indent. Line seven should have two tabs on it.

Using 3114, but I doubt it’s changed.

1 Like

#8

confirmed. the "trim_automatic_white_space" setting seems to make no difference. indeed, it does say that it should trim white space added by auto_indent when moving the caret off the line., which kinda implies that if the caret was never on the line then it shouldn’t affect it.

0 Likes

#9

Ah, you’re right. I must have accidentally checked the two different cases when I previously “confirmed” it working.

0 Likes

#10

I can confirm, this issue is still persistent, as of 2/11/21 public build #3210.
I also agree that the issue is isolated to:
Upon pressing tab / triggering indent, empty/blank lines within a multi-line selection, are not indented.

Here’s a list of all my settings, pertaining to tabs and/or indentation:

“auto_indent”: true,
“detect_indentation”: true,
“indent_to_bracket”: false,
“smart_indent”: false,
“tab_completion”: false,
“tab_size”: 2,
“translate_tabs_to_spaces”: false,
“trim_automatic_white_space”: false,
“trim_trailing_white_space_on_save”: false,
“use_tab_stops”: true,

What I end up doing, to remedy, is:

  1. Make your target selection, copy it to a new tab
  2. Open Find & Replace ([^]+[h] or via the menu: Find > Replace… )
  3. Ensure REGEX / Regular Expression pattern matching is enabled (/Re), then:
  • Find: ^
  • Replace: \t
  • Click Replace All
  1. Select all, copy, move back to the original tab and paste over the original selection.
0 Likes