我在当前缓冲区中进行了一些更改,我希望vim在使用以下命令编辑新文件时自动保存当前缓冲区:
:e another_file_which_is_not_a_buffer_in_vim_yet
我在.vimrc
文件中添加了以下行,但它没有用。
autocmd BufLeave * update
Vim仍然提示我No write since last change
,为什么?我怎样才能使它工作?顺便说一句,我只想保存当前缓冲区而不是所有缓冲区,因为保存所有缓冲区似乎搞乱了缓冲区的顺序,这会在我运行:bp
或:bn
时带来麻烦。
答案 0 :(得分:5)
除了触发:edit
的内容之外,Vim还可以为autowrite
保存其他内容:
set 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.
'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.
答案 1 :(得分:2)