1" Various tests for inserting a Tab. 2 3" Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set. 4" Also test that dv_ works correctly 5func Test_smarttab() 6 enew! 7 set smarttab expandtab ts=8 sw=4 8 " make sure that backspace works, no matter what termcap is used 9 exe "set t_kD=\<C-V>x7f t_kb=\<C-V>x08" 10 call append(0, ['start text', 11 \ "\t\tsome test text", 12 \ 'test text', 13 \ "\t\tother test text", 14 \ ' a cde', 15 \ ' f ghi', 16 \ 'test text', 17 \ ' Second line beginning with whitespace' 18 \ ]) 19 call cursor(1, 1) 20 exe "normal /some\<CR>" 21 exe "normal r\t" 22 call assert_equal("\t\t ome test text", getline('.')) 23 set noexpandtab 24 exe "normal /other\<CR>" 25 exe "normal r\t" 26 call assert_equal("\t\t ther test text", getline('.')) 27 28 " Test replacing with Tabs and then backspacing to undo it 29 exe "normal j0wR\t\t\t\<BS>\<BS>\<BS>" 30 call assert_equal(" a cde", getline('.')) 31 " Test replacing with Tabs 32 exe "normal j0wR\t\t\t" 33 call assert_equal(" \t\thi", getline('.')) 34 35 " Test that copyindent works with expandtab set 36 set expandtab smartindent copyindent ts=8 sw=8 sts=8 37 exe "normal jo{\<CR>x" 38 call assert_equal('{', getline(line('.') - 1)) 39 call assert_equal(' x', getline('.')) 40 set nosol 41 exe "normal /Second line/\<CR>" 42 exe "normal fwdv_" 43 call assert_equal(' with whitespace', getline('.')) 44 enew! 45 set expandtab& smartindent& copyindent& ts& sw& sts& 46endfunc 47 48func Test_softtabstop() 49 new 50 set sts=0 sw=0 51 exe "normal ix\<Tab>x\<Esc>" 52 call assert_equal("x\tx", getline(1)) 53 54 call setline(1, '') 55 set sts=4 56 exe "normal ix\<Tab>x\<Esc>" 57 call assert_equal("x x", getline(1)) 58 59 call setline(1, '') 60 set sts=-1 sw=4 61 exe "normal ix\<Tab>x\<Esc>" 62 call assert_equal("x x", getline(1)) 63 64 call setline(1, 'x ') 65 set sts=0 sw=0 backspace=start 66 exe "normal A\<BS>x\<Esc>" 67 call assert_equal("x x", getline(1)) 68 69 call setline(1, 'x ') 70 set sts=4 71 exe "normal A\<BS>x\<Esc>" 72 call assert_equal("x x", getline(1)) 73 74 call setline(1, 'x ') 75 set sts=-1 sw=4 76 exe "normal A\<BS>x\<Esc>" 77 call assert_equal("x x", getline(1)) 78 79 call setline(1, 'x') 80 set sts=-1 sw=0 smarttab 81 exe "normal I\<Tab>\<Esc>" 82 call assert_equal("\tx", getline(1)) 83 84 call setline(1, 'x') 85 exe "normal I\<Tab>\<BS>\<Esc>" 86 call assert_equal("x", getline(1)) 87 88 set sts=0 sw=0 backspace& nosmarttab 89 bwipe! 90endfunc 91 92" vim: shiftwidth=2 sts=2 expandtab 93