简体   繁体   English

Vim将打开的HTML标签加入同一行

[英]Vim Join opened Html tags to same line

So I've started using snippets with vim, now sometimes I like the closing tag to be put on a newline but other times I like the closing tag to be on the same line. 所以我开始在vim中使用代码片段,现在有时我喜欢将结束标记放在换行符上,但有时我喜欢将结束标记放在同一行上。

After typing a html tag and pressing the autocomplete key it's formatted as shown below, with the cursor position shown by the caret symbol 键入html标记并按自动完成键后,其格式如下所示,光标位置由插入符号显示

<td>
    ^
</td>

Currently, if I want both tags on the same line I have to move the cursor up a line and repeatedly hit Shift+J to join the lines, but this takes multiple key strokes 当前,如果我希望两个标签都在同一行上,则必须将光标向上移动一行并反复按Shift + J来加入行,但这需要多个按键

Is there a fast way (without moving the cursor from it's current position), to join the two lines together to look like, from the above code snippet 有没有一种快速的方法(无需将光标从当前位置移动),将两行连接在一起,就像上面的代码片段所示

<td>^</td>

You can utilize Vim's built-in inner tag text object to delete ( dit ) or change ( cit ) the whitespace / text inside the tags. 您可以利用Vim的内置内部标签文本对象删除( dit )或更改( cit )标签内的空格/文本。 (This assumes the tags are indented; without indent, you still need a J to join the end tag to the current line.) (这假定标签是缩进的;没有缩进,您仍然需要一个J才能将结束标签连接到当前行。)

or: 要么:

:.,/td>/j

meaning from the current line ( . ) to ( , ) search for "td>" ( /td>/ ) join the lines ( j ) 从当前行( . )到( , )的含义搜索“ td>”( /td>/ )加入行( j

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM