blob: 216238a52879fe775676d4a5de3bd6239d362477 [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 Moolenaare9b0b402021-11-27 13:28:24 +000017func Test_blockinsert_autoindent()
18 new
19 let lines =<< trim END
20 var d = {
21 a: () => 0,
22 b: () => 0,
23 c: () => 0,
24 }
25 END
26 call setline(1, lines)
27 filetype plugin indent on
28 setlocal sw=2 et ft=vim
29 setlocal indentkeys+=:
30 exe "norm! 2Gf)\<c-v>2jA: asdf\<esc>"
31 let expected =<< trim END
32 var d = {
33 a: (): asdf => 0,
34 b: (): asdf => 0,
35 c: (): asdf => 0,
36 }
37 END
38 call assert_equal(expected, getline(1, 5))
39
40 filetype off
41 bwipe!
42endfunc
43
Bram Moolenaar35e802e2018-04-30 17:21:03 +020044func Test_blockinsert_delete()
45 new
46 let _bs = &bs
47 set bs=2
48 call setline(1, ['case Arg is ', ' when Name_Async,', ' when Name_Num_Gangs,', 'end if;'])
49 exe "norm! ggjVj\<c-v>$o$A\<bs>\<esc>"
50 "call feedkeys("Vj\<c-v>$o$A\<bs>\<esc>", 'ti')
51 call assert_equal(["case Arg is ", " when Name_Async", " when Name_Num_Gangs,", "end if;"],
52 \ getline(1,'$'))
53 " reset to sane state
54 let &bs = _bs
55 bwipe!
56endfunc
Bram Moolenaar8c87a2b2018-04-10 13:15:47 +020057
Bram Moolenaar4067bd32021-06-29 18:54:35 +020058func Test_blockappend_eol_cursor()
59 new
60 " Test 1 Move 1 char left
61 call setline(1, ['aaa', 'bbb', 'ccc'])
62 exe "norm! gg$\<c-v>2jA\<left>x\<esc>"
63 call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$'))
64 " Test 2 Move 2 chars left
65 sil %d
66 call setline(1, ['aaa', 'bbb', 'ccc'])
67 exe "norm! gg$\<c-v>2jA\<left>\<left>x\<esc>"
68 call assert_equal(['axaa', 'bxbb', 'cxcc'], getline(1, '$'))
69 " Test 3 Move 3 chars left (outside of the visual selection)
70 sil %d
71 call setline(1, ['aaa', 'bbb', 'ccc'])
72 exe "norm! ggl$\<c-v>2jA\<left>\<left>\<left>x\<esc>"
73 call assert_equal(['xaaa', 'bbb', 'ccc'], getline(1, '$'))
74 bw!
75endfunc
76
77func Test_blockappend_eol_cursor2()
78 new
79 " Test 1 Move 1 char left
80 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
81 exe "norm! gg\<c-v>$2jA\<left>x\<esc>"
82 call assert_equal(['aaaaxa', 'bbbx', 'ccccxc'], getline(1, '$'))
83 " Test 2 Move 2 chars left
84 sil %d
85 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
86 exe "norm! gg\<c-v>$2jA\<left>\<left>x\<esc>"
87 call assert_equal(['aaaxaa', 'bbbx', 'cccxcc'], getline(1, '$'))
88 " Test 3 Move 3 chars left (to the beginning of the visual selection)
89 sil %d
90 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
91 exe "norm! gg\<c-v>$2jA\<left>\<left>\<left>x\<esc>"
92 call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$'))
93 " Test 4 Move 3 chars left (outside of the visual selection)
94 sil %d
95 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
96 exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>x\<esc>"
97 call assert_equal(['aaxaaa', 'bbxb', 'ccxccc'], getline(1, '$'))
98 " Test 5 Move 4 chars left (outside of the visual selection)
99 sil %d
100 call setline(1, ['aaaaa', 'bbb', 'ccccc'])
101 exe "norm! ggl\<c-v>$2jA\<left>\<left>\<left>\<left>x\<esc>"
102 call assert_equal(['axaaaa', 'bxbb', 'cxcccc'], getline(1, '$'))
103 bw!
104endfunc
105
Bram Moolenaar8c87a2b2018-04-10 13:15:47 +0200106" vim: shiftwidth=2 sts=2 expandtab