blob: f6b1a43b812e01a1bc2acdb93b7ea60794f1b753 [file] [log] [blame]
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001" Test for various Normal mode commands
2
3func! Setup_NewWindow()
4 10new
5 call setline(1, range(1,100))
6endfunc
7
8func! MyFormatExpr()
9 " Adds '->$' at lines having numbers followed by trailing whitespace
10 for ln in range(v:lnum, v:lnum+v:count-1)
11 let line = getline(ln)
12 if getline(ln) =~# '\d\s\+$'
13 call setline(ln, substitute(line, '\s\+$', '', '') . '->$')
14 endif
15 endfor
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020016endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020017
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020018func! CountSpaces(type, ...)
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020019 " for testing operatorfunc
20 " will count the number of spaces
21 " and return the result in g:a
22 let sel_save = &selection
23 let &selection = "inclusive"
24 let reg_save = @@
25
26 if a:0 " Invoked from Visual mode, use gv command.
27 silent exe "normal! gvy"
28 elseif a:type == 'line'
29 silent exe "normal! '[V']y"
30 else
31 silent exe "normal! `[v`]y"
32 endif
33 let g:a=strlen(substitute(@@, '[^ ]', '', 'g'))
34 let &selection = sel_save
35 let @@ = reg_save
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020036endfunc
37
Bram Moolenaar4a08b0d2016-11-05 21:55:13 +010038func! OpfuncDummy(type, ...)
39 " for testing operatorfunc
40 let g:opt=&linebreak
41
42 if a:0 " Invoked from Visual mode, use gv command.
43 silent exe "normal! gvy"
44 elseif a:type == 'line'
45 silent exe "normal! '[V']y"
46 else
47 silent exe "normal! `[v`]y"
48 endif
49 " Create a new dummy window
50 new
51 let g:bufnr=bufnr('%')
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020052endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020053
54fun! Test_normal00_optrans()
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020055 new
56 call append(0, ['1 This is a simple test: abcd', '2 This is the second line', '3 this is the third line'])
57 1
58 exe "norm! Sfoobar\<esc>"
59 call assert_equal(['foobar', '2 This is the second line', '3 this is the third line', ''], getline(1,'$'))
60 2
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020061 exe "norm! $vbsone"
62 call assert_equal(['foobar', '2 This is the second one', '3 this is the third line', ''], getline(1,'$'))
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020063 norm! VS Second line here
64 call assert_equal(['foobar', ' Second line here', '3 this is the third line', ''], getline(1, '$'))
65 %d
66 call append(0, ['4 This is a simple test: abcd', '5 This is the second line', '6 this is the third line'])
67 call append(0, ['1 This is a simple test: abcd', '2 This is the second line', '3 this is the third line'])
68
69 1
70 norm! 2D
71 call assert_equal(['3 this is the third line', '4 This is a simple test: abcd', '5 This is the second line', '6 this is the third line', ''], getline(1,'$'))
72 set cpo+=#
73 norm! 4D
74 call assert_equal(['', '4 This is a simple test: abcd', '5 This is the second line', '6 this is the third line', ''], getline(1,'$'))
75
76 " clean up
77 set cpo-=#
78 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020079endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020080
81func! Test_normal01_keymodel()
82 call Setup_NewWindow()
83 " Test 1: depending on 'keymodel' <s-down> does something different
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020084 50
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020085 call feedkeys("V\<S-Up>y", 'tx')
86 call assert_equal(['47', '48', '49', '50'], getline("'<", "'>"))
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020087 set keymodel=startsel
88 50
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020089 call feedkeys("V\<S-Up>y", 'tx')
90 call assert_equal(['49', '50'], getline("'<", "'>"))
91 " Start visual mode when keymodel = startsel
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020092 50
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020093 call feedkeys("\<S-Up>y", 'tx')
94 call assert_equal(['49', '5'], getreg(0, 0, 1))
95 " Do not start visual mode when keymodel=
Bram Moolenaar2931f2a2016-09-09 16:59:08 +020096 set keymodel=
97 50
Bram Moolenaar87bc3f72016-09-03 17:33:54 +020098 call feedkeys("\<S-Up>y$", 'tx')
99 call assert_equal(['42'], getreg(0, 0, 1))
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200100 " Stop visual mode when keymodel=stopsel
101 set keymodel=stopsel
102 50
103 call feedkeys("Vkk\<Up>yy", 'tx')
104 call assert_equal(['47'], getreg(0, 0, 1))
105
106 set keymodel=
107 50
108 call feedkeys("Vkk\<Up>yy", 'tx')
109 call assert_equal(['47', '48', '49', '50'], getreg(0, 0, 1))
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200110
111 " clean up
112 bw!
113endfunc
114
115func! Test_normal02_selectmode()
116 " some basic select mode tests
117 call Setup_NewWindow()
118 50
119 norm! gHy
120 call assert_equal('y51', getline('.'))
121 call setline(1, range(1,100))
122 50
123 exe ":norm! V9jo\<c-g>y"
124 call assert_equal('y60', getline('.'))
125 " clean up
126 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200127endfunc
128
129func! Test_normal02_selectmode2()
130 " some basic select mode tests
131 call Setup_NewWindow()
132 50
133 call feedkeys(":set im\n\<c-o>gHc\<c-o>:set noim\n", 'tx')
134 call assert_equal('c51', getline('.'))
135 " clean up
136 bw!
137endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200138
139func! Test_normal03_join()
140 " basic join test
141 call Setup_NewWindow()
142 50
143 norm! VJ
144 call assert_equal('50 51', getline('.'))
145 $
146 norm! J
147 call assert_equal('100', getline('.'))
148 $
149 norm! V9-gJ
150 call assert_equal('919293949596979899100', getline('.'))
151 call setline(1, range(1,100))
152 $
153 :j 10
154 call assert_equal('100', getline('.'))
155 " clean up
156 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200157endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200158
159func! Test_normal04_filter()
160 " basic filter test
161 " only test on non windows platform
Bram Moolenaar4a08b0d2016-11-05 21:55:13 +0100162 if has('win32')
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200163 return
164 endif
165 call Setup_NewWindow()
166 1
167 call feedkeys("!!sed -e 's/^/| /'\n", 'tx')
168 call assert_equal('| 1', getline('.'))
169 90
170 :sil :!echo one
171 call feedkeys('.', 'tx')
172 call assert_equal('| 90', getline('.'))
173 95
174 set cpo+=!
175 " 2 <CR>, 1: for executing the command,
176 " 2: clear hit-enter-prompt
177 call feedkeys("!!\n", 'tx')
178 call feedkeys(":!echo one\n\n", 'tx')
179 call feedkeys(".", 'tx')
180 call assert_equal('one', getline('.'))
181 set cpo-=!
182 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200183endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200184
185func! Test_normal05_formatexpr()
186 " basic formatexpr test
187 call Setup_NewWindow()
188 %d_
189 call setline(1, ['here: 1 ', '2', 'here: 3 ', '4', 'not here: '])
190 1
191 set formatexpr=MyFormatExpr()
192 norm! gqG
193 call assert_equal(['here: 1->$', '2', 'here: 3->$', '4', 'not here: '], getline(1,'$'))
194 set formatexpr=
195 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200196endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200197
Bram Moolenaard77f9d52016-09-04 15:13:39 +0200198func Test_normal05_formatexpr_newbuf()
199 " Edit another buffer in the 'formatexpr' function
200 new
201 func! Format()
202 edit another
203 endfunc
204 set formatexpr=Format()
205 norm gqG
206 bw!
207 set formatexpr=
208endfunc
209
210func Test_normal05_formatexpr_setopt()
211 " Change the 'formatexpr' value in the function
212 new
213 func! Format()
214 set formatexpr=
215 endfunc
216 set formatexpr=Format()
217 norm gqG
218 bw!
219 set formatexpr=
220endfunc
221
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200222func! Test_normal06_formatprg()
223 " basic test for formatprg
224 " only test on non windows platform
Bram Moolenaar4a08b0d2016-11-05 21:55:13 +0100225 if has('win32')
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200226 return
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200227 endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +0100228
229 " uses sed to number non-empty lines
230 call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/ /', '}'''], 'Xsed_format.sh')
231 call system('chmod +x ./Xsed_format.sh')
232 let text = ['a', '', 'c', '', ' ', 'd', 'e']
233 let expected = ['1 a', '', '3 c', '', '5 ', '6 d', '7 e']
234
235 10new
236 call setline(1, text)
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200237 set formatprg=./Xsed_format.sh
238 norm! gggqG
Bram Moolenaar9be7c042017-01-14 14:28:30 +0100239 call assert_equal(expected, getline(1, '$'))
240 bw!
241
242 10new
243 call setline(1, text)
244 set formatprg=donothing
245 setlocal formatprg=./Xsed_format.sh
246 norm! gggqG
247 call assert_equal(expected, getline(1, '$'))
248 bw!
249
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200250 " clean up
251 set formatprg=
Bram Moolenaar9be7c042017-01-14 14:28:30 +0100252 setlocal formatprg=
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200253 call delete('Xsed_format.sh')
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200254endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200255
256func! Test_normal07_internalfmt()
257 " basic test for internal formmatter to textwidth of 12
258 let list=range(1,11)
259 call map(list, 'v:val." "')
260 10new
261 call setline(1, list)
262 set tw=12
263 norm! gggqG
264 call assert_equal(['1 2 3', '4 5 6', '7 8 9', '10 11 '], getline(1, '$'))
265 " clean up
Bram Moolenaar9be7c042017-01-14 14:28:30 +0100266 set tw=0
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200267 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200268endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200269
270func! Test_normal08_fold()
271 " basic tests for foldopen/folddelete
272 if !has("folding")
273 return
274 endif
275 call Setup_NewWindow()
276 50
277 setl foldenable fdm=marker
278 " First fold
279 norm! V4jzf
280 " check that folds have been created
281 call assert_equal(['50/*{{{*/', '51', '52', '53', '54/*}}}*/'], getline(50,54))
282 " Second fold
283 46
284 norm! V10jzf
285 " check that folds have been created
286 call assert_equal('46/*{{{*/', getline(46))
287 call assert_equal('60/*}}}*/', getline(60))
288 norm! k
289 call assert_equal('45', getline('.'))
290 norm! j
291 call assert_equal('46/*{{{*/', getline('.'))
292 norm! j
293 call assert_equal('61', getline('.'))
294 norm! k
295 " open a fold
296 norm! Vzo
297 norm! k
298 call assert_equal('45', getline('.'))
299 norm! j
300 call assert_equal('46/*{{{*/', getline('.'))
301 norm! j
302 call assert_equal('47', getline('.'))
303 norm! k
304 norm! zcVzO
305 call assert_equal('46/*{{{*/', getline('.'))
306 norm! j
307 call assert_equal('47', getline('.'))
308 norm! j
309 call assert_equal('48', getline('.'))
310 norm! j
311 call assert_equal('49', getline('.'))
312 norm! j
313 call assert_equal('50/*{{{*/', getline('.'))
314 norm! j
315 call assert_equal('51', getline('.'))
316 " delete folds
317 :46
318 " collapse fold
319 norm! V14jzC
320 " delete all folds recursively
321 norm! VzD
322 call assert_equal(['46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60'], getline(46,60))
323
324 " clean up
325 setl nofoldenable fdm=marker
326 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200327endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200328
329func! Test_normal09_operatorfunc()
330 " Test operatorfunc
331 call Setup_NewWindow()
332 " Add some spaces for counting
333 50,60s/$/ /
334 unlet! g:a
335 let g:a=0
336 nmap <buffer><silent> ,, :set opfunc=CountSpaces<CR>g@
337 vmap <buffer><silent> ,, :<C-U>call CountSpaces(visualmode(), 1)<CR>
338 50
339 norm V2j,,
340 call assert_equal(6, g:a)
341 norm V,,
342 call assert_equal(2, g:a)
343 norm ,,l
344 call assert_equal(0, g:a)
345 50
346 exe "norm 0\<c-v>10j2l,,"
347 call assert_equal(11, g:a)
348 50
349 norm V10j,,
350 call assert_equal(22, g:a)
351
352 " clean up
353 unmap <buffer> ,,
354 set opfunc=
Bram Moolenaar4a08b0d2016-11-05 21:55:13 +0100355 unlet! g:a
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200356 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200357endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200358
Bram Moolenaar4a08b0d2016-11-05 21:55:13 +0100359func! Test_normal09a_operatorfunc()
360 " Test operatorfunc
361 call Setup_NewWindow()
362 " Add some spaces for counting
363 50,60s/$/ /
364 unlet! g:opt
365 set linebreak
366 nmap <buffer><silent> ,, :set opfunc=OpfuncDummy<CR>g@
367 50
368 norm ,,j
369 exe "bd!" g:bufnr
370 call assert_true(&linebreak)
371 call assert_equal(g:opt, &linebreak)
372 set nolinebreak
373 norm ,,j
374 exe "bd!" g:bufnr
375 call assert_false(&linebreak)
376 call assert_equal(g:opt, &linebreak)
377
378 " clean up
379 unmap <buffer> ,,
380 set opfunc=
381 bw!
382 unlet! g:opt
383endfunc
384
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200385func! Test_normal10_expand()
386 " Test for expand()
387 10new
388 call setline(1, ['1', 'ifooar,,cbar'])
389 2
390 norm! $
Bram Moolenaar65f08472017-09-10 18:16:20 +0200391 call assert_equal('cbar', expand('<cword>'))
392 call assert_equal('ifooar,,cbar', expand('<cWORD>'))
393
394 call setline(1, ['prx = list[idx];'])
395 1
396 let expected = ['', 'prx', 'prx', 'prx',
397 \ 'list', 'list', 'list', 'list', 'list', 'list', 'list',
398 \ 'idx', 'idx', 'idx', 'idx',
399 \ 'list[idx]',
400 \ '];',
401 \ ]
402 for i in range(1, 16)
403 exe 'norm ' . i . '|'
404 call assert_equal(expected[i], expand('<cexpr>'), 'i == ' . i)
405 endfor
406
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200407 " clean up
408 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200409endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200410
411func! Test_normal11_showcmd()
412 " test for 'showcmd'
413 10new
414 exe "norm! ofoobar\<esc>"
415 call assert_equal(2, line('$'))
416 set showcmd
417 exe "norm! ofoobar2\<esc>"
418 call assert_equal(3, line('$'))
419 exe "norm! VAfoobar3\<esc>"
420 call assert_equal(3, line('$'))
421 exe "norm! 0d3\<del>2l"
422 call assert_equal('obar2foobar3', getline('.'))
423 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200424endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200425
426func! Test_normal12_nv_error()
427 " Test for nv_error
428 10new
429 call setline(1, range(1,5))
430 " should not do anything, just beep
431 exe "norm! <c-k>"
432 call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$'))
433 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200434endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200435
436func! Test_normal13_help()
437 " Test for F1
438 call assert_equal(1, winnr())
439 call feedkeys("\<f1>", 'txi')
440 call assert_match('help\.txt', bufname('%'))
441 call assert_equal(2, winnr('$'))
442 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200443endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200444
445func! Test_normal14_page()
446 " basic test for Ctrl-F and Ctrl-B
447 call Setup_NewWindow()
448 exe "norm! \<c-f>"
449 call assert_equal('9', getline('.'))
450 exe "norm! 2\<c-f>"
451 call assert_equal('25', getline('.'))
452 exe "norm! 2\<c-b>"
453 call assert_equal('18', getline('.'))
454 1
455 set scrolloff=5
456 exe "norm! 2\<c-f>"
457 call assert_equal('21', getline('.'))
458 exe "norm! \<c-b>"
459 call assert_equal('13', getline('.'))
460 1
461 set scrolloff=99
462 exe "norm! \<c-f>"
463 call assert_equal('13', getline('.'))
464 set scrolloff=0
465 100
466 exe "norm! $\<c-b>"
467 call assert_equal('92', getline('.'))
468 call assert_equal([0, 92, 1, 0, 1], getcurpos())
469 100
470 set nostartofline
471 exe "norm! $\<c-b>"
472 call assert_equal('92', getline('.'))
473 call assert_equal([0, 92, 2, 0, 2147483647], getcurpos())
474 " cleanup
475 set startofline
476 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200477endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200478
Bram Moolenaarbc54f3f2016-09-04 14:34:28 +0200479func! Test_normal14_page_eol()
480 10new
481 norm oxxxxxxx
482 exe "norm 2\<c-f>"
483 " check with valgrind that cursor is put back in column 1
484 exe "norm 2\<c-b>"
485 bw!
486endfunc
487
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200488func! Test_normal15_z_scroll_vert()
489 " basic test for z commands that scroll the window
490 call Setup_NewWindow()
491 100
492 norm! >>
493 " Test for z<cr>
494 exe "norm! z\<cr>"
495 call assert_equal(' 100', getline('.'))
496 call assert_equal(100, winsaveview()['topline'])
497 call assert_equal([0, 100, 2, 0, 9], getcurpos())
498
499 " Test for zt
500 21
501 norm! >>0zt
502 call assert_equal(' 21', getline('.'))
503 call assert_equal(21, winsaveview()['topline'])
504 call assert_equal([0, 21, 1, 0, 8], getcurpos())
505
506 " Test for zb
507 30
508 norm! >>$ztzb
509 call assert_equal(' 30', getline('.'))
510 call assert_equal(30, winsaveview()['topline']+winheight(0)-1)
511 call assert_equal([0, 30, 3, 0, 2147483647], getcurpos())
512
513 " Test for z-
514 1
515 30
516 norm! 0z-
517 call assert_equal(' 30', getline('.'))
518 call assert_equal(30, winsaveview()['topline']+winheight(0)-1)
519 call assert_equal([0, 30, 2, 0, 9], getcurpos())
520
521 " Test for z{height}<cr>
522 call assert_equal(10, winheight(0))
523 exe "norm! z12\<cr>"
524 call assert_equal(12, winheight(0))
525 exe "norm! z10\<cr>"
526 call assert_equal(10, winheight(0))
527
528 " Test for z.
529 1
530 21
531 norm! 0z.
532 call assert_equal(' 21', getline('.'))
533 call assert_equal(17, winsaveview()['topline'])
534 call assert_equal([0, 21, 2, 0, 9], getcurpos())
535
536 " Test for zz
537 1
538 21
539 norm! 0zz
540 call assert_equal(' 21', getline('.'))
541 call assert_equal(17, winsaveview()['topline'])
542 call assert_equal([0, 21, 1, 0, 8], getcurpos())
543
544 " Test for z+
545 11
546 norm! zt
547 norm! z+
548 call assert_equal(' 21', getline('.'))
549 call assert_equal(21, winsaveview()['topline'])
550 call assert_equal([0, 21, 2, 0, 9], getcurpos())
551
552 " Test for [count]z+
553 1
554 norm! 21z+
555 call assert_equal(' 21', getline('.'))
556 call assert_equal(21, winsaveview()['topline'])
557 call assert_equal([0, 21, 2, 0, 9], getcurpos())
558
559 " Test for z^
560 norm! 22z+0
561 norm! z^
562 call assert_equal(' 21', getline('.'))
563 call assert_equal(12, winsaveview()['topline'])
564 call assert_equal([0, 21, 2, 0, 9], getcurpos())
565
566 " Test for [count]z^
567 1
568 norm! 30z^
569 call assert_equal(' 21', getline('.'))
570 call assert_equal(12, winsaveview()['topline'])
571 call assert_equal([0, 21, 2, 0, 9], getcurpos())
572
573 " cleanup
574 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200575endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200576
577func! Test_normal16_z_scroll_hor()
578 " basic test for z commands that scroll the window
579 10new
580 15vsp
581 set nowrap listchars=
582 let lineA='abcdefghijklmnopqrstuvwxyz'
583 let lineB='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
584 $put =lineA
585 $put =lineB
586 1d
587
588 " Test for zl
589 1
590 norm! 5zl
591 call assert_equal(lineA, getline('.'))
592 call assert_equal(6, col('.'))
593 call assert_equal(5, winsaveview()['leftcol'])
594 norm! yl
595 call assert_equal('f', @0)
596
597 " Test for zh
598 norm! 2zh
599 call assert_equal(lineA, getline('.'))
600 call assert_equal(6, col('.'))
601 norm! yl
602 call assert_equal('f', @0)
603 call assert_equal(3, winsaveview()['leftcol'])
604
605 " Test for zL
606 norm! zL
607 call assert_equal(11, col('.'))
608 norm! yl
609 call assert_equal('k', @0)
610 call assert_equal(10, winsaveview()['leftcol'])
611 norm! 2zL
612 call assert_equal(25, col('.'))
613 norm! yl
614 call assert_equal('y', @0)
615 call assert_equal(24, winsaveview()['leftcol'])
616
617 " Test for zH
618 norm! 2zH
619 call assert_equal(25, col('.'))
620 call assert_equal(10, winsaveview()['leftcol'])
621 norm! yl
622 call assert_equal('y', @0)
623
624 " Test for zs
625 norm! $zs
626 call assert_equal(26, col('.'))
627 call assert_equal(25, winsaveview()['leftcol'])
628 norm! yl
629 call assert_equal('z', @0)
630
631 " Test for ze
632 norm! ze
633 call assert_equal(26, col('.'))
634 call assert_equal(11, winsaveview()['leftcol'])
635 norm! yl
636 call assert_equal('z', @0)
637
638 " cleanup
639 set wrap listchars=eol:$
640 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200641endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200642
643func! Test_normal17_z_scroll_hor2()
644 " basic test for z commands that scroll the window
645 " using 'sidescrolloff' setting
646 10new
647 20vsp
648 set nowrap listchars= sidescrolloff=5
649 let lineA='abcdefghijklmnopqrstuvwxyz'
650 let lineB='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
651 $put =lineA
652 $put =lineB
653 1d
654
655 " Test for zl
656 1
657 norm! 5zl
658 call assert_equal(lineA, getline('.'))
659 call assert_equal(11, col('.'))
660 call assert_equal(5, winsaveview()['leftcol'])
661 norm! yl
662 call assert_equal('k', @0)
663
664 " Test for zh
665 norm! 2zh
666 call assert_equal(lineA, getline('.'))
667 call assert_equal(11, col('.'))
668 norm! yl
669 call assert_equal('k', @0)
670 call assert_equal(3, winsaveview()['leftcol'])
671
672 " Test for zL
673 norm! 0zL
674 call assert_equal(16, col('.'))
675 norm! yl
676 call assert_equal('p', @0)
677 call assert_equal(10, winsaveview()['leftcol'])
678 norm! 2zL
679 call assert_equal(26, col('.'))
680 norm! yl
681 call assert_equal('z', @0)
682 call assert_equal(15, winsaveview()['leftcol'])
683
684 " Test for zH
685 norm! 2zH
686 call assert_equal(15, col('.'))
687 call assert_equal(0, winsaveview()['leftcol'])
688 norm! yl
689 call assert_equal('o', @0)
690
691 " Test for zs
692 norm! $zs
693 call assert_equal(26, col('.'))
694 call assert_equal(20, winsaveview()['leftcol'])
695 norm! yl
696 call assert_equal('z', @0)
697
698 " Test for ze
699 norm! ze
700 call assert_equal(26, col('.'))
701 call assert_equal(11, winsaveview()['leftcol'])
702 norm! yl
703 call assert_equal('z', @0)
704
705 " cleanup
706 set wrap listchars=eol:$ sidescrolloff=0
707 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +0200708endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200709
710func! Test_normal18_z_fold()
711 " basic tests for foldopen/folddelete
712 if !has("folding")
713 return
714 endif
715 call Setup_NewWindow()
716 50
717 setl foldenable fdm=marker foldlevel=5
718
719 " Test for zF
720 " First fold
721 norm! 4zF
722 " check that folds have been created
723 call assert_equal(['50/*{{{*/', '51', '52', '53/*}}}*/'], getline(50,53))
724
725 " Test for zd
726 51
727 norm! 2zF
728 call assert_equal(2, foldlevel('.'))
729 norm! kzd
730 call assert_equal(['50', '51/*{{{*/', '52/*}}}*/', '53'], getline(50,53))
731 norm! j
732 call assert_equal(1, foldlevel('.'))
733
734 " Test for zD
735 " also deletes partially selected folds recursively
736 51
737 norm! zF
738 call assert_equal(2, foldlevel('.'))
739 norm! kV2jzD
740 call assert_equal(['50', '51', '52', '53'], getline(50,53))
741
742 " Test for zE
743 85
744 norm! 4zF
745 86
746 norm! 2zF
747 90
748 norm! 4zF
749 call assert_equal(['85/*{{{*/', '86/*{{{*/', '87/*}}}*/', '88/*}}}*/', '89', '90/*{{{*/', '91', '92', '93/*}}}*/'], getline(85,93))
750 norm! zE
751 call assert_equal(['85', '86', '87', '88', '89', '90', '91', '92', '93'], getline(85,93))
752
753 " Test for zn
754 50
755 set foldlevel=0
756 norm! 2zF
757 norm! zn
758 norm! k
759 call assert_equal('49', getline('.'))
760 norm! j
761 call assert_equal('50/*{{{*/', getline('.'))
762 norm! j
763 call assert_equal('51/*}}}*/', getline('.'))
764 norm! j
765 call assert_equal('52', getline('.'))
766 call assert_equal(0, &foldenable)
767
768 " Test for zN
769 49
770 norm! zN
771 call assert_equal('49', getline('.'))
772 norm! j
773 call assert_equal('50/*{{{*/', getline('.'))
774 norm! j
775 call assert_equal('52', getline('.'))
776 call assert_equal(1, &foldenable)
777
778 " Test for zi
779 norm! zi
780 call assert_equal(0, &foldenable)
781 norm! zi
782 call assert_equal(1, &foldenable)
783 norm! zi
784 call assert_equal(0, &foldenable)
785 norm! zi
786 call assert_equal(1, &foldenable)
787
788 " Test for za
789 50
790 norm! za
791 norm! k
792 call assert_equal('49', getline('.'))
793 norm! j
794 call assert_equal('50/*{{{*/', getline('.'))
795 norm! j
796 call assert_equal('51/*}}}*/', getline('.'))
797 norm! j
798 call assert_equal('52', getline('.'))
799 50
800 norm! za
801 norm! k
802 call assert_equal('49', getline('.'))
803 norm! j
804 call assert_equal('50/*{{{*/', getline('.'))
805 norm! j
806 call assert_equal('52', getline('.'))
807
808 49
809 norm! 5zF
810 norm! k
811 call assert_equal('48', getline('.'))
812 norm! j
813 call assert_equal('49/*{{{*/', getline('.'))
814 norm! j
815 call assert_equal('55', getline('.'))
816 49
817 norm! za
818 call assert_equal('49/*{{{*/', getline('.'))
819 norm! j
820 call assert_equal('50/*{{{*/', getline('.'))
821 norm! j
822 call assert_equal('52', getline('.'))
823 set nofoldenable
824 " close fold and set foldenable
825 norm! za
826 call assert_equal(1, &foldenable)
827
828 50
829 " have to use {count}za to open all folds and make the cursor visible
830 norm! 2za
831 norm! 2k
832 call assert_equal('48', getline('.'))
833 norm! j
834 call assert_equal('49/*{{{*/', getline('.'))
835 norm! j
836 call assert_equal('50/*{{{*/', getline('.'))
837 norm! j
838 call assert_equal('51/*}}}*/', getline('.'))
839 norm! j
840 call assert_equal('52', getline('.'))
841
842 " Test for zA
843 49
844 set foldlevel=0
845 50
846 norm! zA
847 norm! 2k
848 call assert_equal('48', getline('.'))
849 norm! j
850 call assert_equal('49/*{{{*/', getline('.'))
851 norm! j
852 call assert_equal('50/*{{{*/', getline('.'))
853 norm! j
854 call assert_equal('51/*}}}*/', getline('.'))
855 norm! j
856 call assert_equal('52', getline('.'))
857
Bram Moolenaar395b6ba2017-04-07 20:09:51 +0200858 " zA on a opened fold when foldenable is not set
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200859 50
860 set nofoldenable
861 norm! zA
862 call assert_equal(1, &foldenable)
863 norm! k
864 call assert_equal('48', getline('.'))
865 norm! j
866 call assert_equal('49/*{{{*/', getline('.'))
867 norm! j
868 call assert_equal('55', getline('.'))
869
870 " Test for zc
871 norm! zE
872 50
873 norm! 2zF
874 49
875 norm! 5zF
876 set nofoldenable
877 50
878 " There most likely is a bug somewhere:
879 " https://groups.google.com/d/msg/vim_dev/v2EkfJ_KQjI/u-Cvv94uCAAJ
880 " TODO: Should this only close the inner most fold or both folds?
881 norm! zc
882 call assert_equal(1, &foldenable)
883 norm! k
884 call assert_equal('48', getline('.'))
885 norm! j
886 call assert_equal('49/*{{{*/', getline('.'))
887 norm! j
888 call assert_equal('55', getline('.'))
889 set nofoldenable
890 50
891 norm! Vjzc
892 norm! k
893 call assert_equal('48', getline('.'))
894 norm! j
895 call assert_equal('49/*{{{*/', getline('.'))
896 norm! j
897 call assert_equal('55', getline('.'))
898
899 " Test for zC
900 set nofoldenable
901 50
902 norm! zCk
903 call assert_equal('48', getline('.'))
904 norm! j
905 call assert_equal('49/*{{{*/', getline('.'))
906 norm! j
907 call assert_equal('55', getline('.'))
908
909 " Test for zx
910 " 1) close folds at line 49-54
911 set nofoldenable
912 48
913 norm! zx
914 call assert_equal(1, &foldenable)
915 norm! j
916 call assert_equal('49/*{{{*/', getline('.'))
917 norm! j
918 call assert_equal('55', getline('.'))
919
Bram Moolenaar395b6ba2017-04-07 20:09:51 +0200920 " 2) do not close fold under cursor
Bram Moolenaar87bc3f72016-09-03 17:33:54 +0200921 51
922 set nofoldenable
923 norm! zx
924 call assert_equal(1, &foldenable)
925 norm! 3k
926 call assert_equal('48', getline('.'))
927 norm! j
928 call assert_equal('49/*{{{*/', getline('.'))
929 norm! j
930 call assert_equal('50/*{{{*/', getline('.'))
931 norm! j
932 call assert_equal('51/*}}}*/', getline('.'))
933 norm! j
934 call assert_equal('52', getline('.'))
935 norm! j
936 call assert_equal('53', getline('.'))
937 norm! j
938 call assert_equal('54/*}}}*/', getline('.'))
939 norm! j
940 call assert_equal('55', getline('.'))
941
942 " 3) close one level of folds
943 48
944 set nofoldenable
945 set foldlevel=1
946 norm! zx
947 call assert_equal(1, &foldenable)
948 call assert_equal('48', getline('.'))
949 norm! j
950 call assert_equal('49/*{{{*/', getline('.'))
951 norm! j
952 call assert_equal('50/*{{{*/', getline('.'))
953 norm! j
954 call assert_equal('52', getline('.'))
955 norm! j
956 call assert_equal('53', getline('.'))
957 norm! j
958 call assert_equal('54/*}}}*/', getline('.'))
959 norm! j
960 call assert_equal('55', getline('.'))
961
962 " Test for zX
963 " Close all folds
964 set foldlevel=0 nofoldenable
965 50
966 norm! zX
967 call assert_equal(1, &foldenable)
968 norm! k
969 call assert_equal('48', getline('.'))
970 norm! j
971 call assert_equal('49/*{{{*/', getline('.'))
972 norm! j
973 call assert_equal('55', getline('.'))
974
975 " Test for zm
976 50
977 set nofoldenable foldlevel=2
978 norm! zm
979 call assert_equal(1, &foldenable)
980 call assert_equal(1, &foldlevel)
981 norm! zm
982 call assert_equal(0, &foldlevel)
983 norm! zm
984 call assert_equal(0, &foldlevel)
985 norm! k
986 call assert_equal('48', getline('.'))
987 norm! j
988 call assert_equal('49/*{{{*/', getline('.'))
989 norm! j
990 call assert_equal('55', getline('.'))
991
992 " Test for zM
993 48
994 set nofoldenable foldlevel=99
995 norm! zM
996 call assert_equal(1, &foldenable)
997 call assert_equal(0, &foldlevel)
998 call assert_equal('48', getline('.'))
999 norm! j
1000 call assert_equal('49/*{{{*/', getline('.'))
1001 norm! j
1002 call assert_equal('55', getline('.'))
1003
1004 " Test for zr
1005 48
1006 set nofoldenable foldlevel=0
1007 norm! zr
1008 call assert_equal(0, &foldenable)
1009 call assert_equal(1, &foldlevel)
1010 set foldlevel=0 foldenable
1011 norm! zr
1012 call assert_equal(1, &foldenable)
1013 call assert_equal(1, &foldlevel)
1014 norm! zr
1015 call assert_equal(2, &foldlevel)
1016 call assert_equal('48', getline('.'))
1017 norm! j
1018 call assert_equal('49/*{{{*/', getline('.'))
1019 norm! j
1020 call assert_equal('50/*{{{*/', getline('.'))
1021 norm! j
1022 call assert_equal('51/*}}}*/', getline('.'))
1023 norm! j
1024 call assert_equal('52', getline('.'))
1025
1026 " Test for zR
1027 48
1028 set nofoldenable foldlevel=0
1029 norm! zR
1030 call assert_equal(0, &foldenable)
1031 call assert_equal(2, &foldlevel)
1032 set foldenable foldlevel=0
1033 norm! zR
1034 call assert_equal(1, &foldenable)
1035 call assert_equal(2, &foldlevel)
1036 call assert_equal('48', getline('.'))
1037 norm! j
1038 call assert_equal('49/*{{{*/', getline('.'))
1039 norm! j
1040 call assert_equal('50/*{{{*/', getline('.'))
1041 norm! j
1042 call assert_equal('51/*}}}*/', getline('.'))
1043 norm! j
1044 call assert_equal('52', getline('.'))
1045 call append(50, ['a /*{{{*/', 'b /*}}}*/'])
1046 48
1047 call assert_equal('48', getline('.'))
1048 norm! j
1049 call assert_equal('49/*{{{*/', getline('.'))
1050 norm! j
1051 call assert_equal('50/*{{{*/', getline('.'))
1052 norm! j
1053 call assert_equal('a /*{{{*/', getline('.'))
1054 norm! j
1055 call assert_equal('51/*}}}*/', getline('.'))
1056 norm! j
1057 call assert_equal('52', getline('.'))
1058 48
1059 norm! zR
1060 call assert_equal(1, &foldenable)
1061 call assert_equal(3, &foldlevel)
1062 call assert_equal('48', getline('.'))
1063 norm! j
1064 call assert_equal('49/*{{{*/', getline('.'))
1065 norm! j
1066 call assert_equal('50/*{{{*/', getline('.'))
1067 norm! j
1068 call assert_equal('a /*{{{*/', getline('.'))
1069 norm! j
1070 call assert_equal('b /*}}}*/', getline('.'))
1071 norm! j
1072 call assert_equal('51/*}}}*/', getline('.'))
1073 norm! j
1074 call assert_equal('52', getline('.'))
1075
1076 " clean up
1077 setl nofoldenable fdm=marker foldlevel=0
1078 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001079endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001080
1081func! Test_normal19_z_spell()
1082 if !has("spell") || !has('syntax')
1083 return
1084 endif
1085 new
1086 call append(0, ['1 good', '2 goood', '3 goood'])
1087 set spell spellfile=./Xspellfile.add spelllang=en
1088 let oldlang=v:lang
1089 lang C
1090
1091 " Test for zg
1092 1
1093 norm! ]s
1094 call assert_equal('2 goood', getline('.'))
1095 norm! zg
1096 1
1097 let a=execute('unsilent :norm! ]s')
1098 call assert_equal('1 good', getline('.'))
1099 call assert_equal('search hit BOTTOM, continuing at TOP', a[1:])
1100 let cnt=readfile('./Xspellfile.add')
1101 call assert_equal('goood', cnt[0])
1102
1103 " Test for zw
1104 2
1105 norm! $zw
1106 1
1107 norm! ]s
1108 call assert_equal('2 goood', getline('.'))
1109 let cnt=readfile('./Xspellfile.add')
1110 call assert_equal('#oood', cnt[0])
1111 call assert_equal('goood/!', cnt[1])
1112
1113 " Test for zg in visual mode
1114 let a=execute('unsilent :norm! V$zg')
1115 call assert_equal("Word '2 goood' added to ./Xspellfile.add", a[1:])
1116 1
1117 norm! ]s
1118 call assert_equal('3 goood', getline('.'))
1119 let cnt=readfile('./Xspellfile.add')
1120 call assert_equal('2 goood', cnt[2])
1121 " Remove "2 good" from spellfile
1122 2
1123 let a=execute('unsilent norm! V$zw')
1124 call assert_equal("Word '2 goood' added to ./Xspellfile.add", a[1:])
1125 let cnt=readfile('./Xspellfile.add')
1126 call assert_equal('2 goood/!', cnt[3])
1127
1128 " Test for zG
1129 let a=execute('unsilent norm! V$zG')
1130 call assert_match("Word '2 goood' added to .*", a)
1131 let fname=matchstr(a, 'to\s\+\zs\f\+$')
1132 let cnt=readfile(fname)
1133 call assert_equal('2 goood', cnt[0])
1134
1135 " Test for zW
1136 let a=execute('unsilent norm! V$zW')
1137 call assert_match("Word '2 goood' added to .*", a)
1138 let cnt=readfile(fname)
1139 call assert_equal('# goood', cnt[0])
1140 call assert_equal('2 goood/!', cnt[1])
1141
1142 " Test for zuW
1143 let a=execute('unsilent norm! V$zuW')
1144 call assert_match("Word '2 goood' removed from .*", a)
1145 let cnt=readfile(fname)
1146 call assert_equal('# goood', cnt[0])
1147 call assert_equal('# goood/!', cnt[1])
1148
1149 " Test for zuG
1150 let a=execute('unsilent norm! $zG')
1151 call assert_match("Word 'goood' added to .*", a)
1152 let cnt=readfile(fname)
1153 call assert_equal('# goood', cnt[0])
1154 call assert_equal('# goood/!', cnt[1])
1155 call assert_equal('goood', cnt[2])
1156 let a=execute('unsilent norm! $zuG')
1157 let cnt=readfile(fname)
1158 call assert_match("Word 'goood' removed from .*", a)
1159 call assert_equal('# goood', cnt[0])
1160 call assert_equal('# goood/!', cnt[1])
1161 call assert_equal('#oood', cnt[2])
1162 " word not found in wordlist
1163 let a=execute('unsilent norm! V$zuG')
1164 let cnt=readfile(fname)
1165 call assert_match("", a)
1166 call assert_equal('# goood', cnt[0])
1167 call assert_equal('# goood/!', cnt[1])
1168 call assert_equal('#oood', cnt[2])
1169
1170 " Test for zug
1171 call delete('./Xspellfile.add')
1172 2
1173 let a=execute('unsilent norm! $zg')
1174 let cnt=readfile('./Xspellfile.add')
1175 call assert_equal('goood', cnt[0])
1176 let a=execute('unsilent norm! $zug')
1177 call assert_match("Word 'goood' removed from \./Xspellfile.add", a)
1178 let cnt=readfile('./Xspellfile.add')
1179 call assert_equal('#oood', cnt[0])
1180 " word not in wordlist
1181 let a=execute('unsilent norm! V$zug')
1182 call assert_match('', a)
1183 let cnt=readfile('./Xspellfile.add')
1184 call assert_equal('#oood', cnt[0])
1185
1186 " Test for zuw
1187 call delete('./Xspellfile.add')
1188 2
1189 let a=execute('unsilent norm! Vzw')
1190 let cnt=readfile('./Xspellfile.add')
1191 call assert_equal('2 goood/!', cnt[0])
1192 let a=execute('unsilent norm! Vzuw')
1193 call assert_match("Word '2 goood' removed from \./Xspellfile.add", a)
1194 let cnt=readfile('./Xspellfile.add')
1195 call assert_equal('# goood/!', cnt[0])
1196 " word not in wordlist
1197 let a=execute('unsilent norm! $zug')
1198 call assert_match('', a)
1199 let cnt=readfile('./Xspellfile.add')
1200 call assert_equal('# goood/!', cnt[0])
1201
1202 " add second entry to spellfile setting
1203 set spellfile=./Xspellfile.add,./Xspellfile2.add
1204 call delete('./Xspellfile.add')
1205 2
1206 let a=execute('unsilent norm! $2zg')
1207 let cnt=readfile('./Xspellfile2.add')
1208 call assert_match("Word 'goood' added to ./Xspellfile2.add", a)
1209 call assert_equal('goood', cnt[0])
1210
1211 " clean up
1212 exe "lang" oldlang
1213 call delete("./Xspellfile.add")
1214 call delete("./Xspellfile2.add")
Bram Moolenaardf0db162016-09-06 20:37:41 +02001215 call delete("./Xspellfile.add.spl")
1216 call delete("./Xspellfile2.add.spl")
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001217
1218 " zux -> no-op
1219 2
1220 norm! $zux
1221 call assert_equal([], glob('Xspellfile.add',0,1))
1222 call assert_equal([], glob('Xspellfile2.add',0,1))
1223
1224 set spellfile=
1225 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001226endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001227
1228func! Test_normal20_exmode()
Bram Moolenaar0913a102016-09-03 19:11:59 +02001229 if !has("unix")
1230 " Reading from redirected file doesn't work on MS-Windows
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001231 return
1232 endif
1233 call writefile(['1a', 'foo', 'bar', '.', 'w! Xfile2', 'q!'], 'Xscript')
1234 call writefile(['1', '2'], 'Xfile')
1235 call system(v:progpath .' -e -s < Xscript Xfile')
1236 let a=readfile('Xfile2')
1237 call assert_equal(['1', 'foo', 'bar', '2'], a)
1238
1239 " clean up
1240 for file in ['Xfile', 'Xfile2', 'Xscript']
1241 call delete(file)
1242 endfor
1243 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001244endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001245
1246func! Test_normal21_nv_hat()
1247 set hidden
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001248 new
1249 " to many buffers opened already, will not work
1250 "call assert_fails(":b#", 'E23')
1251 "call assert_equal('', @#)
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001252 e Xfoobar
1253 e Xfile2
1254 call feedkeys("\<c-^>", 't')
1255 call assert_equal("Xfile2", fnamemodify(bufname('%'), ':t'))
1256 call feedkeys("f\<c-^>", 't')
1257 call assert_equal("Xfile2", fnamemodify(bufname('%'), ':t'))
1258 " clean up
1259 set nohidden
1260 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001261endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001262
1263func! Test_normal22_zet()
1264 " Test for ZZ
Bram Moolenaar0913a102016-09-03 19:11:59 +02001265 " let shell = &shell
1266 " let &shell = 'sh'
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001267 call writefile(['1', '2'], 'Xfile')
1268 let args = ' -u NONE -N -U NONE -i NONE --noplugins -X --not-a-term'
1269 call system(v:progpath . args . ' -c "%d" -c ":norm! ZZ" Xfile')
1270 let a = readfile('Xfile')
1271 call assert_equal([], a)
1272 " Test for ZQ
1273 call writefile(['1', '2'], 'Xfile')
1274 call system(v:progpath . args . ' -c "%d" -c ":norm! ZQ" Xfile')
1275 let a = readfile('Xfile')
1276 call assert_equal(['1', '2'], a)
1277
1278 " clean up
1279 for file in ['Xfile']
1280 call delete(file)
1281 endfor
Bram Moolenaar0913a102016-09-03 19:11:59 +02001282 " let &shell = shell
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001283endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001284
1285func! Test_normal23_K()
1286 " Test for K command
1287 new
Bram Moolenaar426f3752016-11-04 21:22:37 +01001288 call append(0, ['version8.txt', 'man', 'aa%bb', 'cc|dd'])
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001289 let k = &keywordprg
1290 set keywordprg=:help
1291 1
1292 norm! VK
1293 call assert_equal('version8.txt', fnamemodify(bufname('%'), ':t'))
1294 call assert_equal('help', &ft)
1295 call assert_match('\*version8.txt\*', getline('.'))
1296 helpclose
1297 norm! 0K
1298 call assert_equal('version8.txt', fnamemodify(bufname('%'), ':t'))
1299 call assert_equal('help', &ft)
1300 call assert_match('\*version8\.0\*', getline('.'))
1301 helpclose
1302
Bram Moolenaar426f3752016-11-04 21:22:37 +01001303 set keywordprg=:new
1304 set iskeyword+=%
1305 set iskeyword+=\|
1306 2
1307 norm! K
1308 call assert_equal('man', fnamemodify(bufname('%'), ':t'))
1309 bwipe!
1310 3
1311 norm! K
1312 call assert_equal('aa%bb', fnamemodify(bufname('%'), ':t'))
1313 bwipe!
Bram Moolenaareb828d02016-11-05 19:54:01 +01001314 if !has('win32')
1315 4
1316 norm! K
1317 call assert_equal('cc|dd', fnamemodify(bufname('%'), ':t'))
1318 bwipe!
1319 endif
Bram Moolenaar426f3752016-11-04 21:22:37 +01001320 set iskeyword-=%
1321 set iskeyword-=\|
1322
Bram Moolenaar0913a102016-09-03 19:11:59 +02001323 " Only expect "man" to work on Unix
1324 if !has("unix")
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001325 let &keywordprg = k
1326 bw!
1327 return
1328 endif
1329 set keywordprg=man\ --pager=cat
1330 " Test for using man
1331 2
1332 let a = execute('unsilent norm! K')
1333 call assert_match("man --pager=cat 'man'", a)
1334
1335 " clean up
1336 let &keywordprg = k
1337 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001338endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001339
1340func! Test_normal24_rot13()
1341 " This test uses multi byte characters
1342 if !has("multi_byte")
1343 return
1344 endif
1345 " Testing for g?? g?g?
1346 new
1347 call append(0, 'abcdefghijklmnopqrstuvwxyzäüö')
1348 1
1349 norm! g??
1350 call assert_equal('nopqrstuvwxyzabcdefghijklmäüö', getline('.'))
1351 norm! g?g?
1352 call assert_equal('abcdefghijklmnopqrstuvwxyzäüö', getline('.'))
1353
1354 " clean up
1355 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001356endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001357
1358func! Test_normal25_tag()
1359 " Testing for CTRL-] g CTRL-] g]
1360 " CTRL-W g] CTRL-W CTRL-] CTRL-W g CTRL-]
1361 h
1362 " Test for CTRL-]
1363 call search('\<x\>$')
1364 exe "norm! \<c-]>"
1365 call assert_equal("change.txt", fnamemodify(bufname('%'), ':t'))
1366 norm! yiW
1367 call assert_equal("*x*", @0)
1368 exe ":norm \<c-o>"
1369
1370 " Test for g_CTRL-]
1371 call search('\<v_u\>$')
1372 exe "norm! g\<c-]>"
1373 call assert_equal("change.txt", fnamemodify(bufname('%'), ':t'))
1374 norm! yiW
1375 call assert_equal("*v_u*", @0)
1376 exe ":norm \<c-o>"
1377
1378 " Test for g]
1379 call search('\<i_<Esc>$')
1380 let a = execute(":norm! g]")
1381 call assert_match('i_<Esc>.*insert.txt', a)
1382
1383 if !empty(exepath('cscope')) && has('cscope')
1384 " setting cscopetag changes how g] works
1385 set cst
1386 exe "norm! g]"
1387 call assert_equal("insert.txt", fnamemodify(bufname('%'), ':t'))
1388 norm! yiW
1389 call assert_equal("*i_<Esc>*", @0)
1390 exe ":norm \<c-o>"
1391 " Test for CTRL-W g]
1392 exe "norm! \<C-W>g]"
1393 call assert_equal("insert.txt", fnamemodify(bufname('%'), ':t'))
1394 norm! yiW
1395 call assert_equal("*i_<Esc>*", @0)
1396 call assert_equal(3, winnr('$'))
1397 helpclose
1398 set nocst
1399 endif
1400
1401 " Test for CTRL-W g]
1402 let a = execute("norm! \<C-W>g]")
1403 call assert_match('i_<Esc>.*insert.txt', a)
1404
1405 " Test for CTRL-W CTRL-]
1406 exe "norm! \<C-W>\<C-]>"
1407 call assert_equal("insert.txt", fnamemodify(bufname('%'), ':t'))
1408 norm! yiW
1409 call assert_equal("*i_<Esc>*", @0)
1410 call assert_equal(3, winnr('$'))
1411 helpclose
1412
1413 " Test for CTRL-W g CTRL-]
1414 exe "norm! \<C-W>g\<C-]>"
1415 call assert_equal("insert.txt", fnamemodify(bufname('%'), ':t'))
1416 norm! yiW
1417 call assert_equal("*i_<Esc>*", @0)
1418 call assert_equal(3, winnr('$'))
1419 helpclose
1420
1421 " clean up
1422 helpclose
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001423endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001424
1425func! Test_normal26_put()
1426 " Test for ]p ]P [p and [P
1427 new
1428 call append(0, ['while read LINE', 'do', ' ((count++))', ' if [ $? -ne 0 ]; then', " echo 'Error writing file'", ' fi', 'done'])
1429 1
1430 /Error/y a
1431 2
1432 norm! "a]pj"a[p
1433 call assert_equal(['do', "echo 'Error writing file'", " echo 'Error writing file'", ' ((count++))'], getline(2,5))
1434 1
1435 /^\s\{4}/
1436 exe "norm! \"a]P3Eldt'"
1437 exe "norm! j\"a[P2Eldt'"
1438 call assert_equal([' if [ $? -ne 0 ]; then', " echo 'Error writing'", " echo 'Error'", " echo 'Error writing file'", ' fi'], getline(6,10))
1439
1440 " clean up
1441 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001442endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001443
1444func! Test_normal27_bracket()
1445 " Test for [' [` ]' ]`
1446 call Setup_NewWindow()
1447 1,21s/.\+/ & b/
1448 1
1449 norm! $ma
1450 5
1451 norm! $mb
1452 10
1453 norm! $mc
1454 15
1455 norm! $md
1456 20
1457 norm! $me
1458
1459 " Test for ['
1460 9
1461 norm! 2['
1462 call assert_equal(' 1 b', getline('.'))
1463 call assert_equal(1, line('.'))
1464 call assert_equal(3, col('.'))
1465
1466 " Test for ]'
1467 norm! ]'
1468 call assert_equal(' 5 b', getline('.'))
1469 call assert_equal(5, line('.'))
1470 call assert_equal(3, col('.'))
1471
1472 " No mark after line 21, cursor moves to first non blank on current line
1473 21
1474 norm! $]'
1475 call assert_equal(' 21 b', getline('.'))
1476 call assert_equal(21, line('.'))
1477 call assert_equal(3, col('.'))
1478
1479 " Test for [`
1480 norm! 2[`
1481 call assert_equal(' 15 b', getline('.'))
1482 call assert_equal(15, line('.'))
1483 call assert_equal(8, col('.'))
1484
1485 " Test for ]`
1486 norm! ]`
1487 call assert_equal(' 20 b', getline('.'))
1488 call assert_equal(20, line('.'))
1489 call assert_equal(8, col('.'))
1490
1491 " clean up
1492 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001493endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001494
1495func! Test_normal28_parenthesis()
1496 " basic testing for ( and )
1497 new
1498 call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
1499
1500 $
1501 norm! d(
1502 call assert_equal(['This is a test. With some sentences!', '', 'Even with a question? And one more. ', ''], getline(1, '$'))
1503 norm! 2d(
1504 call assert_equal(['This is a test. With some sentences!', '', ' ', ''], getline(1, '$'))
1505 1
1506 norm! 0d)
1507 call assert_equal(['With some sentences!', '', ' ', ''], getline(1, '$'))
1508
1509 call append('$', ['This is a long sentence', '', 'spanning', 'over several lines. '])
1510 $
1511 norm! $d(
1512 call assert_equal(['With some sentences!', '', ' ', '', 'This is a long sentence', ''], getline(1, '$'))
1513
1514 " clean up
1515 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001516endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001517
1518fun! Test_normal29_brace()
1519 " basic test for { and } movements
1520 let text= ['A paragraph begins after each empty line, and also at each of a set of',
1521 \ 'paragraph macros, specified by the pairs of characters in the ''paragraphs''',
1522 \ 'option. The default is "IPLPPPQPP TPHPLIPpLpItpplpipbp", which corresponds to',
1523 \ 'the macros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in',
1524 \ 'the first column). A section boundary is also a paragraph boundary.',
1525 \ 'Note that a blank line (only containing white space) is NOT a paragraph',
1526 \ 'boundary.',
1527 \ '',
1528 \ '',
1529 \ 'Also note that this does not include a ''{'' or ''}'' in the first column. When',
1530 \ 'the ''{'' flag is in ''cpoptions'' then ''{'' in the first column is used as a',
1531 \ 'paragraph boundary |posix|.',
1532 \ '{',
1533 \ 'This is no paragaraph',
1534 \ 'unless the ''{'' is set',
1535 \ 'in ''cpoptions''',
1536 \ '}',
1537 \ '.IP',
1538 \ 'The nroff macros IP seperates a paragraph',
1539 \ 'That means, it must be a ''.''',
1540 \ 'followed by IP',
1541 \ '.LPIt does not matter, if afterwards some',
1542 \ 'more characters follow.',
1543 \ '.SHAlso section boundaries from the nroff',
1544 \ 'macros terminate a paragraph. That means',
1545 \ 'a character like this:',
1546 \ '.NH',
1547 \ 'End of text here']
1548 new
1549 call append(0, text)
1550 1
1551 norm! 0d2}
1552 call assert_equal(['.IP',
1553 \ 'The nroff macros IP seperates a paragraph', 'That means, it must be a ''.''', 'followed by IP',
1554 \ '.LPIt does not matter, if afterwards some', 'more characters follow.', '.SHAlso section boundaries from the nroff',
1555 \ 'macros terminate a paragraph. That means', 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
1556 norm! 0d}
1557 call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.',
1558 \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
1559 \ 'a character like this:', '.NH', 'End of text here', ''], getline(1, '$'))
1560 $
1561 norm! d{
1562 call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.',
1563 \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means', 'a character like this:', ''], getline(1, '$'))
1564 norm! d{
1565 call assert_equal(['.LPIt does not matter, if afterwards some', 'more characters follow.', ''], getline(1,'$'))
1566 " Test with { in cpooptions
1567 %d
1568 call append(0, text)
1569 set cpo+={
1570 1
1571 norm! 0d2}
1572 call assert_equal(['{', 'This is no paragaraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}',
1573 \ '.IP', 'The nroff macros IP seperates a paragraph', 'That means, it must be a ''.''',
1574 \ 'followed by IP', '.LPIt does not matter, if afterwards some', 'more characters follow.',
1575 \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
1576 \ 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
1577 $
1578 norm! d}
1579 call assert_equal(['{', 'This is no paragaraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}',
1580 \ '.IP', 'The nroff macros IP seperates a paragraph', 'That means, it must be a ''.''',
1581 \ 'followed by IP', '.LPIt does not matter, if afterwards some', 'more characters follow.',
1582 \ '.SHAlso section boundaries from the nroff', 'macros terminate a paragraph. That means',
1583 \ 'a character like this:', '.NH', 'End of text here', ''], getline(1,'$'))
1584 norm! gg}
1585 norm! d5}
1586 call assert_equal(['{', 'This is no paragaraph', 'unless the ''{'' is set', 'in ''cpoptions''', '}', ''], getline(1,'$'))
1587
1588 " clean up
1589 set cpo-={
1590 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001591endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001592
1593fun! Test_normal30_changecase()
1594 " This test uses multi byte characters
1595 if !has("multi_byte")
1596 return
1597 endif
1598 new
1599 call append(0, 'This is a simple test: äüöß')
1600 norm! 1ggVu
1601 call assert_equal('this is a simple test: äüöß', getline('.'))
1602 norm! VU
1603 call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖSS', getline('.'))
1604 norm! guu
1605 call assert_equal('this is a simple test: äüöss', getline('.'))
1606 norm! gUgU
1607 call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖSS', getline('.'))
1608 norm! gugu
1609 call assert_equal('this is a simple test: äüöss', getline('.'))
1610 norm! gUU
1611 call assert_equal('THIS IS A SIMPLE TEST: ÄÜÖSS', getline('.'))
1612 norm! 010~
1613 call assert_equal('this is a SIMPLE TEST: ÄÜÖSS', getline('.'))
1614 norm! V~
1615 call assert_equal('THIS IS A simple test: äüöss', getline('.'))
1616
Bram Moolenaar9f4de1f2017-04-08 19:39:43 +02001617 " Turkish ASCII turns to multi-byte. On Mac the Turkish locale is available
1618 " but toupper()/tolower() don't do the right thing.
Bram Moolenaard2381a22017-04-09 14:58:15 +02001619 if !has('mac') && !has('osx')
Bram Moolenaar9f4de1f2017-04-08 19:39:43 +02001620 try
1621 lang tr_TR.UTF-8
1622 set casemap=
1623 call setline(1, 'iI')
1624 1normal gUU
1625 call assert_equal("\u0130I", getline(1))
1626 call assert_equal("\u0130I", toupper("iI"))
Bram Moolenaar3317d5e2017-04-08 19:12:06 +02001627
Bram Moolenaar9f4de1f2017-04-08 19:39:43 +02001628 call setline(1, 'iI')
1629 1normal guu
1630 call assert_equal("i\u0131", getline(1))
1631 call assert_equal("i\u0131", tolower("iI"))
Bram Moolenaar3317d5e2017-04-08 19:12:06 +02001632
Bram Moolenaar1cc48202017-04-09 13:41:59 +02001633 set casemap&
1634 call setline(1, 'iI')
1635 1normal gUU
1636 call assert_equal("II", getline(1))
1637 call assert_equal("II", toupper("iI"))
1638
1639 call setline(1, 'iI')
1640 1normal guu
1641 call assert_equal("ii", getline(1))
1642 call assert_equal("ii", tolower("iI"))
1643
Bram Moolenaar9f4de1f2017-04-08 19:39:43 +02001644 lang en_US.UTF-8
1645 catch /E197:/
1646 " can't use Turkish locale
1647 throw 'Skipped: Turkish locale not available'
1648 endtry
1649 endif
Bram Moolenaar3317d5e2017-04-08 19:12:06 +02001650
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001651 " clean up
1652 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001653endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001654
1655fun! Test_normal31_r_cmd()
1656 " Test for r command
1657 new
1658 call append(0, 'This is a simple test: abcd')
1659 exe "norm! 1gg$r\<cr>"
1660 call assert_equal(['This is a simple test: abc', '', ''], getline(1,'$'))
1661 exe "norm! 1gg2wlr\<cr>"
1662 call assert_equal(['This is a', 'simple test: abc', '', ''], getline(1,'$'))
1663 exe "norm! 2gg0W5r\<cr>"
1664 call assert_equal(['This is a', 'simple ', ' abc', '', ''], getline('1', '$'))
1665 set autoindent
1666 call setline(2, ['simple test: abc', ''])
1667 exe "norm! 2gg0W5r\<cr>"
1668 call assert_equal(['This is a', 'simple ', 'abc', '', '', ''], getline('1', '$'))
1669 exe "norm! 1ggVr\<cr>"
1670 call assert_equal('^M^M^M^M^M^M^M^M^M', strtrans(getline(1)))
1671 call setline(1, 'This is a')
1672 exe "norm! 1gg05rf"
1673 call assert_equal('fffffis a', getline(1))
1674
1675 " clean up
1676 set noautoindent
1677 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001678endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001679
1680func! Test_normal32_g_cmd1()
1681 " Test for g*, g#
1682 new
1683 call append(0, ['abc.x_foo', 'x_foobar.abc'])
1684 1
1685 norm! $g*
1686 call assert_equal('x_foo', @/)
1687 call assert_equal('x_foobar.abc', getline('.'))
1688 norm! $g#
1689 call assert_equal('abc', @/)
1690 call assert_equal('abc.x_foo', getline('.'))
1691
1692 " clean up
1693 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001694endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001695
1696fun! Test_normal33_g_cmd2()
1697 if !has("jumplist")
1698 return
1699 endif
1700 " Tests for g cmds
1701 call Setup_NewWindow()
1702 " Test for g`
1703 clearjumps
1704 norm! ma10j
1705 let a=execute(':jumps')
1706 " empty jumplist
1707 call assert_equal('>', a[-1:])
1708 norm! g`a
1709 call assert_equal('>', a[-1:])
1710 call assert_equal(1, line('.'))
1711 call assert_equal('1', getline('.'))
1712
1713 " Test for g; and g,
1714 norm! g;
1715 " there is only one change in the changelist
1716 " currently, when we setup the window
1717 call assert_equal(2, line('.'))
1718 call assert_fails(':norm! g;', 'E662')
1719 call assert_fails(':norm! g,', 'E663')
1720 let &ul=&ul
1721 call append('$', ['a', 'b', 'c', 'd'])
1722 let &ul=&ul
1723 call append('$', ['Z', 'Y', 'X', 'W'])
1724 let a = execute(':changes')
1725 call assert_match('2\s\+0\s\+2', a)
1726 call assert_match('101\s\+0\s\+a', a)
1727 call assert_match('105\s\+0\s\+Z', a)
1728 norm! 3g;
1729 call assert_equal(2, line('.'))
1730 norm! 2g,
1731 call assert_equal(105, line('.'))
1732
1733 " Test for g& - global substitute
1734 %d
1735 call setline(1, range(1,10))
1736 call append('$', ['a', 'b', 'c', 'd'])
1737 $s/\w/&&/g
1738 exe "norm! /[1-8]\<cr>"
1739 norm! g&
1740 call assert_equal(['11', '22', '33', '44', '55', '66', '77', '88', '9', '110', 'a', 'b', 'c', 'dd'], getline(1, '$'))
1741
1742 " Test for gv
1743 %d
1744 call append('$', repeat(['abcdefgh'], 8))
1745 exe "norm! 2gg02l\<c-v>2j2ly"
1746 call assert_equal(['cde', 'cde', 'cde'], getreg(0, 1, 1))
1747 " in visual mode, gv swaps current and last selected region
1748 exe "norm! G0\<c-v>4k4lgvd"
1749 call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh'], getline(1,'$'))
1750 exe "norm! G0\<c-v>4k4ly"
1751 exe "norm! gvood"
1752 call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'fgh', 'fgh', 'fgh', 'fgh', 'fgh'], getline(1,'$'))
1753
1754 " Test for gk/gj
1755 %d
1756 15vsp
1757 set wrap listchars= sbr=
1758 let lineA='abcdefghijklmnopqrstuvwxyz'
1759 let lineB='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1760 $put =lineA
1761 $put =lineB
1762
1763 norm! 3gg0dgk
1764 call assert_equal(['', 'abcdefghijklmno', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'], getline(1, '$'))
1765 set nu
1766 norm! 3gg0gjdgj
1767 call assert_equal(['', 'abcdefghijklmno', '0123456789AMNOPQRSTUVWXYZ'], getline(1,'$'))
1768
1769 " Test for gJ
1770 norm! 2gggJ
1771 call assert_equal(['', 'abcdefghijklmno0123456789AMNOPQRSTUVWXYZ'], getline(1,'$'))
1772 call assert_equal(16, col('.'))
1773 " shouldn't do anything
1774 norm! 10gJ
1775 call assert_equal(1, col('.'))
1776
1777 " Test for g0 g^ gm g$
1778 exe "norm! 2gg0gji "
1779 call assert_equal(['', 'abcdefghijk lmno0123456789AMNOPQRSTUVWXYZ'], getline(1,'$'))
1780 norm! g0yl
1781 call assert_equal(12, col('.'))
1782 call assert_equal(' ', getreg(0))
1783 norm! g$yl
1784 call assert_equal(22, col('.'))
1785 call assert_equal('3', getreg(0))
1786 norm! gmyl
1787 call assert_equal(17, col('.'))
1788 call assert_equal('n', getreg(0))
1789 norm! g^yl
1790 call assert_equal(15, col('.'))
1791 call assert_equal('l', getreg(0))
1792
1793 " Test for g Ctrl-G
Bram Moolenaar0913a102016-09-03 19:11:59 +02001794 set ff=unix
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001795 let a=execute(":norm! g\<c-g>")
1796 call assert_match('Col 15 of 43; Line 2 of 2; Word 2 of 2; Byte 16 of 45', a)
1797
1798 " Test for gI
1799 norm! gIfoo
1800 call assert_equal(['', 'fooabcdefghijk lmno0123456789AMNOPQRSTUVWXYZ'], getline(1,'$'))
1801
1802 " Test for gi
1803 wincmd c
1804 %d
1805 set tw=0
1806 call setline(1, ['foobar', 'new line'])
1807 norm! A next word
1808 $put ='third line'
1809 norm! gi another word
1810 call assert_equal(['foobar next word another word', 'new line', 'third line'], getline(1,'$'))
1811
1812 " clean up
1813 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001814endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001815
1816fun! Test_normal34_g_cmd3()
1817 if !has("multi_byte")
1818 return
1819 endif
Bram Moolenaar395b6ba2017-04-07 20:09:51 +02001820
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001821 " Test for g8
1822 new
Bram Moolenaar395b6ba2017-04-07 20:09:51 +02001823 let a=execute(':norm! 1G0g8')
1824 call assert_equal("\nNUL", a)
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001825
Bram Moolenaar395b6ba2017-04-07 20:09:51 +02001826 call setline(1, 'abcdefghijklmnopqrstuvwxyzäüö')
1827 let a=execute(':norm! 1G$g8')
1828 call assert_equal("\nc3 b6 ", a)
1829
1830 call setline(1, "a\u0302")
1831 let a=execute(':norm! 1G0g8')
1832 call assert_equal("\n61 + cc 82 ", a)
1833
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001834 " clean up
1835 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001836endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001837
Bram Moolenaar395b6ba2017-04-07 20:09:51 +02001838func Test_normal_8g8()
1839 if !has("multi_byte")
1840 return
1841 endif
1842 new
1843
1844 " Test 8g8 which finds invalid utf8 at or after the cursor.
1845
1846 " With invalid byte.
1847 call setline(1, "___\xff___")
1848 norm! 1G08g8g
1849 call assert_equal([0, 1, 4, 0, 1], getcurpos())
1850
1851 " With invalid byte before the cursor.
1852 call setline(1, "___\xff___")
1853 norm! 1G$h8g8g
1854 call assert_equal([0, 1, 6, 0, 9], getcurpos())
1855
1856 " With truncated sequence.
1857 call setline(1, "___\xE2\x82___")
1858 norm! 1G08g8g
1859 call assert_equal([0, 1, 4, 0, 1], getcurpos())
1860
1861 " With overlong sequence.
1862 call setline(1, "___\xF0\x82\x82\xAC___")
1863 norm! 1G08g8g
1864 call assert_equal([0, 1, 4, 0, 1], getcurpos())
1865
1866 " With valid utf8.
1867 call setline(1, "café")
1868 norm! 1G08g8
1869 call assert_equal([0, 1, 1, 0, 1], getcurpos())
1870
1871 bw!
1872endfunc
1873
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001874fun! Test_normal35_g_cmd4()
1875 " Test for g<
1876 " Cannot capture its output,
1877 " probably a bug, therefore, test disabled:
Bram Moolenaar31845092016-09-05 22:58:31 +02001878 throw "Skipped: output of g< can't be tested currently"
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001879 echo "a\nb\nc\nd"
1880 let b=execute(':norm! g<')
1881 call assert_true(!empty(b), 'failed `execute(g<)`')
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001882endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001883
1884fun! Test_normal36_g_cmd5()
1885 new
1886 call append(0, 'abcdefghijklmnopqrstuvwxyz')
Bram Moolenaar0913a102016-09-03 19:11:59 +02001887 set ff=unix
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001888 " Test for gp gP
1889 call append(1, range(1,10))
1890 1
1891 norm! 1yy
1892 3
1893 norm! gp
1894 call assert_equal([0, 5, 1, 0, 1], getcurpos())
1895 $
1896 norm! gP
1897 call assert_equal([0, 14, 1, 0, 1], getcurpos())
1898
1899 " Test for go
1900 norm! 26go
1901 call assert_equal([0, 1, 26, 0, 26], getcurpos())
1902 norm! 27go
1903 call assert_equal([0, 1, 26, 0, 26], getcurpos())
1904 norm! 28go
1905 call assert_equal([0, 2, 1, 0, 1], getcurpos())
1906 set ff=dos
1907 norm! 29go
1908 call assert_equal([0, 2, 1, 0, 1], getcurpos())
1909 set ff=unix
1910 norm! gg0
1911 norm! 101go
1912 call assert_equal([0, 13, 26, 0, 26], getcurpos())
1913 norm! 103go
1914 call assert_equal([0, 14, 1, 0, 1], getcurpos())
1915 " count > buffer content
1916 norm! 120go
1917 call assert_equal([0, 14, 1, 0, 2147483647], getcurpos())
1918 " clean up
1919 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001920endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001921
1922fun! Test_normal37_g_cmd6()
1923 " basic test for gt and gT
1924 tabnew 1.txt
1925 tabnew 2.txt
1926 tabnew 3.txt
1927 norm! 1gt
1928 call assert_equal(1, tabpagenr())
1929 norm! 3gt
1930 call assert_equal(3, tabpagenr())
1931 norm! 1gT
1932 " count gT goes not to the absolute tabpagenumber
1933 " but, but goes to the count previous tabpagenumber
1934 call assert_equal(2, tabpagenr())
1935 " wrap around
1936 norm! 3gT
1937 call assert_equal(3, tabpagenr())
1938 " gt does not wrap around
1939 norm! 5gt
1940 call assert_equal(3, tabpagenr())
1941
1942 for i in range(3)
1943 tabclose
1944 endfor
1945 " clean up
1946 call assert_fails(':tabclose', 'E784')
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001947endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001948
1949fun! Test_normal38_nvhome()
1950 " Test for <Home> and <C-Home> key
1951 new
1952 call setline(1, range(10))
1953 $
1954 setl et sw=2
1955 norm! V10>$
1956 " count is ignored
1957 exe "norm! 10\<home>"
1958 call assert_equal(1, col('.'))
1959 exe "norm! \<home>"
1960 call assert_equal([0, 10, 1, 0, 1], getcurpos())
1961 exe "norm! 5\<c-home>"
1962 call assert_equal([0, 5, 1, 0, 1], getcurpos())
1963 exe "norm! \<c-home>"
1964 call assert_equal([0, 1, 1, 0, 1], getcurpos())
1965
1966 " clean up
1967 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001968endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001969
1970fun! Test_normal39_cw()
1971 " Test for cw and cW on whitespace
1972 " and cpo+=w setting
1973 new
1974 set tw=0
1975 call append(0, 'here are some words')
1976 norm! 1gg0elcwZZZ
1977 call assert_equal('hereZZZare some words', getline('.'))
1978 norm! 1gg0elcWYYY
1979 call assert_equal('hereZZZareYYYsome words', getline('.'))
1980 set cpo+=w
1981 call setline(1, 'here are some words')
1982 norm! 1gg0elcwZZZ
1983 call assert_equal('hereZZZ are some words', getline('.'))
1984 norm! 1gg2elcWYYY
1985 call assert_equal('hereZZZ areYYY some words', getline('.'))
1986 set cpo-=w
1987 norm! 2gg0cwfoo
1988 call assert_equal('foo', getline('.'))
1989
1990 " clean up
1991 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02001992endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02001993
1994fun! Test_normal40_ctrl_bsl()
1995 " Basic test for CTRL-\ commands
1996 new
1997 call append(0, 'here are some words')
1998 exe "norm! 1gg0a\<C-\>\<C-N>"
1999 call assert_equal('n', mode())
2000 call assert_equal(1, col('.'))
2001 call assert_equal('', visualmode())
2002 exe "norm! 1gg0viw\<C-\>\<C-N>"
2003 call assert_equal('n', mode())
2004 call assert_equal(4, col('.'))
2005 exe "norm! 1gg0a\<C-\>\<C-G>"
2006 call assert_equal('n', mode())
2007 call assert_equal(1, col('.'))
2008 "imap <buffer> , <c-\><c-n>
2009 set im
2010 exe ":norm! \<c-\>\<c-n>dw"
2011 set noim
2012 call assert_equal('are some words', getline(1))
2013 call assert_false(&insertmode)
2014
2015 " clean up
2016 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002017endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002018
2019fun! Test_normal41_insert_reg()
2020 " Test for <c-r>=, <c-r><c-r>= and <c-r><c-o>=
2021 " in insert mode
2022 new
2023 set sts=2 sw=2 ts=8 tw=0
2024 call append(0, ["aaa\tbbb\tccc", '', '', ''])
2025 let a=getline(1)
2026 norm! 2gg0
2027 exe "norm! a\<c-r>=a\<cr>"
2028 norm! 3gg0
2029 exe "norm! a\<c-r>\<c-r>=a\<cr>"
2030 norm! 4gg0
2031 exe "norm! a\<c-r>\<c-o>=a\<cr>"
2032 call assert_equal(['aaa bbb ccc', 'aaa bbb ccc', 'aaa bbb ccc', 'aaa bbb ccc', ''], getline(1, '$'))
2033
2034 " clean up
2035 set sts=0 sw=8 ts=8
Bram Moolenaar31845092016-09-05 22:58:31 +02002036 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002037endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002038
2039func! Test_normal42_halfpage()
2040 " basic test for Ctrl-D and Ctrl-U
2041 call Setup_NewWindow()
2042 call assert_equal(5, &scroll)
2043 exe "norm! \<c-d>"
2044 call assert_equal('6', getline('.'))
2045 exe "norm! 2\<c-d>"
2046 call assert_equal('8', getline('.'))
2047 call assert_equal(2, &scroll)
2048 set scroll=5
2049 exe "norm! \<c-u>"
2050 call assert_equal('3', getline('.'))
2051 1
2052 set scrolloff=5
2053 exe "norm! \<c-d>"
2054 call assert_equal('10', getline('.'))
2055 exe "norm! \<c-u>"
2056 call assert_equal('5', getline('.'))
2057 1
2058 set scrolloff=99
2059 exe "norm! \<c-d>"
2060 call assert_equal('10', getline('.'))
2061 set scrolloff=0
2062 100
2063 exe "norm! $\<c-u>"
2064 call assert_equal('95', getline('.'))
2065 call assert_equal([0, 95, 1, 0, 1], getcurpos())
2066 100
2067 set nostartofline
2068 exe "norm! $\<c-u>"
2069 call assert_equal('95', getline('.'))
2070 call assert_equal([0, 95, 2, 0, 2147483647], getcurpos())
2071 " cleanup
2072 set startofline
2073 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002074endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002075
2076fun! Test_normal43_textobject1()
2077 " basic tests for text object aw
2078 new
2079 call append(0, ['foobar,eins,foobar', 'foo,zwei,foo '])
2080 " diw
2081 norm! 1gg0diw
2082 call assert_equal([',eins,foobar', 'foo,zwei,foo ', ''], getline(1,'$'))
2083 " daw
2084 norm! 2ggEdaw
2085 call assert_equal([',eins,foobar', 'foo,zwei,', ''], getline(1, '$'))
2086 %d
2087 call append(0, ["foo\teins\tfoobar", "foo\tzwei\tfoo "])
2088 " diW
2089 norm! 2ggwd2iW
2090 call assert_equal(['foo eins foobar', 'foo foo ', ''], getline(1,'$'))
2091 " daW
2092 norm! 1ggd2aW
2093 call assert_equal(['foobar', 'foo foo ', ''], getline(1,'$'))
2094
2095 %d
2096 call append(0, ["foo\teins\tfoobar", "foo\tzwei\tfoo "])
2097 " aw in visual line mode switches to characterwise mode
2098 norm! 2gg$Vawd
2099 call assert_equal(['foo eins foobar', 'foo zwei foo'], getline(1,'$'))
2100 norm! 1gg$Viwd
2101 call assert_equal(['foo eins ', 'foo zwei foo'], getline(1,'$'))
2102
2103 " clean up
2104 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002105endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002106
2107func! Test_normal44_textobjects2()
2108 " basic testing for is and as text objects
2109 new
2110 call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here'])
2111 " Test for dis - does not remove trailing whitespace
2112 norm! 1gg0dis
2113 call assert_equal([' With some sentences!', '', 'Even with a question? And one more. And no sentence here', ''], getline(1,'$'))
2114 " Test for das - removes leading whitespace
2115 norm! 3ggf?ldas
2116 call assert_equal([' With some sentences!', '', 'Even with a question? And no sentence here', ''], getline(1,'$'))
2117 " when used in visual mode, is made characterwise
2118 norm! 3gg$Visy
2119 call assert_equal('v', visualmode())
2120 " reset visualmode()
2121 norm! 3ggVy
2122 norm! 3gg$Vasy
2123 call assert_equal('v', visualmode())
2124 " basic testing for textobjects a< and at
2125 %d
2126 call setline(1, ['<div> ','<a href="foobar" class="foo">xyz</a>',' </div>', ' '])
2127 " a<
2128 norm! 1gg0da<
2129 call assert_equal([' ', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
2130 norm! 1pj
2131 call assert_equal([' <div>', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
2132 " at
2133 norm! d2at
2134 call assert_equal([' '], getline(1,'$'))
2135 %d
2136 call setline(1, ['<div> ','<a href="foobar" class="foo">xyz</a>',' </div>', ' '])
2137 " i<
2138 norm! 1gg0di<
2139 call assert_equal(['<> ', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
2140 norm! 1Pj
2141 call assert_equal(['<div> ', '<a href="foobar" class="foo">xyz</a>', ' </div>', ' '], getline(1,'$'))
2142 norm! d2it
2143 call assert_equal(['<div></div>',' '], getline(1,'$'))
2144 " basic testing for a[ and i[ text object
2145 %d
2146 call setline(1, [' ', '[', 'one [two]', 'thre', ']'])
2147 norm! 3gg0di[
2148 call assert_equal([' ', '[', ']'], getline(1,'$'))
2149 call setline(1, [' ', '[', 'one [two]', 'thre', ']'])
2150 norm! 3gg0ftd2a[
2151 call assert_equal([' '], getline(1,'$'))
2152 %d
2153 " Test for i" when cursor is in front of a quoted object
2154 call append(0, 'foo "bar"')
2155 norm! 1gg0di"
2156 call assert_equal(['foo ""', ''], getline(1,'$'))
2157
2158 " clean up
2159 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002160endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002161
2162func! Test_normal45_drop()
2163 if !has("dnd")
2164 return
2165 endif
2166 " basic test for :drop command
2167 " unfortunately, without a gui, we can't really test much here,
2168 " so simply test that ~p fails (which uses the drop register)
2169 new
2170 call assert_fails(':norm! "~p', 'E353')
2171 call assert_equal([], getreg('~', 1, 1))
2172 " the ~ register is read only
2173 call assert_fails(':let @~="1"', 'E354')
2174 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002175endfunc
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002176
2177func! Test_normal46_ignore()
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002178 " This test uses multi byte characters
2179 if !has("multi_byte")
2180 return
2181 endif
2182
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002183 new
2184 " How to test this?
2185 " let's just for now test, that the buffer
2186 " does not change
2187 call feedkeys("\<c-s>", 't')
2188 call assert_equal([''], getline(1,'$'))
2189
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002190 " no valid commands
2191 exe "norm! \<char-0x100>"
2192 call assert_equal([''], getline(1,'$'))
2193
2194 exe "norm! ä"
2195 call assert_equal([''], getline(1,'$'))
2196
Bram Moolenaar87bc3f72016-09-03 17:33:54 +02002197 " clean up
2198 bw!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002199endfunc
Bram Moolenaarc4a908e2016-09-08 23:35:30 +02002200
2201func! Test_normal47_visual_buf_wipe()
2202 " This was causing a crash or ml_get error.
2203 enew!
2204 call setline(1,'xxx')
2205 normal $
2206 new
2207 call setline(1, range(1,2))
2208 2
2209 exe "norm \<C-V>$"
2210 bw!
2211 norm yp
2212 set nomodified
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002213endfunc
2214
2215func! Test_normal47_autocmd()
2216 " disabled, does not seem to be possible currently
2217 throw "Skipped: not possible to test cursorhold autocmd while waiting for input in normal_cmd"
2218 new
2219 call append(0, repeat('-',20))
2220 au CursorHold * call feedkeys('2l', '')
2221 1
2222 set updatetime=20
2223 " should delete 12 chars (d12l)
2224 call feedkeys('d1', '!')
2225 call assert_equal('--------', getline(1))
2226
2227 " clean up
2228 au! CursorHold
2229 set updatetime=4000
2230 bw!
2231endfunc
2232
2233func! Test_normal48_wincmd()
2234 new
2235 exe "norm! \<c-w>c"
2236 call assert_equal(1, winnr('$'))
2237 call assert_fails(":norm! \<c-w>c", "E444")
2238endfunc
2239
2240func! Test_normal49_counts()
2241 new
2242 call setline(1, 'one two three four five six seven eight nine ten')
2243 1
2244 norm! 3d2w
2245 call assert_equal('seven eight nine ten', getline(1))
2246 bw!
2247endfunc
2248
2249func! Test_normal50_commandline()
Bram Moolenaar4033c552017-09-16 20:54:51 +02002250 if !has("timers") || !has("cmdline_hist")
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002251 return
2252 endif
2253 func! DoTimerWork(id)
2254 call assert_equal('[Command Line]', bufname(''))
2255 " should fail, with E11, but does fail with E23?
2256 "call feedkeys("\<c-^>", 'tm')
2257
2258 " should also fail with E11
2259 call assert_fails(":wincmd p", 'E11')
2260 " return from commandline window
2261 call feedkeys("\<cr>")
2262 endfunc
2263
2264 let oldlang=v:lang
2265 lang C
2266 set updatetime=20
2267 call timer_start(100, 'DoTimerWork')
2268 try
2269 " throws E23, for whatever reason...
2270 call feedkeys('q:', 'x!')
2271 catch /E23/
2272 " no-op
2273 endtry
2274 " clean up
2275 set updatetime=4000
2276 exe "lang" oldlang
2277 bw!
2278endfunc
2279
2280func! Test_normal51_FileChangedRO()
2281 if !has("autocmd")
2282 return
2283 endif
Bram Moolenaare5f2a072017-02-01 22:31:49 +01002284 " Don't sleep after the warning message.
2285 call test_settime(1)
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002286 call writefile(['foo'], 'Xreadonly.log')
2287 new Xreadonly.log
2288 setl ro
2289 au FileChangedRO <buffer> :call feedkeys("\<c-^>", 'tix')
2290 call assert_fails(":norm! Af", 'E788')
2291 call assert_equal(['foo'], getline(1,'$'))
2292 call assert_equal('Xreadonly.log', bufname(''))
2293
2294 " cleanup
Bram Moolenaare5f2a072017-02-01 22:31:49 +01002295 call test_settime(0)
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002296 bw!
2297 call delete("Xreadonly.log")
2298endfunc
2299
2300func! Test_normal52_rl()
2301 if !has("rightleft")
2302 return
2303 endif
2304 new
2305 call setline(1, 'abcde fghij klmnopq')
2306 norm! 1gg$
2307 set rl
2308 call assert_equal(19, col('.'))
2309 call feedkeys('l', 'tx')
2310 call assert_equal(18, col('.'))
2311 call feedkeys('h', 'tx')
2312 call assert_equal(19, col('.'))
2313 call feedkeys("\<right>", 'tx')
2314 call assert_equal(18, col('.'))
2315 call feedkeys("\<s-right>", 'tx')
2316 call assert_equal(13, col('.'))
2317 call feedkeys("\<c-right>", 'tx')
2318 call assert_equal(7, col('.'))
2319 call feedkeys("\<c-left>", 'tx')
2320 call assert_equal(13, col('.'))
2321 call feedkeys("\<s-left>", 'tx')
2322 call assert_equal(19, col('.'))
2323 call feedkeys("<<", 'tx')
2324 call assert_equal(' abcde fghij klmnopq',getline(1))
2325 call feedkeys(">>", 'tx')
2326 call assert_equal('abcde fghij klmnopq',getline(1))
2327
2328 " cleanup
2329 set norl
2330 bw!
2331endfunc
2332
2333func! Test_normal53_digraph()
2334 if !has('digraphs')
2335 return
2336 endif
2337 new
2338 call setline(1, 'abcdefgh|')
2339 exe "norm! 1gg0f\<c-k>!!"
2340 call assert_equal(9, col('.'))
2341 set cpo+=D
2342 exe "norm! 1gg0f\<c-k>!!"
2343 call assert_equal(1, col('.'))
2344
2345 set cpo-=D
2346 bw!
2347endfunc
2348
Bram Moolenaarb1e04fc2017-03-29 13:08:35 +02002349func Test_normal54_Ctrl_bsl()
2350 new
2351 call setline(1, 'abcdefghijklmn')
2352 exe "norm! df\<c-\>\<c-n>"
2353 call assert_equal(['abcdefghijklmn'], getline(1,'$'))
2354 exe "norm! df\<c-\>\<c-g>"
2355 call assert_equal(['abcdefghijklmn'], getline(1,'$'))
2356 exe "norm! df\<c-\>m"
2357 call assert_equal(['abcdefghijklmn'], getline(1,'$'))
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002358 if !has("multi_byte")
2359 return
2360 endif
Bram Moolenaarb1e04fc2017-03-29 13:08:35 +02002361 call setline(2, 'abcdefghijklmnāf')
2362 norm! 2gg0
2363 exe "norm! df\<Char-0x101>"
2364 call assert_equal(['abcdefghijklmn', 'f'], getline(1,'$'))
2365 norm! 1gg0
2366 exe "norm! df\<esc>"
2367 call assert_equal(['abcdefghijklmn', 'f'], getline(1,'$'))
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002368
Bram Moolenaarb1e04fc2017-03-29 13:08:35 +02002369 " clean up
2370 bw!
2371endfunc
2372
2373func Test_normal_large_count()
2374 " This may fail with 32bit long, how do we detect that?
2375 new
2376 normal o
2377 normal 6666666666dL
2378 bwipe!
Bram Moolenaar2931f2a2016-09-09 16:59:08 +02002379endfunc
Bram Moolenaarbf3d5802017-03-29 19:48:11 +02002380
2381func Test_delete_until_paragraph()
2382 if !has('multi_byte')
2383 return
2384 endif
2385 new
2386 normal grádv}
2387 call assert_equal('á', getline(1))
2388 normal grád}
2389 call assert_equal('', getline(1))
2390 bwipe!
2391endfunc