admin管理员组

文章数量:1287625

I have a problem that is causing me lots of extra keystrokes in sublime text. When I create a couple of new lines, the indentation is correct. However, if I up arrow back to those new lines, the indentation is gone and I am back at position 0 (happens for all file formats). Am I doing it wrong, is this intended behaviour? I like white space in my code so this is a pain.

Recreating: Write function code e.g.

    function Bob(){
        | indent starts here
    }

All good. I then add a couple of new lines, up arrow back to the middle and I get this:

    function Bob(){
| indent starts here
| indent starts here
        | indent starts here
    }

I would like:

    function Bob(){
        | indent starts here
        | indent starts here
        | indent starts here
    }

Any suggestions please - apart from changing my coding style :-) Thanks.

Edit: apparently this is not expected behaviour. Preferences and plugins listed below in case they are interfering.

User preferences:

{
"auto_plete": true,
"auto_plete_with_fields": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"detect_indentation": true,
"draw_minimap_border": true,
"fade_fold_buttons": true,
"folder_exclude_patterns":
[
    ".svn",
    ".git",
    ".hg",
    "CVS",
    "tmp",
    ".tmp",
    ".bundle",
    ".sass-cache"
],
"highlight_modified_tabs": true,
"ignored_packages":
[
    "Vintage"
],
"line_padding_bottom": 1,
"line_padding_top": 1,
"soda_classic_tabs": true,
"tab_size": 4,
"theme": "Soda Light.sublime-theme",
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true,
"wrap_width": 200
}

Plugins:

  • Emmet
  • GitGutter
  • Package Control
  • PyV8
  • Sass
  • SFTP
  • Sidebar enhancements
  • Theme - soda

I have a problem that is causing me lots of extra keystrokes in sublime text. When I create a couple of new lines, the indentation is correct. However, if I up arrow back to those new lines, the indentation is gone and I am back at position 0 (happens for all file formats). Am I doing it wrong, is this intended behaviour? I like white space in my code so this is a pain.

Recreating: Write function code e.g.

    function Bob(){
        | indent starts here
    }

All good. I then add a couple of new lines, up arrow back to the middle and I get this:

    function Bob(){
| indent starts here
| indent starts here
        | indent starts here
    }

I would like:

    function Bob(){
        | indent starts here
        | indent starts here
        | indent starts here
    }

Any suggestions please - apart from changing my coding style :-) Thanks.

Edit: apparently this is not expected behaviour. Preferences and plugins listed below in case they are interfering.

User preferences:

{
"auto_plete": true,
"auto_plete_with_fields": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"detect_indentation": true,
"draw_minimap_border": true,
"fade_fold_buttons": true,
"folder_exclude_patterns":
[
    ".svn",
    ".git",
    ".hg",
    "CVS",
    "tmp",
    ".tmp",
    ".bundle",
    ".sass-cache"
],
"highlight_modified_tabs": true,
"ignored_packages":
[
    "Vintage"
],
"line_padding_bottom": 1,
"line_padding_top": 1,
"soda_classic_tabs": true,
"tab_size": 4,
"theme": "Soda Light.sublime-theme",
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true,
"wrap_width": 200
}

Plugins:

  • Emmet
  • GitGutter
  • Package Control
  • PyV8
  • Sass
  • SFTP
  • Sidebar enhancements
  • Theme - soda
Share Improve this question edited Nov 27, 2013 at 16:17 Websemantic asked Nov 27, 2013 at 15:15 WebsemanticWebsemantic 4247 silver badges13 bronze badges 2
  • please edit your question and add the contents of your Preferences -> Settings - User file, and also list any plugins you have installed. Your "desired" behavior is what I'm getting with both ST2 and ST3. – MattDMo Commented Nov 27, 2013 at 15:51
  • Ah, good to know, will do. – Websemantic Commented Nov 27, 2013 at 16:09
Add a ment  | 

1 Answer 1

Reset to default 14

Add the following to your preferences and you should be all set:

"trim_automatic_white_space": false,

The default is true, and when set it trims white space added by auto_indent when moving the caret off the line.

本文标签: javascriptsublime text new line loses indentStack Overflow