Test for BufWritePre autocommand that deletes or unloads the buffer. STARTTEST :au BufWritePre Xxx1 bunload :au BufWritePre Xxx2 bdel /start of A1:.,/end of/w! Xxx1 " write test file Xxx1 $r2:.,/end of/w! Xxx2 " write test file Xxx2 :e! Xxx1 " start editing Xxx1 :w " write it, will unload it and give an error msg :w! test.out " Write contents of this file :e! Xxx2 " start editing Xxx2 :bdel test.out " remove test.out from the buffer list :w " write it, will delete the buffer and give an error msg :w >>test.out " Append contents of this file :!rm Xxx1 Xxx2 :qa! ENDTEST start of test file Xxx this is a test this is a test this is a test this is a test end of test file Xxx