vim 如何消除竖线分隔文件中的列数

jk9hmnmh  于 2022-11-11  发布在  其他
关注(0)|答案(1)|浏览(168)

我在Vim中使用了一个竖线分隔的文件,如何使用该文件删除列?例如,删除文件每一行中第三个竖线之前的所有内容

qeeaahzv

qeeaahzv1#

  1. If your pipe delimited lines start at line #1, move the cursor to line #1, and press Shift-o (letter 'o') to add a blank line above your first line.
  2. Make sure the cursor is in the new first line. Press
    q a
    to start to record your key stroke series into register 'a'. ( q - start to record; a - record to register 'a')
  3. Press
    j d 3 f | q
    ( j - down; d - delete; 3 - the 3rd pipe; f - find; | - pipe sign; q - finish recording)
  4. Press
    u
    to undo the deletion.
  5. Check how many lines are there all together, say, 1000.
  6. Move the cursor back to the first line, then press
    1000 @ a
    ( 1000 - run the recorded key stroke series 1000 times; @ - run the recorded key stroke series; a - in register 'a')
    You have achieved what you want.

相关问题