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