javascript - sublime text 新行丢失缩进

标签 javascript sublimetext2 indentation

我有一个问题导致我在 sublime text 中有很多额外的击键。当我创建几行时,缩进是正确的。但是,如果我向上箭头回到那些新行,缩进就消失了,我回到了位置 0(所有文件格式都会发生)。我做错了吗,这是预期的行为吗?我喜欢我的代码中有空格,所以这很痛苦。

重新创建: 编写功能代码例如

    function Bob(){
        | indent starts here
    }

一切顺利。然后我添加了几行,向上箭头回到中间,我得到了这个:

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

我愿意:

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

除了改变我的编码风格之外,请提出任何建议 :-) 谢谢。

编辑:显然这不是预期的行为。下面列出了首选项和插件,以防它们产生干扰。

用户偏好:

{
"auto_complete": true,
"auto_complete_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
}

插件:

  • 埃米特
  • GitGutter
  • 包控制
  • PyV8
  • 萨斯
  • SFTP
  • 侧边栏改进
  • 主题 - 汽水

最佳答案

将以下内容添加到您的首选项中,您应该已经准备就绪:

"trim_automatic_white_space": false,

默认值为 true,当设置它时,它会在将插入符号移出行时 trim auto_indent 添加的空白。

关于javascript - sublime text 新行丢失缩进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20246170/

相关文章:

java - 使用 Apache Batik 纠正 SVG 文件的缩进( pretty-print )

python - 为什么会抛出缩进错误?

vim - 如何在 Vim 中快速选择(内部)行

javascript - 如何将悬停叠加到 flex 容器中的 flex 元素

javascript - Firefox 中具有可调整大小列的 JQuery UI 表性能问题

java - Sublime Text 2 - 开箱即用编译和运行 Java 程序

sublimetext2 - 使用 Sublime Text 将多行合并为一行

java - 如何使用 XML 从站点生成 HTML

javascript - 制作一个简单的图像切换器

ruby-on-rails - 使用自定义 url 方案打开 sublime