1" Test shifting lines with :> and :< 2 3source check.vim 4 5func Test_ex_shift_right() 6 set shiftwidth=2 7 8 " shift right current line. 9 call setline(1, range(1, 5)) 10 2 11 > 12 3 13 >> 14 call assert_equal(['1', 15 \ ' 2', 16 \ ' 3', 17 \ '4', 18 \ '5'], getline(1, '$')) 19 20 " shift right with range. 21 call setline(1, range(1, 4)) 22 2,3>> 23 call assert_equal(['1', 24 \ ' 2', 25 \ ' 3', 26 \ '4', 27 \ '5'], getline(1, '$')) 28 29 " shift right with range and count. 30 call setline(1, range(1, 4)) 31 2>3 32 call assert_equal(['1', 33 \ ' 2', 34 \ ' 3', 35 \ ' 4', 36 \ '5'], getline(1, '$')) 37 38 bw! 39 set shiftwidth& 40endfunc 41 42func Test_ex_shift_left() 43 set shiftwidth=2 44 45 call setline(1, range(1, 5)) 46 %>>> 47 48 " left shift current line. 49 2< 50 3<< 51 4<<<<< 52 call assert_equal([' 1', 53 \ ' 2', 54 \ ' 3', 55 \ '4', 56 \ ' 5'], getline(1, '$')) 57 58 " shift right with range. 59 call setline(1, range(1, 5)) 60 %>>> 61 2,3<< 62 call assert_equal([' 1', 63 \ ' 2', 64 \ ' 3', 65 \ ' 4', 66 \ ' 5'], getline(1, '$')) 67 68 " shift right with range and count. 69 call setline(1, range(1, 5)) 70 %>>> 71 2<<3 72 call assert_equal([' 1', 73 \ ' 2', 74 \ ' 3', 75 \ ' 4', 76 \ ' 5'], getline(1, '$')) 77 78 bw! 79 set shiftwidth& 80endfunc 81 82func Test_ex_shift_rightleft() 83 CheckFeature rightleft 84 85 set shiftwidth=2 rightleft 86 87 call setline(1, range(1, 4)) 88 2,3<< 89 call assert_equal(['1', 90 \ ' 2', 91 \ ' 3', 92 \ '4'], getline(1, '$')) 93 94 3,4> 95 call assert_equal(['1', 96 \ ' 2', 97 \ ' 3', 98 \ '4'], getline(1, '$')) 99 100 bw! 101 set rightleft& shiftwidth& 102endfunc 103 104func Test_ex_shift_errors() 105 call assert_fails('><', 'E488:') 106 call assert_fails('<>', 'E488:') 107 108 call assert_fails('>!', 'E477:') 109 call assert_fails('<!', 'E477:') 110 111 call assert_fails('2,1>', 'E493:') 112 call assert_fails('2,1<', 'E493:') 113endfunc 114 115" vim: shiftwidth=2 sts=2 expandtab 116