blob: d9d00d97ae9ce3157b9214e34263590b668f20ce [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001Test for BufWritePre autocommand that deletes or unloads the buffer.
Bram Moolenaar2b90ed22013-07-24 16:02:36 +02002Test for BufUnload autocommand that unloads all other buffers.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003
4STARTTEST
5:so small.vim
6:au BufWritePre Xxx1 bunload
7:au BufWritePre Xxx2 bwipe
8/^start of
9A1:.,/end of/w! Xxx1 " write test file Xxx1
10$r2:.,/end of/w! Xxx2 " write test file Xxx2
11:e! Xxx2 " edit Xxx2
12:bdel test8.in " delete this file from the buffer list
13:e Xxx1 " edit Xxx1
14:w " write it, will unload it and give an error msg
15:w! test.out " Write contents of this file
16:e! Xxx2 " start editing Xxx2
17:bwipe test.out " remove test.out from the buffer list
18:w " write it, will delete the buffer and give an error msg
19:w >>test.out " Append contents of this file
Bram Moolenaar2b90ed22013-07-24 16:02:36 +020020:au! BufWritePre
21:func CloseAll()
22 let i = 0
23 while i <= bufnr('$')
24 if i != bufnr('%') && bufloaded(i)
25 exe i . "bunload"
26 endif
27 let i += 1
28 endwhile
29endfunc
30:func WriteToOut()
31 edit! test.out
32 $put ='VimLeave done'
33 write
34endfunc
35:set viminfo='100,nviminfo
36:au BufUnload * call CloseAll()
37:au VimLeave * call WriteToOut()
38:e small.vim
39:sp mbyte.vim
40:q
Bram Moolenaar071d4272004-06-13 20:20:40 +000041:qa!
42ENDTEST
43
44start of Xxx
45 test
46end of Xxx