2013-12-20 49 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