q
命令加上数字可以关闭对应位置的 split 窗口。
:q<split position>
或者 :<split position>q
会关闭对应位置的 split 窗口。
假设你的 vim 窗口布局如下:
-------------------------------------------------
| | | |
-------------------------------------------------
| | | |
| | | |
| Split 1 | Split 2 | Split 3 |
| | | |
-------------------------------------------------
如果你运行q1
命令,它将关闭第一个分屏。q2
将关闭第二个分屏,反之亦然。
在退出命令中,分屏位置的顺序不重要。:2q
或:q2
将关闭第二个分屏。
如果您传递给命令的分屏位置大于当前分屏数量,则会简单地关闭最后一个分屏。
例如,在上面的窗口设置中运行q100
,其中只有3个分屏,它将关闭最后一个分屏(Split 3)。
这是Vim文档中列出的内容。 您可以通过键入:help :close
来查找文档,然后向上滚动以查找Closing a window
部分。
If [count] is greater than the last window number the last
window will be closed:
¦ ¦ :1quit " quit the first window
¦ ¦ :$quit " quit the last window
¦ ¦ :9quit " quit the last window
" if there are fewer than 9 windows opened
¦ ¦ :-quit " quit the previous window
¦ ¦ :+quit " quit the next window
¦ ¦ :+2quit " quit the second next window