【问题标题】:Sublime Text 2 and Emmet and wrapping linesSublime Text 2 和 Emmet 以及环绕线
【发布时间】:2014-01-09 17:31:32
【问题描述】:

我经常从客户那里获取文本,并希望使用 html 标记快速格式化文本,并以指定数量的字符换行每个文本行。我刚刚安装了 Sublime Text 2,它非常好,但是我真正想做的事情之一我不太清楚。

我想取长段落,将每个段落包装在一个段落 p 标记中,然后换行,这样它们就不会跑出屏幕。所以这就是我正在做的事情:

  1. 将文本从我的客户端复制并粘贴到编辑器中(本示例为 2 段)。

  2. 选择文本。

  3. 使用 Emmet,输入“p*”,将 p 标签放在每个段落的开头,将 /p 放在每个段落的结尾。

  4. 选择文本。

  5. 单击 Alt Q 以换行。

文本换行但已损坏,因为 /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>

帮助!我做错了什么?

【问题讨论】:

    标签: sublimetext2 emmet


    【解决方案1】:

    您可以这样做:

    1. 从客户端粘贴内容。
    2. 选择,按AltQ 换行。您现在将有两个光标,一个位于每个段落的末尾。
    3. 选择Selection -&gt; Expand Selection to Paragraph(稍后我将向您展示如何创建快捷方式)。现在两个段落都被选中,每个段落都是一个选择区域。
    4. 使用 CtrlShiftG 调出 Emmet 并输入 pnot p*
    5. 点击Enter,你应该有两个被&lt;p&gt;&lt;/p&gt;标签包围的段落:
    <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 -&gt; Key Bindings - User 并添加以下内容:

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

    如果文件为空,则将上面的行括在方括号中[]:

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

    保存文件,您现在应该可以在步骤 3 中使用 CtrlAltShiftP更多。如果您愿意,可以随意更改组合键,但请注意它可能与其他内置或插件组合冲突。

    注意:我在 Sublime Text 3 上测试了所有这些,但它应该在 ST2 中工作。

    【讨论】:

    • 是的,这行得通。谢谢你。我注意到的一件事是,如果段落之间没有空行,则 Alt Q 将它们组合在一起。此外,在序列的末尾,段落之间的空白行会丢失。是否有任何编辑器提示处理添加或删除空白行?
    • @user2250113 - 是的,需要一个空行来描述段落 - 我认为没有办法解决这个问题。如果我的回答有助于解决您的问题,请随时单击它旁边的复选标记将其选为答案。它将您的问题标记为已解决,并帮助未来可能遇到相同或类似问题的网站访问者。谢谢!
    • 我已选择您的答案来解决我的问题。感谢您及时的回复。而且我能够添加也有帮助的快捷方式。
    猜你喜欢
    • 2013-09-23
    • 2013-02-17
    • 2014-04-27
    • 1970-01-01
    • 2016-03-26
    • 2015-12-17
    • 2016-02-01
    • 2016-10-21
    • 2013-05-31
    相关资源
    最近更新 更多