1 2func Test_yank_put_clipboard() 3 new 4 call setline(1, ['a', 'b', 'c']) 5 set clipboard=unnamed 6 g/^/normal yyp 7 call assert_equal(['a', 'a', 'b', 'b', 'c', 'c'], getline(1, 6)) 8 9 set clipboard& 10 bwipe! 11endfunc 12 13func Test_nested_global() 14 new 15 call setline(1, ['nothing', 'found', 'found bad', 'bad']) 16 call assert_fails('g/found/3v/bad/s/^/++/', 'E147') 17 g/found/v/bad/s/^/++/ 18 call assert_equal(['nothing', '++found', 'found bad', 'bad'], getline(1, 4)) 19 bwipe! 20endfunc 21 22func Test_global_error() 23 call assert_fails('g\\a', 'E10:') 24 call assert_fails('g', 'E148:') 25 call assert_fails('g/\(/y', 'E476:') 26endfunc 27 28" Test for printing lines using :g with different search patterns 29func Test_global_print() 30 new 31 call setline(1, ['foo', 'bar', 'foo', 'foo']) 32 let @/ = 'foo' 33 let t = execute("g/")->trim()->split("\n") 34 call assert_equal(['foo', 'foo', 'foo'], t) 35 36 " Test for Vi compatible patterns 37 let @/ = 'bar' 38 let t = execute('g\/')->trim()->split("\n") 39 call assert_equal(['bar'], t) 40 41 normal gg 42 s/foo/foo/ 43 let t = execute('g\&')->trim()->split("\n") 44 call assert_equal(['foo', 'foo', 'foo'], t) 45 46 let @/ = 'bar' 47 let t = execute('g?')->trim()->split("\n") 48 call assert_equal(['bar'], t) 49 50 " Test for the 'Pattern found in every line' message 51 let v:statusmsg = '' 52 v/foo\|bar/p 53 call assert_notequal('', v:statusmsg) 54 55 close! 56endfunc 57 58" Test for global command with newline character 59func Test_global_newline() 60 new 61 call setline(1, ['foo']) 62 exe "g/foo/s/f/h/\<NL>s/o$/w/" 63 call assert_equal('how', getline(1)) 64 call setline(1, ["foo\<NL>bar"]) 65 exe "g/foo/s/foo\\\<NL>bar/xyz/" 66 call assert_equal('xyz', getline(1)) 67 close! 68endfunc 69 70" vim: shiftwidth=2 sts=2 expandtab 71