blob: b847dbd9628497d0acfafbe188d84b083d7fd97a [file] [log] [blame]
Bram Moolenaar15993ce2017-10-26 20:21:44 +02001
2" Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set.
3" Also test that dv_ works correctly
4func Test_smarttab()
5 enew!
6 set smarttab expandtab ts=8 sw=4
7 " make sure that backspace works, no matter what termcap is used
8 exe "set t_kD=\<C-V>x7f t_kb=\<C-V>x08"
9 call append(0, ['start text',
10 \ "\t\tsome test text",
11 \ 'test text',
12 \ "\t\tother test text",
13 \ ' a cde',
14 \ ' f ghi',
15 \ 'test text',
16 \ ' Second line beginning with whitespace'
17 \ ])
18 call cursor(1, 1)
19 exe "normal /some\<CR>"
20 exe "normal r\t"
21 call assert_equal("\t\t ome test text", getline('.'))
22 set noexpandtab
23 exe "normal /other\<CR>"
24 exe "normal r\t"
25 call assert_equal("\t\t ther test text", getline('.'))
26
27 " Test replacing with Tabs and then backspacing to undo it
28 exe "normal j0wR\t\t\t\<BS>\<BS>\<BS>"
29 call assert_equal(" a cde", getline('.'))
30 " Test replacing with Tabs
31 exe "normal j0wR\t\t\t"
32 call assert_equal(" \t\thi", getline('.'))
33
34 " Test that copyindent works with expandtab set
35 set expandtab smartindent copyindent ts=8 sw=8 sts=8
36 exe "normal jo{\<CR>x"
37 call assert_equal('{', getline(line('.') - 1))
38 call assert_equal(' x', getline('.'))
39 set nosol
40 exe "normal /Second line/\<CR>"
41 exe "normal fwdv_"
42 call assert_equal(' with whitespace', getline('.'))
43 enew!
44 set expandtab& smartindent& copyindent& ts& sw& sts&
45endfunc