Sublime Text (v 2.0) - how do I stop auto indentat

2020-06-23 05:31发布

问题:

I'm trying to make the jump from Notepad++ to Sublime Text 2. However one issue is stopping me from doing so:

When working in CSS, JavaScript or PHP - whenever I type a bracket and press [ENTER], an extra indentation is added. E.g. below show's you where the caret ends up if I type a bracket and press enter:

    {
        |

I need the caret to appear at the same horizontal point as the bracket, like so:

    {
    |

I've tried messing with the indentation settings to no avail. Here are my current User Settings:

{
"auto_indent": true,
"auto_match_enabled": false,
"bold_folder_labels": true,
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"detect_indentation": false,
"font_face": "Courier New",
"font_size": 10,
"highlight_modified_tabs": true,
"ignored_packages":
[
    "Vintage"
],
"indent_to_bracket": false,
"line_padding_bottom": 1,
"line_padding_top": 1,
"smart_indent": false,
"trim_automatic_white_space": false
}

UPDATE: if I set auto_indent to false, this creates a different problem. In this case, the caret will always be placed at the very beginning of the line. E.g.

        {
|

I've also tried playing with the files in Packages/JavaScript to no avail.

Would really appreciate a solution as I really want to start using this editor!

Thanks.

回答1:

Change the value for auto_indent to false. That'll fix it for you!



回答2:

I found that if you use SHIFT+Enter you get what you want.



回答3:

To prevent "smart" indentation or automatic next/extra level indentation in e.g. Ruby you need to edit the %AppData%\Sublime Text 2\Packages\Ruby\Miscellaneous.tmPreferences file, not the %AppData%\Sublime Text 2\Packages\Default\Indentation Rules.tmPreferences file, despite of presence of settings like increaseIndentPattern in both. That is, editing the latter (commenting out the tag insides, for example) won't take any effect. Valid for version 2.0.1.