Bram Moolenaar | 9aa1569 | 2017-08-19 15:05:32 +0200 | [diff] [blame] | 1 | " Tests for 'virtualedit'. |
| 2 | |
| 3 | func Test_yank_move_change() |
Bram Moolenaar | d41babe | 2017-08-30 17:01:35 +0200 | [diff] [blame] | 4 | new |
Bram Moolenaar | 9aa1569 | 2017-08-19 15:05:32 +0200 | [diff] [blame] | 5 | call setline(1, [ |
| 6 | \ "func foo() error {", |
| 7 | \ "\tif n, err := bar();", |
| 8 | \ "\terr != nil {", |
| 9 | \ "\t\treturn err", |
| 10 | \ "\t}", |
| 11 | \ "\tn = n * n", |
| 12 | \ ]) |
| 13 | set virtualedit=all |
| 14 | set ts=4 |
| 15 | function! MoveSelectionDown(count) abort |
| 16 | normal! m` |
| 17 | silent! exe "'<,'>move'>+".a:count |
| 18 | norm! `` |
| 19 | endfunction |
| 20 | |
| 21 | xmap ]e :<C-U>call MoveSelectionDown(v:count1)<CR> |
| 22 | 2 |
| 23 | normal 2gg |
| 24 | normal J |
| 25 | normal jVj |
| 26 | normal ]e |
| 27 | normal ce |
| 28 | bwipe! |
| 29 | set virtualedit= |
| 30 | set ts=8 |
| 31 | endfunc |
Bram Moolenaar | d41babe | 2017-08-30 17:01:35 +0200 | [diff] [blame] | 32 | |
| 33 | func Test_paste_end_of_line() |
| 34 | new |
| 35 | set virtualedit=all |
| 36 | call setline(1, ['456', '123']) |
| 37 | normal! gg0"ay$ |
| 38 | exe "normal! 2G$lllA\<C-O>:normal! \"agP\r" |
| 39 | call assert_equal('123456', getline(2)) |
| 40 | |
| 41 | bwipe! |
| 42 | set virtualedit= |
| 43 | endfunc |
Bram Moolenaar | db0eede | 2018-04-25 22:38:17 +0200 | [diff] [blame] | 44 | |
| 45 | func Test_edit_CTRL_G() |
| 46 | new |
| 47 | set virtualedit=insert |
| 48 | call setline(1, ['123', '1', '12']) |
| 49 | exe "normal! ggA\<c-g>jx\<c-g>jx" |
| 50 | call assert_equal(['123', '1 x', '12 x'], getline(1,'$')) |
| 51 | |
| 52 | set virtualedit=all |
| 53 | %d_ |
| 54 | call setline(1, ['1', '12']) |
| 55 | exe "normal! ggllix\<c-g>jx" |
| 56 | call assert_equal(['1 x', '12x'], getline(1,'$')) |
| 57 | |
| 58 | |
| 59 | bwipe! |
| 60 | set virtualedit= |
| 61 | endfunc |