我使用:e和:w命令来编辑和写入文件。我不确定是否有“close”命令关闭当前文件而不离开Vim?
我知道:q命令可以用来关闭一个文件,但如果它是最后一个文件,Vim也会被关闭;实际上在Mac OS上MacVim退出了。只有Vim窗口是关闭的,我可以使用Control-N再次打开一个空白的Vim窗口。我希望Vim保持空白屏幕的打开状态。
我使用:e和:w命令来编辑和写入文件。我不确定是否有“close”命令关闭当前文件而不离开Vim?
我知道:q命令可以用来关闭一个文件,但如果它是最后一个文件,Vim也会被关闭;实际上在Mac OS上MacVim退出了。只有Vim窗口是关闭的,我可以使用Control-N再次打开一个空白的Vim窗口。我希望Vim保持空白屏幕的打开状态。
当前回答
如果你修改了一个文件,想要在不退出Vim和不保存的情况下关闭它,你应该输入:bd!
其他回答
如果你已经保存了最后一个文件,那么:ennew就是你的朋友(:ennew !如果你不想保存最后一个文件)。请注意,原始文件仍将在缓冲列表中(通过:ls访问)。
:[N]bd[elete][!] *:bd* *:bdel* *:bdelete* *E516* :bd[elete][!] [N] Unload buffer [N] (default: current buffer) and delete it from the buffer list. If the buffer was changed, this fails, unless when [!] is specified, in which case changes are lost. The file remains unaffected. Any windows for this buffer are closed. If buffer [N] is the current buffer, another buffer will be displayed instead. This is the most recent entry in the jump list that points into a loaded buffer. Actually, the buffer isn't completely deleted, it is removed from the buffer list |unlisted-buffer| and option values, variables and mappings/abbreviations for the buffer are cleared.
查看Butane插件以保持关闭缓冲区时的窗口布局。
对我来说,close-buffers是非常有用的插件:
:删除这个关闭,你可以重新映射。
:bd可以被映射。我把它映射到F4, Shift-F4如果我需要强制关闭因为一些我不想要的改变。