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

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

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置