什么是:q1在Vim中做什么?
我只注意到输入:q1
关闭了我目前打开的文件(我通过输入错误找到了这个文件:q!
)
基于类似2dd
(删除两行)或2j
(向下移动两行)的命令,我会期望:2q
“退出两个文件”(但是,如果我用vi -O testfile1 testfile2
打开两个文件vi -O testfile1 testfile2
,则仅关闭:2q
其中之一 - 也是如此:q2
)。
后面的数字是:q
简单地丢弃了? 还是它有一些我无法确定的效果?
而且,更一般地说 - 我怎么能为自己回答这个问题? 我查了usr_21.txt| Go away and come back
usr_21.txt| Go away and come back
Vim的帮助,但没有发现这种行为。 我甚至检查了这个着名的问题,但没有人提到过这个问题。
带数字的q
命令会关闭该位置的给定分割。
:q<split position>
或:<split position>q
将关闭该位置的分割。
可以说你的vim窗口布局如下:
-------------------------------------------------
| | | |
-------------------------------------------------
| | | |
| | | |
| Split 1 | Split 2 | Split 3 |
| | | |
-------------------------------------------------
如果你运行q1
命令,它将关闭第一个分割。 q2
将关闭第二次拆分,反之亦然。
quit命令中分割位置的顺序无关紧要。 :2q
或:q2
将关闭第二次分割。
如果您传递给命令的分割位置大于当前分割的分割位置,它将简单地关闭最后一个分割。
例如,如果您在上面的窗口设置中只运行q100
,只有3个拆分,它将关闭最后一个拆分(拆分3)。
这是vim文档中列出的内容。 您可以通过键入:help :close
来查找文档: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
链接地址: http://www.djcxy.com/p/3857.html