3 回答

TA貢獻(xiàn)34條經(jīng)驗(yàn) 獲得超21個(gè)贊
Sublime Alignment 主要用于代碼對(duì)齊,最新版據(jù)說已經(jīng)集成了這個(gè)插件,你不妨下載Sublime3試試
具體部署:
左上角Sublime Text -> Preferences -> Package Settings ->Alignment 如果沒有最后的"Alignment"選項(xiàng),說明你還沒有安裝此插件。
這里面有5個(gè)選項(xiàng):
Settings- Default
Settings- User
Settings- Syntax Specific - User
Key Bildings - Default
Key Bildings - User
帶有后綴Default的,為默認(rèn)設(shè)置,每次升級(jí)插件都會(huì)重置這里的設(shè)置。所以盡量不要修改這里,否則升級(jí)會(huì)丟失你原先的設(shè)置。
帶有后綴User的,為用戶自定義設(shè)置,你可以把Default里面的設(shè)置全部復(fù)制一份到這里,然后再修改,這里存在的設(shè)置選項(xiàng)會(huì)覆蓋Default里面的,即User的優(yōu)先級(jí)更高。
Key Bildings為快捷鍵設(shè)置,默認(rèn)的快捷鍵很有可能因?yàn)楹推渌旖萱I沖突而無效, 所以及可以在Key Bildings - User里重新設(shè)置(格式可以仿照Default里的寫法)。
此快捷鍵是用來 實(shí)現(xiàn)對(duì)齊的。
默認(rèn)設(shè)置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":開關(guān)量,默認(rèn)為true,??true,則把選擇的多行的 不同縮進(jìn)級(jí)別也變成相同的縮進(jìn)(最大的縮緊級(jí)別)flase,只是對(duì)齊,不改變縮進(jìn)級(jí)別
"mid_line_tabs"開關(guān)量,默認(rèn)為false。如果你的文本是使用Tab鍵縮進(jìn)排版,設(shè)置該變量為true時(shí),那么該插件在對(duì)齊文本的時(shí)候也使用Tab鍵來對(duì)齊縮進(jìn)。但是這樣可能會(huì)出現(xiàn)問題,因?yàn)門ab鍵在不同的編輯器上代表的空格數(shù)可能不同(Sublime 是代表4個(gè)空格), 當(dāng)你使用別的編輯器打開該文件時(shí),簡(jiǎn)而言之,就是排版可能就不是對(duì)齊的了。
"alignment_chars"即對(duì)齊字符這是一個(gè)數(shù)組,可以這樣設(shè)置多個(gè)字符:alignment_chars": ["=","*","a"]
默認(rèn)只有“=”字符,即alignment_chars": ["="]
數(shù)組里面的字符就是放在中線對(duì)齊的字符。
"alignment_space_chars"和"alignment_chars"一樣,也是數(shù)組格式 默認(rèn)值包含“=”號(hào),即:alignment_space_chars": ["*","="]就是這個(gè)數(shù)組包含上面"alignment_chars"里的字符, 對(duì)齊后,在其前面增加一個(gè)空格。如果這里不包含"alignment_chars"里的字符,對(duì)齊后,在其前面沒有空格。可以這樣說, "alignment_space_chars"數(shù)組是"alignment_chars"數(shù)組的子集。
"alignment_prefix_chars"前綴字符 對(duì)齊字符(即alignment_chars"里的字符),可以擁有前綴字符。例如"="號(hào)字符前可以擁有以上字符作為前綴
可按照以上的參數(shù)說明,自己增加對(duì)齊的字符來增強(qiáng)功能。
我一般需要在對(duì)齊字符前面增加一個(gè)空格,
所以我一般就保持alignment_chars 數(shù)組和 alignment_space_chars數(shù)組一致。即在所有的對(duì)齊字符前面都增加一個(gè)空格。
添加回答
舉報(bào)