diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/testdir/test_normal.vim | 32 | ||||
-rw-r--r-- | src/nvim/testdir/test_visual.vim | 92 |
2 files changed, 124 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index e9de94c0b3..4a00999c45 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -2883,3 +2883,35 @@ func Test_normal_gk() bw! set cpoptions& number& numberwidth& endfunc + +" Some commands like yy, cc, dd, >>, << and !! accept a count after +" typing the first letter of the command. +func Test_normal_count_after_operator() + new + setlocal shiftwidth=4 tabstop=8 autoindent + call setline(1, ['one', 'two', 'three', 'four', 'five']) + let @a = '' + normal! j"ay4y + call assert_equal("two\nthree\nfour\nfive\n", @a) + normal! 3G>2> + call assert_equal(['one', 'two', ' three', ' four', 'five'], + \ getline(1, '$')) + exe "normal! 3G0c2cred\nblue" + call assert_equal(['one', 'two', ' red', ' blue', 'five'], + \ getline(1, '$')) + exe "normal! gg<8<" + call assert_equal(['one', 'two', 'red', 'blue', 'five'], + \ getline(1, '$')) + exe "normal! ggd3d" + call assert_equal(['blue', 'five'], getline(1, '$')) + call setline(1, range(1, 4)) + call feedkeys("gg!3!\<C-B>\"\<CR>", 'xt') + call assert_equal('".,.+2!', @:) + call feedkeys("gg!1!\<C-B>\"\<CR>", 'xt') + call assert_equal('".!', @:) + call feedkeys("gg!9!\<C-B>\"\<CR>", 'xt') + call assert_equal('".,$!', @:) + bw! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index c879db1542..21fd57b791 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -762,7 +762,99 @@ func Test_visual_block_mode() \ 'axyzqqqqefgmnoklm', \ 'abcdqqqqijklm'], getline(1, 5)) + " Test from ':help v_b_I_example' + %d _ + setlocal tabstop=8 shiftwidth=4 + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\<C-V>3jISTRING" + let expected =<< trim END + abcdefghijklmnSTRINGopqrstuvwxyz + abc STRING defghijklmnopqrstuvwxyz + abcdef ghi STRING jklmnopqrstuvwxyz + abcdefghijklmnSTRINGopqrstuvwxyz + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_A_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\<C-V>3j$ASTRING" + let expected =<< trim END + abcdefghijklmnopqrstuvwxyzSTRING + abc defghijklmnopqrstuvwxyzSTRING + abcdef ghi jklmnopqrstuvwxyzSTRING + abcdefghijklmnopqrstuvwxyzSTRING + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_<_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\<C-V>3j3l<.." + let expected =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_>_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\<C-V>3j>.." + let expected =<< trim END + abcdefghijklmn opqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmn opqrstuvwxyz + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_r_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\<C-V>5l3jrX" + let expected =<< trim END + abcdefghijklmnXXXXXXuvwxyz + abc XXXXXXhijklmnopqrstuvwxyz + abcdef ghi XXXXXX jklmnopqrstuvwxyz + abcdefghijklmnXXXXXXuvwxyz + END + call assert_equal(expected, getline(1, '$')) + bwipe! + set tabstop& shiftwidth& endfunc " Test block-insert using cursor keys for movement |