Sublime Forum

Solved -- New User - having Problems with Indent Settings in S3

#1

Hi there,
I am new to the forum and also new to S3. My English can be scary because English is not my mother tongue. Please be lenient with me: thoughtful:.
I have many HTML pages (almost 3000) in my web portal that I created in 2017. At the beginning I wrote the pages without meaningful indentation. Since I currently want to (have to) automate a few steps, I started to switch to a uniform template, for which S3 is the most powerful and useful editor for me. After changing over 120 pages, I had to make some changes to the template and noticed that there was a problem between automation and indentation.
S3 has great indentation tools, but my version has limited functionality for it.
I can make settings, but none of the following key combinations works!


Do I have to activate anything in the user settings or at another location in order to use this function? I probably missed something because of the language barrier.

Greetings from Germany
Andreas

0 Likes

#2

Tha indention feature in Sublime Text works based on regexp patterns. It detects opening and closing tags to determine when to increase or decrease the indention level while typing or to drive the Reindent command.

Example:

If you select a piece of html source like …

<table>
<tr>
<td></td>
</tr>
</table>

… and call Reindent, it will increase the indenditon level after each opening tag and decrease it after each closing one, which results in …

<table>
    <tr>
        <td></td>
    </tr>
</table>

But it won’t do code beautification beyond that. It won’t add newlines etc. to templates like the following in order to insert proper indented/beautified source.

<table><tr><td></td></tr></table>

That said, some more information about what you want to achieve and some snippets of source (current style -> desired style) would help to provide more specific support.

0 Likes

#3

Hi,
thanks for reply. Yes, that works with reindent if i mark a TAG-Group like your example.
But if I want 1 line with the shortcut Ctrl + [ indented does not work as in the video here Sublime Text3 settings indent (start at 3:08). It also doesn’t work with the shortcut the other way Ctrl +]
Likewise, I still have a problem with global indentation settings.
My Tab-Size is default

// The number of spaces a tab is considered equal to
“tab_size”: 4,

I have different settings regarding TAB or Spaces on the almost 3000 websites. Most look like this

Do I have to set each individual page like the picture on the left or is there a global setting in Sublime that would relieve me of this effort?

Regards Andreas

0 Likes

#4

key bindings

What you need to keep in mind with regards of key bindings is: ST only knows the english keyboard layout. It doesn’t map to german or any other layouts. This means, you need to know which key is used for the [ on the english keyboard. It’s the ´ on the german layout - the one left of the backspace key.

That said, I find those key combinations terrible. I personally set "shift_tab_unindent": true, in the preferences and use tab to indent and shift+tab decrease the indention level, which is much more natural on a Windows system.

indention settings

Sublime Text tries to auto detect the indention settings by default. This is the reason for you to see different settings in different files. It reads the first couple of lines and uses some heuristics to determine whether indention is done via tabs or spaces etc.

The default heuristics are sometimes not too accurate in ST3. Hence I personally prefer to use the AutoSetIndentation plugin. Via "detect_indentation": false ST is told not to do indention detection, then.

If you just want to prevent ST from auto-detecting the indention, you can simply set "detect_indentation": false without installing the plugin. ST uses the tab_size setting then.

0 Likes

#5

Hi,
thx for the hints. The thread can be closed.

regards
Andreas

0 Likes