如何在Sublime Text 3中解决项目缩进不一致的问题? [英] How to fix inconsistent indentation of a project in Sublime Text 3?

查看:292
本文介绍了如何在Sublime Text 3中解决项目缩进不一致的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到我的PHP Laravel项目中的一个文件在Sublime Text 3中一直显示奇怪的行.

I notice one of the file in my PHP Laravel project kept showing weird lines indetation in my Sublime Text 3.

两个文件都在同一个项目中,但是我不确定一个文件是否比另一个文件显示更多的行.

Both file in the same project, but I am not sure one show a lot more line than other.

是否有办法在Sublime中解决此问题?有没有办法解决文件缩进问题?

Is there a way to fix this in Sublime? Is there a way to fix the file indentation?

推荐答案

在某些情况下,文件似乎没有根据您的设置所期望的缩进,罪魁祸首通常是该设置:

In situations where files don't seem to have the indentation that you would expect them to have based on your settings, the culprit is generally this setting:

// Set to false to disable detection of tabs vs. spaces on load
"detect_indentation": true,

这默认情况下是打开的,这使Sublime尝试在打开文件时检测文件的缩进.检测可以使其认为文件应使用制表符而不是空格(反之亦然),并使其认为tab_size不是您所期望的.

This defaults to being turned on, which makes Sublime attempt to detect the indentation of a file when you open it. The detection can cause it to assume that the file should use tabs instead of spaces (or vice versa), as well as making it think the tab_size is not what you expect.

在您的屏幕截图中,看起来至少是第二个发生在您身上;选项卡的大小看起来像是设置为2而不是4.

In your screenshot it looks like at a minimum the second is what's happening to you; the tab size looks like it's set to 2 instead of 4.

如果您在打开文件时观看状态行,则可以看到它在其中生成一条消息,如Detect Indentation: setting indentation to 2或沿这些行的内容.

If you watch the status line when you open a file, you can see it generating a message there like Detect Indentation: setting indentation to 2 or something along those lines.

可以在Default包中的detect_indentation.py插件中找到有关自动检测工作原理的详细信息,但粗略地说,它是通过查看用制表符缩进多少行而不是空格缩进来确定缩进的检查常见的缩进大小.

The specifics for how the auto-detection works can be found in the detect_indentation.py plugin in the Default package, but roughly speaking it determines the indentation by seeing how many lines are indented with tabs versus with spaces as well as checking for common indent sizes.

在大多数情况下,关闭设置并重新打开文件即可解决此问题.如果由于缩进停留在旧级别而仍不能解决问题,则可能需要利用Convert Indentation命令,您可以在单击状态行部分时在打开的菜单中找到Convert Indentation命令告诉您它是如何缩进的.

Turning the setting off and re-opening the file clears the problem in most cases. If that still doesn't solve the problem because the indent is stuck at the old level, you may need to avail yourself of the Convert Indentation commands that you can find in the menu that opens when you click on the part of the status line that tells you how it's indenting things.

这篇关于如何在Sublime Text 3中解决项目缩进不一致的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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