Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | Test for "*Cmd" autocommands |
| 2 | |
| 3 | STARTTEST |
| 4 | :so small.vim |
| 5 | :/^start/,$w! Xxx " write lines below to Xxx |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 6 | :au BufReadCmd XtestA 0r Xxx|$del |
| 7 | :e XtestA " will read text of Xxd instead |
| 8 | :au BufWriteCmd XtestA call append(line("$"), "write") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9 | :w " will append a line to the file |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 10 | :r XtestA " should not read anything |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 11 | : " now we have: |
| 12 | : " 1 start of Xxx |
| 13 | : " 2 test40 |
| 14 | : " 3 end of Xxx |
| 15 | : " 4 write |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 16 | :au FileReadCmd XtestB '[r Xxx |
| 17 | :2r XtestB " will read Xxx below line 2 instead |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 18 | : " 1 start of Xxx |
| 19 | : " 2 test40 |
| 20 | : " 3 start of Xxx |
| 21 | : " 4 test40 |
| 22 | : " 5 end of Xxx |
| 23 | : " 6 end of Xxx |
| 24 | : " 7 write |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 25 | :au FileWriteCmd XtestC '[,']copy $ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 26 | 4GA1 |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 27 | :4,5w XtestC " will copy lines 4 and 5 to the end |
| 28 | :r XtestC " should not read anything |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 29 | : " 1 start of Xxx |
| 30 | : " 2 test40 |
| 31 | : " 3 start of Xxx |
| 32 | : " 4 test401 |
| 33 | : " 5 end of Xxx |
| 34 | : " 6 end of Xxx |
| 35 | : " 7 write |
| 36 | : " 8 test401 |
| 37 | : " 9 end of Xxx |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 38 | :au FILEAppendCmd XtestD '[,']w! test.out |
| 39 | :w >>XtestD " will write all lines to test.out |
| 40 | :$r XtestD " should not read anything |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 41 | :$w >>test.out " append "end of Xxx" to test.out |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 42 | :au BufReadCmd XtestE 0r test.out|$del |
| 43 | :sp XtestE " split window with test.out |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 44 | 5Goasdf:" |
Bram Moolenaar | 707060e | 2013-02-14 20:58:35 +0100 | [diff] [blame] | 45 | :au BufWriteCmd XtestE w! test.out |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 46 | :wall " will write other window to test.out |
| 47 | : " 1 start of Xxx |
| 48 | : " 2 test40 |
| 49 | : " 3 start of Xxx |
| 50 | : " 4 test401 |
| 51 | : " 5 end of Xxx |
| 52 | : " 6 asdf |
| 53 | : " 7 end of Xxx |
| 54 | : " 8 write |
| 55 | : " 9 test401 |
| 56 | : " 10 end of Xxx |
| 57 | : " 11 end of Xxx |
| 58 | :qa! |
| 59 | ENDTEST |
| 60 | |
| 61 | start of Xxx |
| 62 | test40 |
| 63 | end of Xxx |