Question

When using HTML syntax mode in Sublime Text, I see what appears to be erroneous behavior. However, I've exhausted Google trying to find any mention of the same issue. The image explains it best:

Sublime indentation issue

You'll note that in each instance, the cursor starts at the correct location (one tab in from the current tag). However, the indentation immediately shifts to the left when typing begins.

I've compared this behavior to Coda and Atom, but neither have this issue. Sublime Text 3 is up to date. The same behavior occurs with the default theme or a custom theme.

I realize there are shortcuts that can be used (div + tab + enter for example), but that doesn't help when editing an existing file where the elements are already present.

Any idea how to stop Sublime from unindenting like this?

Edit: Here is the contents of Preferences > Settings - User:

{
    "auto_match_enabled": false,
    "color_scheme": "Packages/Theme - Spacegray/base16-ocean.dark.tmTheme",
    "font_size": 14,
    "highlight_line": true,
    "ignored_packages":
    [
        "Vintage"
    ],
    "open_files_in_new_window": false,
    "theme": "Spacegray.sublime-theme",
    "trim_trailing_white_space_on_save": true,
    "word_wrap": false
}
Was it helpful?

Solution

I recently asked a similar question at Sublime Text isn't indenting properly with HTML.

Try installing the Emmet package. It allows you to write HTML in a much more efficient way, but also has its own indentation configuration. Typing anytagTab gives you the properly indented text.

An example without Emmet.

autoindentation problem in HTML

An example with Emmet.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top