Vim:如何在自由文本字段中加入内联换行符?

时间:2017-10-02 16:34:29

标签: vim line-breaks

我有自由文字

"starthello","hello 
 helloInline
 helloInline2","hello2","new field"
"not this","no inline line breaks","no","no"

我想与"$^ "加入

"starthello","hello helloInline helloInline2","hello2","new field"
"not this","no inline line breaks","no","no"

如何在Vim中加入内联换行符?

2 个答案:

答案 0 :(得分:2)

你可以这样做:

:g/[^"]$/.,/"/j

以下是它的工作原理:

:g/                 # On every line matching this regex:
   [^"]$            #   A line that does *not* end with a double quote
        /           # Run this command:
         .,         #   On every line from the current line until
           /"/      #   The next line containing a double quote
                    #   Run this command:
              j     #     Join (remove newlines)

答案 1 :(得分:1)

可能还有其他方法可以做到这一点,但有一种方法是通过按Shift+V并向上或向下移动光标来直观地选择要加入的行。然后按Shift + J加入选定的行。