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