gpt4 book ai didi

vim - 编辑新文件时自动保存当前缓冲区

转载 作者:行者123 更新时间:2023-12-03 22:46:57 25 4
gpt4 key购买 nike

我对当前缓冲区进行了一些更改,我希望 vim 在我要使用以下命令编辑新文件时自动保存当前缓冲区:

:e another_file_which_is_not_a_buffer_in_vim_yet

我在 .vimrc 中添加了以下行文件,但它没有用。
autocmd BufLeave * update

Vim 仍然提示我 No write since last change , 为什么?我怎样才能让它工作?顺便说一句,我只想保存当前缓冲区而不是所有缓冲区,因为保存所有缓冲区似乎会弄乱缓冲区的顺序,这会在我运行 :bp时带来麻烦。或 :bn .

最佳答案

Vim 有一个选项可以保存,其中包括 :edit除了什么触发autowrite :

set autowriteall

相关手册摘录:

autowrite :

'autowrite' 'aw'  boolean (default off)
global
Write the contents of the file, if it has been modified, on each
:next, :rewind, :last, :first, :previous, :stop, :suspend, :tag, :!,
:make, CTRL-] and CTRL-^ command; and when a :buffer, CTRL-O, CTRL-I,
'{A-Z0-9}, or `{A-Z0-9} command takes one to another file.
Note that for some commands the 'autowrite' option is not used, see
'autowriteall' for that.


autowriteall :

'autowriteall' 'awa'  boolean (default off)
global
{not in Vi}
Like 'autowrite', but also used for commands ":edit", ":enew", ":quit",
":qall", ":exit", ":xit", ":recover" and closing the Vim window.
Setting this option also implies that Vim behaves like 'autowrite' has
been set.

关于vim - 编辑新文件时自动保存当前缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34463800/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com