gpt4 book ai didi

Vim 用一个空行替换多个空行

转载 作者:行者123 更新时间:2023-12-04 21:39:30 27 4
gpt4 key购买 nike

我正在寻找一种用一个空行替换多个空行的方法,并遇到了下面给出的一个解决方案:

:g/^$/,/./-j

我明白以下几点:
g/   replace each occurrences
^$ start to end is an empty, basically empty line
, replace empty line by comma
. maybe repeat last command
-j minus is go up and j is go down

但是,我不明白上面代码中的 period 和减 j 是如何工作的。
Vim 是一个非常强大的工具,我希望理解它的语法有助于进一步。

我们在哪里可以找到减 j 的文档?

期间和减 j 在这里如何工作?

最佳答案

g    Run the command globally, for the entire file
/^$/ Start executing at an empty line…
, …and continue executing to…
/./ …the first non-empty line (a line that contains
regexp '.', i.e. any character)
-j go up and join all selected lines

即命令 joins从一个空行到下一个非空行之前的所有空行。

关于Vim 用一个空行替换多个空行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56156037/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com