如何强制Sublime Text在每个标签上缩进两个空格? [英] How do I force Sublime Text to indent two spaces per tab?

查看:150
本文介绍了如何强制Sublime Text在每个标签上缩进两个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Ruby文件时,是否有一种方法可以强制Sublime Text 2在每个选项卡上始终缩进两个空格?

Is there a way to force Sublime Text 2 to always indent two spaces per tab when working with Ruby files?

我知道可以在视图->缩进菜单选项,但不会粘滞。每次我打开一个新文件并单击Tab时,它都会还原为四个空格。

I know that indentation can be set under the view -> indentation menu option, but it does not stick. Every time I open a new file and hit tab, it reverts back to four spaces.

推荐答案

如果要用于所有文件,请转到首选项->设置-默认/用户。但是如下面的几条注释所示,语法特定设置可以将其限制为您选择的语言。

If you want it for all files, go to Preferences -> Settings - Default/User. But as several comments below indicate, Syntax Specific settings can limit it to just the languages you choose.

要将此配置限制为Ruby文件,请先在编辑器,然后转到首选项->设置-语法特定。这应该会打开一个名为 Ruby.sublime-settings

To limit this configuration to Ruby files, first open up a Ruby file in the editor, and then go to Preferences -> Settings - Syntax Specific. This should open a settings window named Ruby.sublime-settings

保存以下设置的设置窗口:

Save these settings:

{
  "tab_size": 2,
  "translate_tabs_to_spaces": true,
  "detect_indentation": false
}

通过打开该类型的文件并返回到

Repeat for any other syntax types by opening a file of that type and going back to the preferences to open the correct preferences file for that syntax.

我已经对其进行了编辑,以使注释中的每个请求都包含 detect_indentation行;我以前使用默认值/用户来设置我的标签大小,并且不需要标签检测,但是这是由于全局配置还是由于我很少打开带有标签的文件,我不知道。 / em>

I have edited this to include the "detect_indentation" line per the requests in comments; I previously used the Default/User to set my tab size, and have not needed the tab detection, but whether that is due to the global config or due to the fact that I have rarely opened files with tabs, I do not know.

虽然在某些情况下重新启动,但不必重新启动。

Restarting should not be necessary, although in some instances it can be.

这篇关于如何强制Sublime Text在每个标签上缩进两个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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