douyin6188
2018-04-25 16:44
浏览 225
已采纳

如何修复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.

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

enter image description here

图片转代码服务由CSDN问答提供 功能建议

我注意到我的PHP Laravel项目中的一个文件在我的Sublime Text 3中显示出奇怪的行不对。

两个文件都在同一个项目中,但我不确定一个文件显示的行多于其他项目。

有没有办法在Sublime中解决这个问题? 有没有办法修复文件缩进?

< img src =“https://i.stack.imgur.com/WsTdj.jpg”alt =“在此输入图像说明”>

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doty58493 2018-04-25 20:13
    已采纳

    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,
    

    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.

    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.

    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.

    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.

    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.

    点赞 打赏 评论

相关推荐 更多相似问题