1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
" Tests for the various 'formatoptions' settings
func Test_text_format()
enew!
setl noai tw=2 fo=t
call append('$', [
\ '{',
\ ' ',
\ '',
\ '}'])
exe "normal /^{/+1\n0"
normal gRa b
let lnum = line('.')
call assert_equal([
\ 'a',
\ 'b'], getline(lnum - 1, lnum))
normal ggdG
setl ai tw=2 fo=tw
call append('$', [
\ '{',
\ 'a b ',
\ '',
\ 'a ',
\ '}'])
exe "normal /^{/+1\n0"
normal gqgqjjllab
let lnum = line('.')
call assert_equal([
\ 'a ',
\ 'b ',
\ '',
\ 'a ',
\ 'b'], getline(lnum - 4, lnum))
normal ggdG
setl tw=3 fo=t
call append('$', [
\ '{',
\ "a \<C-A>",
\ '}'])
exe "normal /^{/+1\n0"
exe "normal gqgqo\na \<C-V>\<C-A>"
let lnum = line('.')
call assert_equal([
\ 'a',
\ "\<C-A>",
\ '',
\ 'a',
\ "\<C-A>"], getline(lnum - 4, lnum))
normal ggdG
setl tw=2 fo=tcq1 comments=:#
call append('$', [
\ '{',
\ 'a b',
\ '#a b',
\ '}'])
exe "normal /^{/+1\n0"
exe "normal gqgqjgqgqo\na b\n#a b"
let lnum = line('.')
call assert_equal([
\ 'a b',
\ '#a b',
\ '',
\ 'a b',
\ '#a b'], getline(lnum - 4, lnum))
normal ggdG
setl tw=5 fo=tcn comments=:#
call append('$', [
\ '{',
\ ' 1 a',
\ '# 1 a',
\ '}'])
exe "normal /^{/+1\n0"
exe "normal A b\<Esc>jA b"
let lnum = line('.')
call assert_equal([
\ ' 1 a',
\ ' b',
\ '# 1 a',
\ '# b'], getline(lnum - 3, lnum))
normal ggdG
setl tw=5 fo=t2a si
call append('$', [
\ '{',
\ '',
\ ' x a',
\ ' b',
\ ' c',
\ '',
\ '}'])
exe "normal /^{/+3\n0"
exe "normal i \<Esc>A_"
let lnum = line('.')
call assert_equal([
\ '',
\ ' x a',
\ ' b_',
\ ' c',
\ ''], getline(lnum - 2, lnum + 2))
normal ggdG
setl tw=5 fo=qn comments=:#
call append('$', [
\ '{',
\ '# 1 a b',
\ '}'])
exe "normal /^{/+1\n5|"
normal gwap
call assert_equal(5, col('.'))
let lnum = line('.')
call assert_equal([
\ '# 1 a',
\ '# b'], getline(lnum, lnum + 1))
normal ggdG
setl tw=5 fo=q2 comments=:#
call append('$', [
\ '{',
\ '# x',
\ '# a b',
\ '}'])
exe "normal /^{/+1\n0"
normal gwap
let lnum = line('.')
call assert_equal([
\ '# x a',
\ '# b'], getline(lnum, lnum + 1))
normal ggdG
setl tw& fo=a
call append('$', [
\ '{',
\ ' 1aa',
\ ' 2bb',
\ '}'])
exe "normal /^{/+2\n0"
normal I^^
call assert_equal('{ 1aa ^^2bb }', getline('.'))
normal ggdG
setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/
call append('$', [
\ '/* abc def ghi jkl ',
\ ' * mno pqr stu',
\ ' */'])
exe "normal /mno pqr/\n"
normal A vwx yz
let lnum = line('.')
call assert_equal([
\ ' * mno pqr stu ',
\ ' * vwx yz',
\ ' */'], getline(lnum - 1, lnum + 1))
normal ggdG
setl tw=12 fo=tqnc comments=:#
call setline('.', '# 1 xxxxx')
normal A foobar
call assert_equal([
\ '# 1 xxxxx',
\ '# foobar'], getline(1, 2))
setl ai& tw& fo& si& comments&
enew!
endfunc
|