Bram Moolenaar | c812996 | 2017-01-22 20:04:51 +0100 | [diff] [blame] | 1 | |
| 2 | func Test_put_block() |
| 3 | if !has('multi_byte') |
| 4 | return |
| 5 | endif |
| 6 | new |
| 7 | call feedkeys("i\<C-V>u2500\<CR>x\<ESC>", 'x') |
| 8 | call feedkeys("\<C-V>y", 'x') |
| 9 | call feedkeys("gg0p", 'x') |
| 10 | call assert_equal("\u2500x", getline(1)) |
| 11 | bwipe! |
| 12 | endfunc |
Bram Moolenaar | 9957a10 | 2017-01-23 21:53:53 +0100 | [diff] [blame] | 13 | |
| 14 | func Test_put_char_block() |
| 15 | new |
| 16 | call setline(1, ['Line 1', 'Line 2']) |
| 17 | f Xfile_put |
| 18 | " visually select both lines and put the cursor at the top of the visual |
| 19 | " selection and then put the buffer name over it |
| 20 | exe "norm! G0\<c-v>ke\"%p" |
| 21 | call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2)) |
| 22 | bw! |
| 23 | endfunc |
Bram Moolenaar | 941c12d | 2017-01-24 19:55:43 +0100 | [diff] [blame] | 24 | |
| 25 | func Test_put_char_block2() |
| 26 | new |
| 27 | let a = [ getreg('a'), getregtype('a') ] |
| 28 | call setreg('a', ' one ', 'v') |
| 29 | call setline(1, ['Line 1', '', 'Line 3', '']) |
| 30 | " visually select the first 3 lines and put register a over it |
| 31 | exe "norm! ggl\<c-v>2j2l\"ap" |
| 32 | call assert_equal(['L one 1', '', 'L one 3', ''], getline(1,4)) |
| 33 | " clean up |
| 34 | bw! |
| 35 | call setreg('a', a[0], a[1]) |
| 36 | endfunc |
Bram Moolenaar | 18d90b9 | 2017-06-27 15:39:14 +0200 | [diff] [blame] | 37 | |
| 38 | func Test_put_lines() |
| 39 | new |
| 40 | let a = [ getreg('a'), getregtype('a') ] |
| 41 | call setline(1, ['Line 1', 'Line2', 'Line 3', '']) |
| 42 | exe 'norm! gg"add"AddG""p' |
| 43 | call assert_equal(['Line 3', '', 'Line 1', 'Line2'], getline(1,'$')) |
| 44 | " clean up |
| 45 | bw! |
| 46 | call setreg('a', a[0], a[1]) |
| 47 | endfunc |
Bram Moolenaar | 833093b | 2018-05-23 21:53:52 +0200 | [diff] [blame] | 48 | |
| 49 | func Test_put_expr() |
| 50 | new |
| 51 | call setline(1, repeat(['A'], 6)) |
| 52 | exec "1norm! \"=line('.')\<cr>p" |
| 53 | norm! j0. |
| 54 | norm! j0. |
| 55 | exec "4norm! \"=\<cr>P" |
| 56 | norm! j0. |
| 57 | norm! j0. |
| 58 | call assert_equal(['A1','A2','A3','4A','5A','6A'], getline(1,'$')) |
| 59 | bw! |
| 60 | endfunc |