annotate src/testdir/test_cpoptions.vim @ 20832:045442aa392b v8.2.0968

patch 8.2.0968: no proper testing of the 'cpoptions' flags Commit: https://github.com/vim/vim/commit/c9630d2658af9dcaa01913e899b201bfdef7b536 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 13 13:20:48 2020 +0200 patch 8.2.0968: no proper testing of the 'cpoptions' flags Problem: No proper testing of the 'cpoptions' flags. Solution: Add tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6251)
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 Jun 2020 13:30:04 +0200
parents
children d3fa0d29fa9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20832
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test for various 'cpoptions' (cpo) flags
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 source check.vim
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 source view_util.vim
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 " Test for the 'a' flag in 'cpo'. Reading a file should set the alternate
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 " file name.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 func Test_cpo_a()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 call writefile(['one'], 'Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 " Wipe out all the buffers, so that the alternate file is empty
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 edit Xfoo | %bw
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 set cpo-=a
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 read Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 call assert_equal('', @#)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 set cpo+=a
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 read Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 call assert_equal('Xfile', @#)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 call delete('Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 " Test for the 'A' flag in 'cpo'. Writing a file should set the alternate
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 " file name.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 func Test_cpo_A()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 " Wipe out all the buffers, so that the alternate file is empty
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 edit Xfoo | %bw
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 set cpo-=A
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 new Xfile1
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 write Xfile2
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 call assert_equal('', @#)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 %bw
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 call delete('Xfile2')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 new Xfile1
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 set cpo+=A
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 write Xfile2
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 call assert_equal('Xfile2', @#)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 call delete('Xfile2')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 " Test for the 'b' flag in 'cpo'. "\|" at the end of a map command is
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 " recognized as the end of the map.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 func Test_cpo_b()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 set cpo+=b
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 nnoremap <F5> :pwd\<CR>\|let i = 1
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 call assert_equal(':pwd\<CR>\', maparg('<F5>'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 nunmap <F5>
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 exe "nnoremap <F5> :pwd\<C-V>|let i = 1"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 call assert_equal(':pwd|let i = 1', maparg('<F5>'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 nunmap <F5>
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 set cpo-=b
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 nnoremap <F5> :pwd\<CR>\|let i = 1
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 call assert_equal(':pwd\<CR>|let i = 1', maparg('<F5>'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 nunmap <F5>
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 " Test for the 'c' flag in 'cpo'.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 func Test_cpo_c()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 set cpo+=c
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 call setline(1, ' abababababab')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 exe "normal gg/abab\<CR>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 call assert_equal(3, searchcount().total)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 set cpo-=c
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 exe "normal gg/abab\<CR>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 call assert_equal(5, searchcount().total)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 " Test for the 'C' flag in 'cpo' (line continuation)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 func Test_cpo_C()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 call writefile(['let l = [', '\ 1,', '\ 2]'], 'Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 set cpo-=C
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 source Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 call assert_equal([1, 2], g:l)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 set cpo+=C
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 call assert_fails('source Xfile', 'E10:')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 call delete('Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 " Test for the 'd' flag in 'cpo' (tags relative to the current file)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 func Test_cpo_d()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 call mkdir('Xdir')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 call writefile(["one\tXfile1\t/^one$/"], 'tags')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 call writefile(["two\tXfile2\t/^two$/"], 'Xdir/tags')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 set tags=./tags
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 set cpo-=d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 edit Xdir/Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 call assert_equal('two', taglist('.*')[0].name)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 set cpo+=d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 call assert_equal('one', taglist('.*')[0].name)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 %bw!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 call delete('tags')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 call delete('Xdir', 'rf')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 set tags&
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 " Test for the 'D' flag in 'cpo' (digraph after a r, f or t)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 func Test_cpo_D()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 CheckFeature digraphs
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 set cpo-=D
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 call setline(1, 'abcdefgh|')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 exe "norm! 1gg0f\<c-k>!!"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 call assert_equal(9, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 set cpo+=D
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 exe "norm! 1gg0f\<c-k>!!"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 call assert_equal(1, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 set cpo-=D
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 " Test for the 'e' flag in 'cpo'
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 func Test_cpo_e()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 let @a='let i = 45'
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 set cpo+=e
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 call feedkeys(":@a\<CR>", 'xt')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 call assert_equal(45, i)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 set cpo-=e
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 call feedkeys(":@a\<CR>6\<CR>", 'xt')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 call assert_equal(456, i)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 " Test for the 'E' flag in 'cpo' with yank, change, delete, etc. operators
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 func Test_cpo_E()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 call setline(1, '')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 set cpo+=E
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 " yank an empty line
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 call assert_beeps('normal "ayl')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 " change an empty line
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 call assert_beeps('normal lcTa')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 " delete an empty line
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 call assert_beeps('normal D')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 call assert_beeps('normal dl')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 call assert_equal('', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 " change case of an empty line
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 call assert_beeps('normal gul')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 call assert_beeps('normal gUl')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 " replace a character
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 call assert_beeps('normal vrx')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 " increment and decrement
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 call assert_beeps('exe "normal v\<C-A>"')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 call assert_beeps('exe "normal v\<C-X>"')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 set cpo-=E
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 " Test for the 'f' flag in 'cpo' (read in an empty buffer sets the file name)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 func Test_cpo_f()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 set cpo-=f
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 read test_cpoptions.vim
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 call assert_equal('', @%)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 set cpo+=f
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 read test_cpoptions.vim
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 call assert_equal('test_cpoptions.vim', @%)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 " Test for the 'F' flag in 'cpo' (write in an empty buffer sets the file name)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 func Test_cpo_F()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 set cpo-=F
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 write Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 call assert_equal('', @%)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 call delete('Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 set cpo+=F
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 write Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 call assert_equal('Xfile', @%)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 call delete('Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 " Test for the 'g' flag in 'cpo' (jump to line 1 when re-editing a file)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 func Test_cpo_g()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 new test_cpoptions.vim
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 set cpo-=g
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 normal 20G
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 edit
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 call assert_equal(20, line('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 set cpo+=g
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 edit
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 call assert_equal(1, line('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 " Test for inserting text in a line with only spaces ('H' flag in 'cpoptions')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 func Test_cpo_H()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 set cpo-=H
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 call setline(1, ' ')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 normal! Ia
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 call assert_equal(' a', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 set cpo+=H
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 call setline(1, ' ')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 normal! Ia
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 call assert_equal(' a ', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 " Test for the 'I' flag in 'cpo' (deleting autoindent when using arrow keys)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 func Test_cpo_I()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 setlocal autoindent
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 set cpo+=I
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 exe "normal i one\<CR>\<Up>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 call assert_equal(' ', getline(2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 set cpo-=I
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 exe "normal i one\<CR>\<Up>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 call assert_equal('', getline(2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 " Test for the 'J' flag in 'cpo' (two spaces after a sentence)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 func Test_cpo_J()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 set cpo-=J
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 call setline(1, 'one. two! three? four."'' five.)]')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 normal 0
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 for colnr in [6, 12, 19, 28, 34]
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 normal )
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 call assert_equal(colnr, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 endfor
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 for colnr in [28, 19, 12, 6, 1]
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 normal (
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 call assert_equal(colnr, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 endfor
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 set cpo+=J
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 normal 0
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 for colnr in [12, 28, 34]
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 normal )
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 call assert_equal(colnr, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 endfor
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 for colnr in [28, 12, 1]
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 normal (
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 call assert_equal(colnr, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 endfor
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 " TODO: Add a test for 'k' in 'cpo'
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 " TODO: Add a test for 'K' in 'cpo'
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 " Test for the 'l' flag in 'cpo' (backslash in a [] range)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 func Test_cpo_l()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 call setline(1, ['', "a\tc" .. '\t'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 set cpo-=l
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 exe 'normal gg/[\t]' .. "\<CR>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 call assert_equal([2, 8], [col('.'), virtcol('.')])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 set cpo+=l
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 exe 'normal gg/[\t]' .. "\<CR>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 call assert_equal([4, 10], [col('.'), virtcol('.')])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 " Test for inserting tab in virtual replace mode ('L' flag in 'cpoptions')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 func Test_cpo_L()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 set cpo-=L
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 call setline(1, 'abcdefghijklmnopqr')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 exe "normal 0gR\<Tab>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 call assert_equal("\<Tab>ijklmnopqr", getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 set cpo+=L
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 set list
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 call setline(1, 'abcdefghijklmnopqr')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 exe "normal 0gR\<Tab>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 call assert_equal("\<Tab>cdefghijklmnopqr", getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 set nolist
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 call setline(1, 'abcdefghijklmnopqr')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 exe "normal 0gR\<Tab>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 call assert_equal("\<Tab>ijklmnopqr", getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 " TODO: This test doesn't work.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 " Test for the 'M' flag in 'cpo' (% with escape parenthesis)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 func Test_cpo_M()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 call setline(1, ['( \( )', '\( ( \)'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 set cpo-=M
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 call cursor(1, 1)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 normal %
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 call assert_equal(6, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 call cursor(1, 4)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 call assert_beeps('normal %')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 call cursor(2, 2)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 normal %
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 call assert_equal(7, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 call cursor(2, 4)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 call assert_beeps('normal %')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 set cpo+=M
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 call cursor(1, 4)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 normal %
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 call assert_equal(6, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 call cursor(1, 1)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 call assert_beeps('normal %')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 call cursor(2, 4)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 normal %
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 call assert_equal(7, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 call cursor(2, 1)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 call assert_beeps('normal %')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 " Test for the 'n' flag in 'cpo' (using number column for wrapped lines)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 func Test_cpo_n()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 call setline(1, repeat('a', &columns))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 setlocal number
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 set cpo-=n
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 redraw!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 call assert_equal(' aaaa', Screenline(2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 set cpo+=n
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 redraw!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 call assert_equal('aaaa', Screenline(2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 " Test for the 'o' flag in 'cpo' (line offset to search command)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 func Test_cpo_o()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 call setline(1, ['', 'one', 'two', 'three', 'one', 'two', 'three'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 set cpo-=o
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 exe "normal /one/+2\<CR>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 normal n
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 call assert_equal(7, line('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 set cpo+=o
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 exe "normal /one/+2\<CR>"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 normal n
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 call assert_equal(5, line('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 " Test for the 'O' flag in 'cpo' (overwriting an existing file)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 func Test_cpo_O()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 new Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 call setline(1, 'one')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 call writefile(['two'], 'Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 set cpo-=O
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 call assert_fails('write', 'E13:')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 set cpo+=O
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 write
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 call assert_equal(['one'], readfile('Xfile'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 call delete('Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 " Test for the 'P' flag in 'cpo' (appending to a file sets the current file
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 " name)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 func Test_cpo_P()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 call writefile([], 'Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 call setline(1, 'one')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 set cpo+=F
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 set cpo-=P
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 write >> Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 call assert_equal('', @%)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 set cpo+=P
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 write >> Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 call assert_equal('Xfile', @%)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 call delete('Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 " Test for the 'q' flag in 'cpo' (joining multiple lines)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 func Test_cpo_q()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 call setline(1, ['one', 'two', 'three', 'four', 'five'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 set cpo-=q
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 normal gg4J
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 call assert_equal(14, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 call setline(1, ['one', 'two', 'three', 'four', 'five'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 set cpo+=q
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 normal gg4J
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 call assert_equal(4, col('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 " Test for the 'r' flag in 'cpo' (redo command with a search motion)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 func Test_cpo_r()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 call setline(1, repeat(['one two three four'], 2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 set cpo-=r
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 exe "normal ggc/two\<CR>abc "
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 let @/ = 'three'
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 normal 2G.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 call assert_equal('abc two three four', getline(2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 call setline(1, repeat(['one two three four'], 2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 set cpo+=r
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 exe "normal ggc/two\<CR>abc "
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 let @/ = 'three'
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 normal 2G.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 call assert_equal('abc three four', getline(2))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 " Test for the 'R' flag in 'cpo' (clear marks after a filter command)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 func Test_cpo_R()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 CheckUnix
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 call setline(1, ['three', 'one', 'two'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 set cpo-=R
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 3mark r
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 %!sort
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 call assert_equal(3, line("'r"))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 call setline(1, ['three', 'one', 'two'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 set cpo+=R
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 3mark r
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 %!sort
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 call assert_equal(0, line("'r"))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 " Test for the 'S' flag in 'cpo' (copying buffer options)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 func Test_cpo_S()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 new Xfile1
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 set noautoindent
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 new Xfile2
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 set cpo-=S
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 set autoindent
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 wincmd p
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 call assert_equal(0, &autoindent)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 wincmd p
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 call assert_equal(1, &autoindent)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 set cpo+=S
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 wincmd p
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 call assert_equal(1, &autoindent)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 set noautoindent
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 wincmd p
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 call assert_equal(0, &autoindent)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 wincmd t
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 " Test for the 'u' flag in 'cpo' (Vi-compatible undo)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 func Test_cpo_u()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 set cpo-=u
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 exe "normal iabc\<C-G>udef\<C-G>ughi"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 normal uu
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 call assert_equal('abc', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 set cpo+=u
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 exe "normal iabc\<C-G>udef\<C-G>ughi"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 normal uu
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 call assert_equal('abcdefghi', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 " Test for the 'x' flag in 'cpo' (Esc on command-line executes command)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 func Test_cpo_x()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 set cpo-=x
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 let i = 1
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 call feedkeys(":let i=10\<Esc>", 'xt')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 call assert_equal(1, i)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 set cpo+=x
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 call feedkeys(":let i=10\<Esc>", 'xt')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 call assert_equal(10, i)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 " Test for the 'X' flag in 'cpo' ('R' with a count)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 func Test_cpo_X()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 call setline(1, 'aaaaaa')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 set cpo-=X
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 normal gg4Rx
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 call assert_equal('xxxxaa', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 normal ggRy
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 normal 4.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 call assert_equal('yyyyaa', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 call setline(1, 'aaaaaa')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 set cpo+=X
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 normal gg4Rx
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 call assert_equal('xxxxaaaaa', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 normal ggRy
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 normal 4.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 call assert_equal('yyyyxxxaaaaa', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 " Test for the 'y' flag in 'cpo' (repeating a yank command)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 func Test_cpo_y()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 call setline(1, ['one', 'two'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 set cpo-=y
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 normal ggyy
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 normal 2G.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 call assert_equal("one\n", @")
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 %d
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 call setline(1, ['one', 'two'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 set cpo+=y
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 normal ggyy
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 normal 2G.
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 call assert_equal("two\n", @")
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 " Test for the 'Z' flag in 'cpo' (write! resets 'readonly')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 func Test_cpo_Z()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 call writefile([], 'Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 new Xfile
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 setlocal readonly
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 set cpo-=Z
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 write!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 call assert_equal(0, &readonly)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 set cpo+=Z
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 setlocal readonly
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 write!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 call assert_equal(1, &readonly)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 call delete('Xfile')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 " Test for cursor movement with '-' in 'cpoptions'
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 func Test_cpo_minus()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 call setline(1, ['foo', 'bar', 'baz'])
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 let save_cpo = &cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 set cpo+=-
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 call assert_beeps('normal 10j')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 call assert_equal(1, line('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 normal G
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 call assert_beeps('normal 10k')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 call assert_equal(3, line('.'))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 call assert_fails(10, 'E16:')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 let &cpo = save_cpo
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 close!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 " Test for displaying dollar when changing text ('$' flag in 'cpoptions')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 func Test_cpo_dollar()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 new
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 let g:Line = ''
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 func SaveFirstLine()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 let g:Line = Screenline(1)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 return ''
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 inoremap <expr> <buffer> <F2> SaveFirstLine()
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 call test_override('redraw_flag', 1)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 set cpo+=$
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 call setline(1, 'one two three')
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 redraw!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 exe "normal c2w\<F2>vim"
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 call assert_equal('one tw$ three', g:Line)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 call assert_equal('vim three', getline(1))
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 set cpo-=$
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 call test_override('ALL', 0)
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 delfunc SaveFirstLine
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 %bw!
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 endfunc
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626
045442aa392b patch 8.2.0968: no proper testing of the 'cpoptions' flags
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 " vim: shiftwidth=2 sts=2 expandtab