blob: 29e24759fa7e20a04a2266d5d4eaac816da6eda4 [file] [log] [blame]
Bram Moolenaar8c87a2b2018-04-10 13:15:47 +02001" Test for block inserting
Bram Moolenaar8c87a2b2018-04-10 13:15:47 +02002
3func Test_blockinsert_indent()
4 new
5 filetype plugin indent on
6 setlocal sw=2 et ft=vim
7 call setline(1, ['let a=[', ' ''eins'',', ' ''zwei'',', ' ''drei'']'])
8 call cursor(2, 3)
9 exe "norm! \<c-v>2jI\\ \<esc>"
10 call assert_equal(['let a=[', ' \ ''eins'',', ' \ ''zwei'',', ' \ ''drei'']'],
11 \ getline(1,'$'))
12 " reset to sane state
13 filetype off
14 bwipe!
15endfunc
16
Bram Moolenaar35e802e2018-04-30 17:21:03 +020017func Test_blockinsert_delete()
18 new
19 let _bs = &bs
20 set bs=2
21 call setline(1, ['case Arg is ', ' when Name_Async,', ' when Name_Num_Gangs,', 'end if;'])
22 exe "norm! ggjVj\<c-v>$o$A\<bs>\<esc>"
23 "call feedkeys("Vj\<c-v>$o$A\<bs>\<esc>", 'ti')
24 call assert_equal(["case Arg is ", " when Name_Async", " when Name_Num_Gangs,", "end if;"],
25 \ getline(1,'$'))
26 " reset to sane state
27 let &bs = _bs
28 bwipe!
29endfunc
Bram Moolenaar8c87a2b2018-04-10 13:15:47 +020030
Bram Moolenaar4067bd32021-06-29 18:54:35 +020031func Test_blockappend_eol_cursor()
32 new
33 " Test 1 Move 1 char left
34 call setline(1, ['aaa', 'bbb', 'ccc'])
35 exe "norm! gg$\<c-v>2jA\<left>x\<esc>"
36 call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$'))
37 " Test 2 Move 2 chars left
38 sil %d
39 call setline(1, ['aaa', 'bbb', 'ccc'])
40 exe "norm! gg$\<c-v>2jA\<left>\<left>x\<esc>"
41 call assert_equal(['axaa', 'bxbb', 'cxcc'], getline(1, '$'))
42 " Test 3 Move 3 chars left (outside of the visual selection)
43 sil %d
44 call setline(1, ['aaa', 'bbb', 'ccc'])
45 exe "norm! ggl$\<c-v>2jA\<left>\<left>\<left>x\<esc>"
46 call assert_equal(['xaaa', 'bbb', 'ccc'], getline(1, '$'))
47 bw!
48endfunc
49
50func Test_blockappend_eol_cursor2()
51 new
52 " Test 1 Move 1 char left
53 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
54 exe "norm! gg\<c-v>$2jA\<left>x\<esc>"
55 call assert_equal(['aaaaxa', 'bbbx', 'ccccxc'], getline(1, '$'))
56 " Test 2 Move 2 chars left
57 sil %d
58 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
59 exe "norm! gg\<c-v>$2jA\<left>\<left>x\<esc>"
60 call assert_equal(['aaaxaa', 'bbbx', 'cccxcc'], getline(1, '$'))
61 " Test 3 Move 3 chars left (to the beginning of the visual selection)
62 sil %d
63 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
64 exe "norm! gg\<c-v>$2jA\<left>\<left>\<left>x\<esc>"
65 call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$'))
66 " Test 4 Move 3 chars left (outside of the visual selection)
67 sil %d
68 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
69 exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>x\<esc>"
70 call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$'))
71 " Test 5 Move 4 chars left (outside of the visual selection)
72 sil %d
73 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
74 exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>\<left>x\<esc>"
75 call assert_equal(['axaaaa', 'bxbb', 'cxcccc'], getline(1, '$'))
76 bw!
77endfunc
78
Bram Moolenaar8c87a2b2018-04-10 13:15:47 +020079" vim: shiftwidth=2 sts=2 expandtab