本文介绍了当缓冲区有未保存的更改且未命名时,退出vim吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过使用:vnew 在vim中创建了一个空白的暂存缓冲区(即未与特定文件关联)。然后我玩了一些文本,现在我只想退出编辑器-不保留此临时缓冲区的内容。

I created a blank "scratch buffer" (i.e. not associated with a specific file) in vim, by using :vnew. Then I played around with some text, now I simply want to exit the editor - not keeping the contents of this "scratch buffer".

当我键入命令时:

:q!

Vim给我:

[No Name][+]                                               
E37: No write since last change (add ! to  override)  
E162: No write since last change for buffer "[No Name]"  
Press ENTER or type command to continue

如何从该状态退出vim?

How can I quit vim from this state?

推荐答案

当您修改了隐藏缓冲区后,就会发生这种情况。仍然使用:qa!退出。

This happens when you have a modified hidden buffer. Use :qa! to exit anyway.

:h:quit

:q[uit]!        Quit without writing, also when currently visible
                buffers have changes.  Does not exit when this is the
                last window and there is a changed hidden buffer.
                In this case, the first changed hidden buffer becomes
                the current buffer.
                Use ":qall!" to exit always.






万一有人想复制它:


In case someone wants to reproduce it:


  • 启动vim并修改未命名的缓冲区

  • 编辑另一个文件(您可能需要:设为隐藏),即:e自述文件

  • 尝试以<$ c $退出c>:q!

  • Start vim and modify the unnamed buffer
  • Edit another file (you might need to :set hidden), ie :e README
  • Try to exit with :q!

这篇关于当缓冲区有未保存的更改且未命名时,退出vim吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:05