3 回答

TA貢獻34條經驗 獲得超21個贊
Sublime Alignment 主要用于代碼對齊,最新版據說已經集成了這個插件,你不妨下載Sublime3試試
具體部署:
左上角Sublime Text -> Preferences -> Package Settings ->Alignment 如果沒有最后的"Alignment"選項,說明你還沒有安裝此插件。
這里面有5個選項:
Settings- Default
Settings- User
Settings- Syntax Specific - User
Key Bildings - Default
Key Bildings - User
帶有后綴Default的,為默認設置,每次升級插件都會重置這里的設置。所以盡量不要修改這里,否則升級會丟失你原先的設置。
帶有后綴User的,為用戶自定義設置,你可以把Default里面的設置全部復制一份到這里,然后再修改,這里存在的設置選項會覆蓋Default里面的,即User的優先級更高。
Key Bildings為快捷鍵設置,默認的快捷鍵很有可能因為和其他快捷鍵沖突而無效, 所以及可以在Key Bildings - User里重新設置(格式可以仿照Default里的寫法)。
此快捷鍵是用來 實現對齊的。
默認設置Settings- Default:
{ ????//?If?the?indent?level?of?a?multi-line?selection?should?be?aligned ????"align_indent":?true, ????//?If?indentation?is?done?via?tabs,?set?this?to?true?to?also?align ????//?mid-line?characters?via?tabs.?This?may?cause?alignment?issues?when ????//?viewing?the?file?in?an?editor?with?different?tab?width?settings.?This ????//?will?also?cause?multi-character?operators?to?be?left-aligned?to?the ????//?first?character?in?the?operator?instead?of?the?character?from?the ????//?"alignment_chars"?setting. ????"mid_line_tabs":?false, ????//?The?mid-line?characters?to?align?in?a?multi-line?selection,?changing ????//?this?to?an?empty?array?will?disable?mid-line?alignment ????"alignment_chars":?["="], ????//?If?the?following?character?is?matched?for?alignment,?insert?a?space ????//?before?it?in?the?final?alignment ????"alignment_space_chars":?["="], ????//?The?characters?to?align?along?with?"alignment_chars" ????//?For?instance?if?the?=?is?to?be?aligned,?there?are?a?number?of ????//?symbols?that?can?be?combined?with?the?=?to?make?an?operator,?and?all ????//?of?those?must?be?kept?next?to?the?=?for?the?operator?to?be?parsed ????"alignment_prefix_chars":?[ ????????"+",?"-",?"&",?"|",?"<",?">",?"!",?"~",?"%",?"/",?"*",?"." ????] }
"align_indent":開關量,默認為true,??true,則把選擇的多行的 不同縮進級別也變成相同的縮進(最大的縮緊級別)flase,只是對齊,不改變縮進級別
"mid_line_tabs"開關量,默認為false。如果你的文本是使用Tab鍵縮進排版,設置該變量為true時,那么該插件在對齊文本的時候也使用Tab鍵來對齊縮進。但是這樣可能會出現問題,因為Tab鍵在不同的編輯器上代表的空格數可能不同(Sublime 是代表4個空格), 當你使用別的編輯器打開該文件時,簡而言之,就是排版可能就不是對齊的了。
"alignment_chars"即對齊字符這是一個數組,可以這樣設置多個字符:alignment_chars": ["=","*","a"]
默認只有“=”字符,即alignment_chars": ["="]
數組里面的字符就是放在中線對齊的字符。
"alignment_space_chars"和"alignment_chars"一樣,也是數組格式 默認值包含“=”號,即:alignment_space_chars": ["*","="]就是這個數組包含上面"alignment_chars"里的字符, 對齊后,在其前面增加一個空格。如果這里不包含"alignment_chars"里的字符,對齊后,在其前面沒有空格??梢赃@樣說, "alignment_space_chars"數組是"alignment_chars"數組的子集。
"alignment_prefix_chars"前綴字符 對齊字符(即alignment_chars"里的字符),可以擁有前綴字符。例如"="號字符前可以擁有以上字符作為前綴
可按照以上的參數說明,自己增加對齊的字符來增強功能。
我一般需要在對齊字符前面增加一個空格,
所以我一般就保持alignment_chars 數組和 alignment_space_chars數組一致。即在所有的對齊字符前面都增加一個空格。
- 3 回答
- 0 關注
- 13729 瀏覽
添加回答
舉報