我从Vim的HOME文件夹中打开了_gvimrc
做了一个小编辑
从编辑模式中退出。
已执行:w
以保存更改
然后尝试通过执行:close
关闭文件,但它显示E444: Cannot close last window
如果我转到文件菜单并点击菜单项Close
(旁边显示:close
),那么它就会关闭。
为什么File> Close关闭文件,但:close
没有?
修改
这是我的文件菜单:
答案 0 :(得分:1)
来自:he :close
:
CTRL-W c *CTRL-W_c* *:clo* *:close*
:clo[se][!] Close current window. When the 'hidden' option is set, or
when the buffer was changed and the [!] is used, the buffer
becomes hidden (unless there is another window editing it).
When there is only one window in the current tab page and
there is another tab page, this closes the current tab page.
|tab-page|.
This command fails when: *E444*
- There is only one window on the screen.
- When 'hidden' is not set, [!] is not used, the buffer has
changes, and there is no other window on this buffer.
Changes to the buffer are not written and won't get lost, so
this is a "safe" command.
基本上,菜单项close window
是错误的名称,并且匹配关闭当前窗口的实际:quit
或当前的vim会话(如果这是最后一个窗口):
*:q* *:quit*
:q[uit] Quit the current window. Quit Vim if this is the last
window. This fails when changes have been made and
Vim refuses to |abandon| the current buffer, and when
the last file in the argument list has not been
edited.
If there are other tab pages and quitting the last
window in the current tab page the current tab page is
closed |tab-page|.
Triggers the |QuitPre| autocommand event.
和IINW,实际上是:confirm quit
。因此,如果您在:close
菜单选项旁边close
正确,那肯定是一个拼写错误。
编辑:
好的,刚刚和#vim IRC频道上的一些人讨论过。在那里,我被告知了:menu
命令,您可以通过:menu File.Close
从那里访问file-> close命令:
To create a new menu item, use the ":menu" commands. They are mostly like
the ":map" set of commands but the first argument is a menu item name, given
as a path of menus and submenus with a '.' between them, e.g.: >
:menu File.Save :w<CR>
:inoremenu File.Save <C-O>:w<CR>
:menu Edit.Big\ Changes.Delete\ All\ Spaces :%s/[ ^I]//g<CR>
关闭操作绝对不是:close
,而是内置于WinClose
(BuiltIn17
),:he builtin-tools
的菜单。它的作用与:close
不同。
但无论如何,这个bug /拼写错误,如果你是vim的新手,你最好学会在没有菜单的情况下使用它。你需要的一切都在你的指尖下。浏览vimtutor
,在vimgolf
播放,阅读一些教程,并尝试每月学习并使用一个新命令。你最终会提高效率而忘记你的鼠标......