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.

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

报告相同问题?

悬赏问题

  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答