我对当前缓冲区进行了一些更改,当我要使用以下命令编辑新文件时,我希望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
:
set autowriteall
和autowriteall
:
'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.