2013-05-05 49 views
2

我从Vim的HOME文件夹中打开_gvimrc
做了一个小小的编辑。
从编辑模式中退出。
执行:w以保存更改。
然后试图通过执行:close关闭该文件,但它说E444: Cannot close last windowVim中的文件>关闭和关闭之间的区别

如果我去的文件菜单,然后单击菜单项Close(这表示它旁边:close),那么它关闭的罚款。

为什么File> Close愉快地关闭文件,但:close不?


编辑

这是我的文件菜单:

enter image description here

+1

PROTIP:忘记菜单,并强制自己使用Ex命令,而不是':w',':q',':bd'等等。阅读所有这些命令的帮助,例如':h:w'。 – romainl 2013-05-05 14:54:18

回答

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是misname和匹配什么是真正的: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

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不同。

但无论如何,这个错误/打字错位,如果你是vim的新手,你最好学会在没有菜单的情况下使用它。你需要的一切都在你的指尖下。通过vimtutor,玩vimgolf,阅读一些教程,并尝试学习和使用一个新的命令每个月。您将最终提高生产力,并忘记您的鼠标...

+0

+1感谢。我已经向OP添加了一个屏幕打印。即使':q'错误对我来说''E37:没有写sonce最后的变化(add!覆盖)' – whytheq 2013-05-05 14:39:34

+0

':confirm quit'关闭了整个应用程序 - 我只想关闭文件 – whytheq 2013-05-05 14:41:34

+0

或者''close'实际上更接近':bdel',它关闭了当前的缓冲区。我不确定,因为我没有使用'gvim',也没有一个...但是当你执行'File-> Close'时,你得到最后一个文件关闭并且得到一个空的缓冲区?在任何情况下,它在我看来都像是'gvim'中的一个bug,应该被修补。 – zmo 2013-05-05 14:48:38

相关问题