vim 可以在不退出的情况下关闭文件吗?

Sea*_*mus 4 vim

我在 中打开了一个文件vim,并且我已经完成了编辑。有没有办法让我关闭文件(或缓冲区)以使vim屏幕空白?

Sté*_*las 10

那会是:bd:help :bd在 vim 8.2 中给出:

:[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. Examples:
                :.,$-bdelete    " delete buffers from the current one to
                                " last but one
                :%bdelete       " delete all buffers
Run Code Online (Sandbox Code Playgroud)

  • 有一点术语不匹配:文件在 Vim 中不是“打开”的。(缓冲区已加载。)因此这实现了目标,但可能值得指出其中的区别,尤其是。因为缓冲区抽象对于多种编辑技术都很有用。 (3认同)
  • @D.BenKnoble,虽然编辑器通常不会在文件上打开*文件描述符*,除非他们加载它(或那些没有将它们完全加载到内存中的部分)或保存它(以及是否它们是否做更多的是实现细节),该文件仍然可以被认为是由编辑器通过 *open* 的某些(常见)定义打开的,就像当您说在 `evince` 中打开 pdf 文件或图像文件时在图像查看器中。我就是这样理解这个问题的。 (3认同)