blob: 8ca9c9ed291236877fbc154da7d263df3a8edceb [file] [log] [blame]
Bram Moolenaar06a89a52006-04-29 22:01:03 +00001Tests for string and html text objects. vim: set ft=vim :
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002
Bram Moolenaar89cb5e02004-07-19 20:55:54 +00003Note that the end-of-line moves the cursor to the next test line.
4
5Also test match() and matchstr()
6
Bram Moolenaar9feaf622014-02-22 22:18:47 +01007Also test the gn command and repeating it.
8
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009STARTTEST
10:so small.vim
11/^start:/
12da"
130va'a'rx
1402f`da`
150fXdi"
1603f'vi'ry
17:set quoteescape=+*-
18di`
19$F"va"oha"i"rz
Bram Moolenaar06a89a52006-04-29 22:01:03 +000020:"
21/^<begin
22jfXdit
230fXdit
24fXdat
250fXdat
26:"
27:put =matchstr(\"abcd\", \".\", 0, 2) " b
Bram Moolenaar89cb5e02004-07-19 20:55:54 +000028:put =matchstr(\"abcd\", \"..\", 0, 2) " bc
29:put =matchstr(\"abcd\", \".\", 2, 0) " c (zero and negative -> first match)
30:put =matchstr(\"abcd\", \".\", 0, -1) " a
31:put =match(\"abcd\", \".\", 0, 5) " -1
32:put =match(\"abcd\", \".\", 0, -1) " 0
Bram Moolenaar9feaf622014-02-22 22:18:47 +010033:put =match('abc', '.', 0, 1) " 0
34:put =match('abc', '.', 0, 2) " 1
35:put =match('abc', '.', 0, 3) " 2
36:put =match('abc', '.', 0, 4) " -1
37:put =match('abc', '.', 1, 1) " 1
38:put =match('abc', '.', 2, 1) " 2
39:put =match('abc', '.', 3, 1) " -1
40:put =match('abc', '$', 0, 1) " 3
41:put =match('abc', '$', 0, 2) " -1
42:put =match('abc', '$', 1, 1) " 3
43:put =match('abc', '$', 2, 1) " 3
44:put =match('abc', '$', 3, 1) " 3
45:put =match('abc', '$', 4, 1) " -1
46:put =match('abc', '\zs', 0, 1) " 0
47:put =match('abc', '\zs', 0, 2) " 1
48:put =match('abc', '\zs', 0, 3) " 2
49:put =match('abc', '\zs', 0, 4) " 3
50:put =match('abc', '\zs', 0, 5) " -1
51:put =match('abc', '\zs', 1, 1) " 1
52:put =match('abc', '\zs', 2, 1) " 2
53:put =match('abc', '\zs', 3, 1) " 3
54:put =match('abc', '\zs', 4, 1) " -1
Bram Moolenaar641e2862012-07-25 15:06:34 +020055/^foobar
56gncsearchmatch/one\_s*two\_s
57:1
58gnd
59/[a]bcdx
60:1
Bram Moolenaardd7d8462012-08-29 16:55:13 +0200612gnd/join
62/$
630gnd
64/\>\zs
650gnd/^
66gnd$h/\zs
Bram Moolenaar57c0ea82012-09-05 12:16:45 +020067gnd/[u]niquepattern/s
68vlgnd
Bram Moolenaar0c178752012-10-11 03:35:45 +020069/mother
70:set selection=exclusive
Bram Moolenaare78495d2013-06-30 14:46:53 +020071$cgNmongoose/i
72cgnj
Bram Moolenaar4c7cb6b2013-10-02 21:55:02 +020073:" Make sure there is no other match y uppercase.
74/x59
75gggnd
Bram Moolenaar9feaf622014-02-22 22:18:47 +010076:" test repeating dgn
77/^Johnny
78ggdgn.
79:" test repeating gUgn
80/^Depp
81gggUgn.
Bram Moolenaarb12db9f2014-12-13 22:00:22 +010082gg/a:0\@!\zs\d\+
83nygnop
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000084:/^start:/,/^end:/wq! test.out
85ENDTEST
86
87start: "wo\"rd\\" foo
88'foo' 'bar' 'piep'
89bla bla `quote` blah
90out " in "noXno"
91"'" 'blah' rep 'buh'
92bla `s*`d-`+++`l**` b`la
93voo "nah" sdf " asdf" sdf " sdf" sd
Bram Moolenaar06a89a52006-04-29 22:01:03 +000094
95<begin>
96-<b>asdf<i>Xasdf</i>asdf</b>-
97-<b>asdX<i>a<i />sdf</i>asdf</b>-
98-<b>asdf<i>Xasdf</i>asdf</b>-
99-<b>asdX<i>as<b />df</i>asdf</b>-
100</begin>
Bram Moolenaar641e2862012-07-25 15:06:34 +0200101SEARCH:
102foobar
103one
104two
105abcdx | abcdx | abcdx
Bram Moolenaardd7d8462012-08-29 16:55:13 +0200106join
107lines
108zero width pattern
109delete first and last chars
Bram Moolenaar57c0ea82012-09-05 12:16:45 +0200110uniquepattern uniquepattern
Bram Moolenaar0c178752012-10-11 03:35:45 +0200111my very excellent mother just served us nachos
Bram Moolenaare78495d2013-06-30 14:46:53 +0200112for (i=0; i<=10; i++)
Bram Moolenaarb12db9f2014-12-13 22:00:22 +0100113a:10
114
115a:1
116
117a:20
Bram Moolenaar4c7cb6b2013-10-02 21:55:02 +0200118Y
119text
120Y
Bram Moolenaar9feaf622014-02-22 22:18:47 +0100121--1
122Johnny
123--2
124Johnny
125--3
126Depp
127--4
128Depp
129--5
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000130end: