您也可以使用 ex 命令
:m-2|j
Run Code Online (Sandbox Code Playgroud)
m-2具有将当前行移动到其当前位置上方 2 行的效果;这会切换当前行和上面行的位置。j连接当前行和上面的行,在两者之间插入一个空格。使用j!,如果你不想要的空间。| 将 2 个前命令分开此前命令是编写以下内容的简短方法
:move .-2
:join
Run Code Online (Sandbox Code Playgroud)
有很多方法可以做到这一点。一种是 \xe2\x80\xa6 删除上面的行并将其附加到下面行的末尾:
\n\nk move up one line\n^ move to the first printable character\ny$ yank to the end of the line\n"_d get rid of the now useless line by deleting it into the black hole register\n$ move to the end of the line\np put the deleted text\nRun Code Online (Sandbox Code Playgroud)\n