[英]How do I force Sublime Text 2 to use a tab of 3 spaces in PHP files?
在我的一些PHP文件中,Sublime顯示相隔2個字符的垂直線(制表位?),其他文件默認使這些垂直線相隔3個字符(我的首選標簽長度)。
下面可以看到垂直線(這些線相隔3個字符):
[注意我無法發布截圖,因為我沒有足夠的分數!]
我的用戶首選項文件如下:
{
"draw_white_space": "none",
"ignored_packages":
[
"Vintage"
],
"tab_size": 3,
"translate_tabs_to_spaces": true,
"detect_indentation": false,
"smart_indent": false,
"use_tab_stops": false,
"trim_trailing_white_space_on_save": true,
"fallback_encoding": "UTF-8",
"rulers": [80, 120]
}
我嘗試了detect_indentation,smart_indent和use_tab_stops的不同排列,即完全省略和true / false等。這沒有任何區別。
我真的很驚訝:a)不同的PHP文件之間存在不一致,即一些默認情況下具有2個字符的垂直線和其他3個字符。 b)用戶設置沒有我期望的效果。
任何Sublime Text 2專家都知道如何將這些垂直線默認為我的標簽寬度設置?
非常感謝。
因為這是指PHP中的特定語法,所以必須將設置直接保存在“特定於語法”的設置文件中。 打開packages文件夾中的Packages/User/PHP.sublime-settings
文件並編寫以下內容:
{
"tab_size": 3,
"translate_tabs_to_spaces": true,
"detect_indentation": false
}
但是,如果您希望所有代碼(即不僅僅是PHP) 都像這樣,請將其放在Packages/User/Preferences.sublime-settings
文件中。
這兩種方法都是valids,但我認為你應該知道Preferences.sublime-settings
文件,這是所有環境的默認首選項。
你可以訪問Preferences.sublime-settings
去:
Prefenrences>設置 - 默認
在主菜單上。 或訪問路徑:
/home/<user_name>/.config/sublime-text-3/Packages/Default/Preferences.sublime-settings
對於Linux用戶,但在其他操作系統中,除了訪問目錄的特殊性之外,系統的結構相似。 像Windowns C:\\\\Programs Files\\Sublime Text 3\\[...]
Preferences.sublime-settings文件已經預先定義了許多參數,您只需根據自己的喜好分配值即可。 通常,可能值的范圍是true,false或numeric。
對於你的情況,你應該改變"tab_size"
的值,默認情況下它接收4個空格作為值 - 它非常適合Python程序員),只需更改為所需的值。
// Set to true to turn spell checking on by default
"spell_check": false,
// The number of spaces a tab is considered equal to
"tab_size": 4,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
// If translate_tabs_to_spaces is true, use_tab_stops will make tab and
// backspace insert/delete up to the next tabstop
"use_tab_stops": true,
我一直喜歡的設置更改值是:
"translate_tabs_to_spaces": true, //prevents that to switch from editor the indentation be changed.
"highlight_line": true, //highlights the line where the course is.
"auto_complete_commit_on_tab": true, //allows complement of code structure with tab key.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.