我正在寻找一种用一条空行替换多个空行的方法,并遇到以下给出的一种解决方案:
:g/^$/,/./-j
Run Code Online (Sandbox Code Playgroud)
我了解以下内容:
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
Run Code Online (Sandbox Code Playgroud)
但是,我不明白上面的代码中的句点和减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
Run Code Online (Sandbox Code Playgroud)
也就是说,该命令将所有空行从空行连接到下一个非空行之前的行。
归档时间: |
|
查看次数: |
51 次 |
最近记录: |