彼此之后,将两个文本块的行放在

发布于 2025-01-21 15:45:19 字数 185 浏览 2 评论 0原文

我有以下两个文本块,

abc
abc
cdz
zer
sdf



bfd
dss
azr
vvf
ezr

我想知道我如何将这两个块的行置于以下文本的最终块: -

abc
bfd
abc
dss
cdz
azr
zer
vvf
sdf
ezr

I have the following two blocks of text

abc
abc
cdz
zer
sdf



bfd
dss
azr
vvf
ezr

I want to know how I can place the rows of these two blocks alternatively so that I get the final block of text as following:-

abc
bfd
abc
dss
cdz
azr
zer
vvf
sdf
ezr

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与风相奔跑 2025-01-28 15:45:19

使用宏一次移动1行:

  1. 在第1行的第一个字符上以光标开始记录宏,
  2. 将光标向下移动x行,直到第二块的第一行(在这种情况下为x = 8)
      8J
     
  3. 使用d而不是dd剪切此行,以维持两个块之间的距离
      d
     
  4. 将光标向上移动x行到第一行
      8K
     
  5. 粘贴我们刚切割的线
      o [esc] p
     
  6. 将光标移动到下一个起始位置(下一行的第一张字符)
      j^
     
  7. 结束记录。
  8. 在每行上重播这个宏。

Using macro to move 1 line at a time:

  1. Start recording macro with your cursor on the 1st char of the 1st line
  2. Move cursor down x lines until the first line of the 2nd block (x=8 in this case)
    8j
    
  3. Cut this line using D instead of dd to maintain the distance between the 2 blocks
    D
    
  4. Move cursor up x lines to the first line
    8k
    
  5. Paste the line we just cut
    o[esc]p
    
  6. Move cursor to the next starting position (1st char of the next line)
    j^
    
  7. End recording.
  8. Replay this macro on each line.
逐鹿 2025-01-28 15:45:19

这是一种受

  1. 方法将每个块写入一个单独的临时文件:

      VIP
    :'<,'> w /tmp /a
    <运动>
    VIP
    :'<,'> w /tmp /b
     
  2. 切开两个块。

  3. 插入粘贴的输出

     :阅读!糊状-d'\ n' /tmp /a /tmp /b
     

Here is a method inspired by this question:

  1. Write each block to a separate temporary file:

    vip
    :'<,'>w /tmp/a
    <motion>
    vip
    :'<,'>w /tmp/b
    
  2. Cut the two blocks.

  3. Insert the output of paste:

    :read !paste -d '\n' /tmp/a /tmp/b
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文