我有一个包含标题和代码的文档。每个代码都有自己的行,现在我需要复制其中的所有代码,每个代码都放在单独的行中。它们都以数字开头,Vim可以轻松实现。
该文档如下所示:
TITLE
123-456-4252-2
Other TITLE 2
123-456-4252-X
A nice TITLE 3
523-456-4252-2
...
Run Code Online (Sandbox Code Playgroud)
You can use the :global command!
qaq:g/^\d/y A
Run Code Online (Sandbox Code Playgroud)
After this, the lines are in the a register. Afterwards you can paste the copied lines with "ap.
qaq records a macro in a and immediately ends it, effectively clearing it.:g/foo/bar executes the bar command for every line that matches foo.^\d is a regex that matches lines starting with a number.y A yanks into the a register, but in append-mode.| 归档时间: |
|
| 查看次数: |
48 次 |
| 最近记录: |