2013-12-20 38 views
0

我經常從客戶端獲取文本,並希望快速格式化帶有html標籤的文本,並將每個文本行包裝爲指定的字符數。我剛剛安裝了Sublime Text 2,它非常好,但我真正想做的事情之一我不明白。Sublime Text 2 and Emmet and wrapping lines

我想要採取長段落,將段落換成段落p標記,然後換行以便它們不會跑出屏幕。所以這裏是我在做什麼:

  1. 從我的客戶端複製並粘貼文本到編輯器(本例爲2段)。

  2. 選擇文本。

  3. 使用Emmet,輸入「p *」,將p標籤放在每個段落的開頭,並在每個段落的末尾放置/ p。

  4. 選擇文本。

  5. 單擊Alt Q以包裝文本。

文字環繞但它損壞,因爲從/ p標記的開度角括號「<」被附加到每個行的開始和開口角撐架從/ p標籤丟失。

<p>Our swimming lessons run on a perpetual monthly enrollment system, 
<making year-round lessons affordable and convenient. Our online 
<registration system allows you to sign up at your convenience and 
<monitor your account details easily./p> 

<p>Our highly trained swim instructors teach our unique, proven 
<curriculum in stages, encouraging swimmers to master the fundamentals 
<of every important swimming skill. We continuously encourage 
<progression and advancement as each swimmer becomes more confident in 
<the water. Our program blends important water safety skills, buoyancy 
<principles and correct stroke technique./p> 

幫助!我究竟做錯了什麼?

回答

0

這裏是你可以做什麼:從客戶端

  1. 粘貼內容。
  2. 選擇,打替代Q要包裝。現在您將有兩個遊標,每個段落的末尾都有一個遊標。
  3. 請選擇Selection -> Expand Selection to Paragraph(稍後我會告訴你如何製作快捷方式)。現在選擇兩個段落,每個段落作爲選擇區域。
  4. 造就埃米特與按Ctrl並進入pp*
  5. 命中輸入,你應該有兩個包段由<p></p>標籤包圍:
<p>Our swimming lessons run on a perpetual monthly enrollment system, making 
    year-round lessons affordable and convenient. Our online registration system 
    allows you to sign up at your convenience and monitor your account details 
    easily.</p> 
<p>Our highly trained swim instructors teach our unique, proven curriculum in 
    stages, encouraging swimmers to master the fundamentals of every important 
    swimming skill. We continuously encourage progression and advancement as each 
    swimmer becomes more confident in the water. Our program blends important 
    water safety skills, buoyancy principles and correct stroke technique.</p> 

要創建一個快捷鍵Expand Selection to Paragraph,去Preferences -> Key Bindings - User並添加以下內容:

[ 
    { "keys": ["ctrl+alt+shift+p"], "command": "expand_selection_to_paragraph" } 
] 

保存文件:

{ "keys": ["ctrl+alt+shift+p"], "command": "expand_selection_to_paragraph" } 

如果該文件是空的,在方括號[]包裹上面的行,你現在應該可以使用CtrlAltShiftP上面的第3步。如果您願意,可隨意更改組合鍵,但請注意它可能與其他內置或插件組合件發生衝突。

注意:我在Sublime Text 3上測試了所有這些,但它應該在ST2中工作。

+0

是的,這有效。謝謝。我注意到的一件事是,如果段落之間沒有空行,那麼Alt Q將它們組合在一起。另外,在序列結尾處,段落之間會丟失空行。是否有任何編輯器提示處理添加或刪除空行? – user2250113

+0

@ user2250113 - 是的,需要一個空行來劃定段落 - 我不認爲有任何解決方法。如果我的答案幫助解決了您的問題,請隨時點擊旁邊的複選標記以將其選爲答案。它會將您的問題標記爲已解決,並協助將來可能有相同或類似問題的網站訪問者。謝謝! – MattDMo

+0

我選擇了您的答案來解決我的問題。感謝您及時的回覆。我能夠添加快捷方式,這也將有所幫助。 – user2250113