Sublime文本缩进设置被文件覆盖 [英] Sublime Text Indentation Settings Being Overwritten By a File

查看:97
本文介绍了Sublime文本缩进设置被文件覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,制表符的大小应该为4,制表符不应为空格.我将自己的Preferences.sublime-settings文件更新为包含

 "detect_indentation":"false","tab_size":4"translate_tabs_to_spaces":否, 

当我打开一个新文件时,这些设置将设置为我想要的方式,并且一切正常.但是,如果我打开一个缩进为2个空格的现有文件(scss或html),则我的Sublime设置将被覆盖,并且缩进会更改为2个空格.如果单击视图">缩进",我会看到制表符大小"设置为2,并且启用了使用空格缩进",即使我的首选项设置与此相反.

如果我通过视图">缩进"将缩进"手动更改为制表符宽度:4",然后取消选择使用空格缩进",则该操作一直有效,直到我保存文件为止,此时设置恢复为制表符宽度2"并且使用空格缩进"处于打开状态.>

如何强制Sublime Text遵守我的缩进首选项而不被其他文件覆盖.我认为Sublime正在检测页面上的缩进,但是我已经关闭了该设置.

这是我的偏好设置文件,该文件显示一切正常:

这是scss文件的混乱设置.我所做的就是打开它:

我认为没有插件引起此问题,我禁用了大多数插件,但仍然遇到此问题.但是,作为参考,这是我已安装的所有软件包的列表:

  • 对齐方式
  • BracketHighlighter
  • 水豚摘录
  • ColorPicker
  • 点文件语法突出显示
  • EditorConfig
  • Emmet
  • ERB代码段
  • 宝石浏览器
  • 要旨
  • Git
  • GitGutter
  • Haml
  • jQuery
  • JSHint
  • 包装控制
  • 漂亮的JSON
  • PyV8
  • RSpec
  • SCSS
  • SideBarEnahancements
  • SublimeLinter
  • 端子
  • TrailingSpaces

在此先感谢您的帮助.

解决方案

因此,我通过完全卸载Sublime Text和所有关联的程序包和设置,然后重新安装该应用程序以及一个接一个地重新安装我的程序包,来解决此问题.事实证明,我的其中一个软件包 EditorConfig 覆盖了我的Sublime Text样式设置.

EditorConfig实际上是一个非常酷的插件,通过定义缩进类型,大小,字符集和其他设置,允许多个开发人员在多个IDE上的一个项目中使用一致的样式.

我的问题的答案是,在特定的项目目录中,我正在下载的某些节点模块的 .editorconfig 文件的缩进设置为大小2,并且使用空格而不是制表符.我必须从Sublime Text中卸载EditorConfig软件包,或者在项目的根目录中创建一个新的 .editorConfig 文件.这是我创建的用于修复问题的 .editorConfig 文件.

 #最顶层的EditorConfig文件根=真#4制表符缩进indent_style =制表符indent_size = 4 

I am working on a project where tab size is supposed to be 4 and tabs should not be spaces. I updated my Preferences.sublime-settings file to include

"detect_indentation": "false",
"tab_size": 4,
"translate_tabs_to_spaces": false,

When I open a new file these settings are set to how I want and everything works. However, if I open an existing file (scss or html) that has indentations as 2 spaces, my Sublime settings are overwritten and indentations change to 2 spaces. If I click View > Indentation I see that Tab Size is set to 2 and Indent Using Spaces is enabled, even though my preferences should be the opposite of that.

If I manually change Indentation via View > Indentation to Tab Width: 4 and deselect Indent Using Spaces, this works until I save the file, at which point the settings revert to Tab Width 2 and Indent Using Spaces turned on.

How can I force Sublime Text to honor my indentation preferences and not be overwritten by another file. I would assume that Sublime is detecting the indentations on the page, but I've turned that setting off.

Here is my preferences file showing that things should be working:

Here are the messed up settings for a scss file. All I did was open it:

I don't think any plugin is causing this, I disabled most of them and was still experiencing this issue. However, for reference, here is a list of all packages I have installed:

  • Alignment
  • BracketHighlighter
  • Capybara Snippets
  • ColorPicker
  • Dotfiles Syntax Highlighting
  • EditorConfig
  • Emmet
  • ERB Snippets
  • Gem Browser
  • Gist
  • Git
  • GitGutter
  • Haml
  • jQuery
  • JSHint
  • Package Control
  • Pretty JSON
  • PyV8
  • RSpec
  • SCSS
  • SideBarEnahancements
  • SublimeLinter
  • Terminal
  • TrailingSpaces

Thanks in advance for any help.

解决方案

So I figured this out by completely uninstalling Sublime Text and all associated packages and settings, then reinstalling the app and one-by-one reinstalling my packages. It turns out that one of my packages, EditorConfig, was overwriting my Sublime Text style settings.

EditorConfig is actually a really cool plugin that allows a number of developers working on one project across multiple IDEs to have a consistent style by defining indentation type, size, charset, and other settings.

The answer to my problem was that in the particular project directory I was working some of the node modules I had downloaded had .editorconfig files that had indentation set as size 2 and spaces instead of tabs. I had to either uninstall the EditorConfig package from my Sublime Text or create a new .editorConfig file in the root directory of my project. This is the .editorConfig file I created that fixed my problem.

# top-most EditorConfig file
root = true

# 4 Tab Indentation
indent_style = tab
indent_size = 4

这篇关于Sublime文本缩进设置被文件覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆