blob: f5d8ff9c3e5372c10d294163153f701a51e0af57 [file] [log] [blame]
Bram Moolenaar3a304b22015-06-25 13:57:36 +02001Tests for using Ctrl-A/Ctrl-X on visual selections
2
3Test cases
4==========
5
61) Ctrl-A on visually selected number
7Text:
8foobar-10
Bram Moolenaar9bb19302015-07-03 12:44:07 +02009 Expected:
Bram Moolenaar3a304b22015-06-25 13:57:36 +020010 1) Ctrl-A on start of line:
11 foobar-9
12 2) Ctrl-A on visually selected "-10":
13 foobar-9
14 3) Ctrl-A on visually selected "10":
15 foobar-11
16 4) Ctrl-X on visually selected "-10"
17 foobar-11
18 5) Ctrl-X on visually selected "10"
19 foobar-9
20
212) Ctrl-A on visually selected lines
22Text:
2310
2420
2530
2640
27
Bram Moolenaar9bb19302015-07-03 12:44:07 +020028 Expected:
Bram Moolenaar3a304b22015-06-25 13:57:36 +020029 1) Ctrl-A on visually selected lines:
3011
3121
3231
3341
34
35 2) Ctrl-X on visually selected lines:
369
3719
3829
3939
40
413) g Ctrl-A on visually selected lines, with non-numbers in between
42Text:
4310
44
4520
46
4730
48
4940
50
Bram Moolenaar9bb19302015-07-03 12:44:07 +020051 Expected:
Bram Moolenaar3a304b22015-06-25 13:57:36 +020052 1) 2 g Ctrl-A on visually selected lines:
5312
54
5524
56
5736
58
5948
60 2) 2 g Ctrl-X on visually selected lines
618
62
6316
64
6524
66
6732
68
694) Ctrl-A on non-number
70Text:
71foobar-10
Bram Moolenaar9bb19302015-07-03 12:44:07 +020072 Expected:
Bram Moolenaar3a304b22015-06-25 13:57:36 +020073 1) visually select foobar:
74 foobar-10
75
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200765) g<Ctrl-A> on letter
77Test:
78a
79a
80a
81a
82 Expected:
83 1) g Ctrl-A on visually selected lines
84 b
85 c
86 d
87 e
88
896) g<Ctrl-A> on letter
90Test:
91z
92z
93z
94z
95 Expected:
96 1) g Ctrl-X on visually selected lines
97 y
98 x
99 w
100 v
101
1027) <Ctrl-A> on letter
103Test:
1042
1051
1060
107-1
108-2
109
110 Expected:
111 1) Ctrl-A on visually selected lines
112 3
113 2
114 1
115 0
116 -1
117
118 2) Ctrl-X on visually selected lines
119 1
120 0
121 -1
122 -2
123 -3
1248) Block increment on 0x9
125Text:
1260x9
1270x9
128 Expected:
129 1) Ctrl-A on visually block selected region (cursor at beginning):
130 0xa
131 0xa
132 2) Ctrl-A on visually block selected region (cursor at end)
133 0xa
134 0xa
135
1369) Increment and redo
137Text:
1382
1392
140
1413
1423
143
144 Expected:
145 1) 2 Ctrl-A on first 2 visually selected lines
146 4
147 4
148 2) redo (.) on 3
149 5
150 5
15110) sequentially decrement 1
152Text:
1531
1541
1551
1561
157 Expected:
158 1) g Ctrl-X on visually selected lines
159 0
160 -1
161 -2
162 -3
163
16411) visually block selected indented lines
165Text:
166 1
1671
168 1
169 1
170 Expexted:
171 1) g Ctrl-A on block selected indented lines
172 2
1731
174 3
175 4
176
17712) visually selected several columns
178Text:
1790 0
1800 0
1810 0
182 Expected:
183 1) 'v' select last zero and first zeroes
184 0 1
185 1 0
186 1 0
187
Bram Moolenaar5d1bc782015-07-17 13:03:48 +020018813) visually selected part of columns
189Text:
190max: 100px
191max: 200px
192max: 300px
193max: 400px
194 Expected:
195 1) 'v' on first two numbers Ctrl-A
196 max: 110px
197 max: 220px
198 max: 330px
199 max: 400px
200 2) 'v' on first two numbers Ctrl-X
201 max: 90px
202 max: 190px
203 max: 290px
204 max: 400px
205
20614) redo in block mode
207Text:
2081 1
2091 1
210 Expected:
211 1) Ctrl-a on first column, redo on second column
212 2 2
213 2 2
214
21515) block select single numbers
216Text:
217101
218 Expected:
219 1) Ctrl-a on visually selected zero
220 111
221
22216) increment right aligned numbers
223Text:
224 1
225 19
226 119
227 Expected:
228 1) Ctrl-a on line selected region
229 2
230 20
231 120
232
23317) block-wise increment and redo
234Text:
235 100
236 1
237
238 100
239 1
240
241 Expected:
242 1) Ctrl-V j $ on first block, afterwards '.' on second
243 101
244 2
245
246 101
247 2
248
24918) repeat of g<Ctrl-a>
250Text:
251 0
252 0
253 0
254 0
255
256 Expected:
257 1) V 4j g<ctrl-a>, repeat twice afterwards with .
258 3
259 6
260 9
261 12
262
Bram Moolenaarcc218ab2015-08-04 18:23:22 +020026319) increment on number with nrformat including alpha
264Text:
265 1
266 1a
267
268 Expected:
269 1) <Ctrl-V>j$ <ctrl-a>
270 2
Bram Moolenaar25c2f672015-08-11 19:36:42 +0200271 2a
272
27320) increment a single letter
274Text:
275 a
276
277 Expected:
278 1) <Ctrl-a> and cursor is on a
279 b
Bram Moolenaar5adfea12015-09-01 18:51:39 +0200280
28121) block-wise increment on part of hexadecimal
282Text:
2830x123456
284
285 Expected:
286 1) Ctrl-V f3 <ctrl-a>
2870x124456
288
Bram Moolenaar887c1fe2016-01-02 17:56:35 +010028922) Block increment on 0b0
290Text:
2910b1
2920b1
293 Expected:
294 1) Ctrl-A on visually block selected region (cursor at beginning):
295 0b10
296 0b10
297 2) Ctrl-A on visually block selected region (cursor at end)
298 0b10
299 0b10
300
30123) block-wise increment on part of binary
302Text:
3030b1001
304
305 Expected:
306 1) Ctrl-V 5l <ctrl-a>
3070b1011
308
30924) increment hexadecimal
310Text:
3110x0b1001
312
313 Expected:
314 1) <ctrl-a>
3150x0b1002
316
31725) increment binary with nrformats including alpha
318Text:
3190b1001a
320
321 Expected:
322 1) <ctrl-a>
3230b1010a
324
32526) increment binary with 64 bits
326Text:
3270b1111111111111111111111111111111111111111111111111111111111111110
328
329 Expected:
330 1) <ctrl-a>
3310b1111111111111111111111111111111111111111111111111111111111111111
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200332
333
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200334STARTTEST
335:so small.vim
Bram Moolenaar6a57cce2015-06-28 19:24:39 +0200336:"
337:" Avoid CTRL-X being mapped in Visual mode for MS-Windows
338:vmapclear
339:"
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200340:" Test 1
341:/^S1=/+,/^E1=/-y a
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200342:/^E1=/+put a
343:/^E1=/+2put a
344f-v$:/^E1=/+3put a
345f1v$:/^E1=/+4put a
346f-v$:/^E1=/+5put a
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200347f1v$
348
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200349:" Test 2
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200350:/^S2=/+,/^E2=/-y a
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200351:/^E2=/+put a
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200352V3k$3j:.+put a
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200353V3k$
354
355:" Test 3
356:/^S3=/+,/^E3=/-y a
357:/^E3=/+put a
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200358V6k2g6j:.+put a
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200359V6k2g
360
361:" Test 4
362:/^S4=/+,/^E4=/-y a
363:/^E4=/+put a
364vf-
365
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200366:" Test 5
367:set nrformats+=alpha
368:/^S5=/+,/^E5=/-y a
369:/^E5=/+put a
370v3kg
371
372:" Test 6
373:/^S6=/+,/^E6=/-y a
374:/^E6=/+put a
375v3kg
376
377:" Test 7
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200378:set nrformats&vim
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200379:/^S7=/+,/^E7=/-y a
380:/^E7=/+put a
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200381V4k4j:.+put a
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200382V4k
383
384:" Test 8
385:/^S8=/+,/^E8=/-y a
386:/^E8=/+put a
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200387kj$j:.+put a
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200388k$+
389
390:" Test 9
391:/^S9=/+,/^E9=/-y a
392:/^E9=/+put a
Bram Moolenaar5d1bc782015-07-17 13:03:48 +02003935kVj23j.
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200394
395:" Test 10
396:/^S10=/+,/^E10=/-y a
397:/^E10=/+put a
398V3kg
399
400: Test 11
401:/^S11=/+,/^E11=/-y a
402:/^E11=/+put a
4033kf13jg
404
405:" Test 12
406:/^S12=/+,/^E12=/-y a
407:/^E12=/+put a
4082k$v++
409
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200410:" Test 13
411:/^S13=/+,/^E13=/-y a
412:/^E13=/+put a
4133kf1l2j3j:.+put a
4143kf1l2j
415
416:" Test 14
417:/^S14=/+,/^E14=/-y a
418:/^E14=/+put a
419kw.
420
421:" Test 15
422:/^S15=/+,/^E15=/-y a
423:/^E15=/+put a
424lv
425
426:" Test 16
427:/^S16=/+,/^E16=/-y a
428:/^E16=/+put a
429V3k
430
431:" Test 17
432:/^S17=/+,/^E17=/-y a
433:/^E17=/+put a
4344kj$2j.
435
436:" Test 18
437:/^S18=/+,/^E18=/-y a
438:/^E18=/+put a
439V3kg..
440
Bram Moolenaarcc218ab2015-08-04 18:23:22 +0200441:" Test 19
442:set nrformats+=alpha
443:/^S19=/+,/^E19=/-y a
444:/^E19=/+put a
445k$
446:set nrformats&vim
447
Bram Moolenaar25c2f672015-08-11 19:36:42 +0200448:" Test 20
449:set nrformats+=alpha
450:/^S20=/+,/^E20=/-y a
451:/^E20=/+put a
452:.put =col('.')
453:set nrformats&vim
454
Bram Moolenaar5adfea12015-09-01 18:51:39 +0200455:" Test 21
456:/^S21=/+,/^E21=/-y a
457:/^E21=/+put a
458:set nrformats&vim
459f3
460
Bram Moolenaar887c1fe2016-01-02 17:56:35 +0100461:" Test 22
462:/^S22=/+,/^E22=/-y a
463:/^E22=/+put a
464kj$j:.+put a
465k$+
466
467:" Test 23
468:/^S23=/+,/^E23=/-y a
469:/^E23=/+put a
470:set nrformats&vim
4714l
472
473:" Test 24
474:/^S24=/+,/^E24=/-y a
475:/^E24=/+put a
476:set nrformats&vim
477$
478
479:" Test 25
480:set nrformats+=alpha
481:/^S25=/+,/^E25=/-y a
482:/^E25=/+put a
483k$
484:set nrformats&vim
485
486:" Test 26
487:set nrformats+=alpha
488:/^S26=/+,/^E26=/-y a
489:/^E26=/+put a
490k$
491:set nrformats&vim
492
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200493:" Save the report
494:/^# Test 1/,$w! test.out
495:qa!
496
497
498# Test 1
499S1======
500foobar-10
501E1======
502
503
504
505# Test 2
506S2=====
50710
50820
50930
51040
511E2=====
512
513
514
515# Test 3
516S3=====
51710
518
51920
520
52130
522
52340
524E3=====
525
526
527
528# Test 4
529S4=====
530foobar-10
531E4=====
532
533
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200534
535# Test 5
536S5====
537a
538a
539a
540a
541E5====
542
543
544# Test 6
545S6====
546z
547z
548z
549z
550E6====
551
552
553
554# Test 7
555S7====
5562
5571
5580
559-1
560-2
561E7====
562
563
564
565# Test 8
566S8====
5670x9
5680x9
569E8====
570
571
572
573
574# Test 9
575S9====
5762
5772
578
5793
5803
581
582E9====
583
584
585
586
587# Test 10
588S10====
5891
5901
5911
5921
593E10====
594
595
596
597
598# Test 11
599S11====
600 1
6011
602 1
603 1
604E11====
605
606
607
608# Test 12
609S12====
6100 0
6110 0
6120 0
613E12====
614
615
616
Bram Moolenaar5d1bc782015-07-17 13:03:48 +0200617# Test 13
618S13====
619max: 100px
620max: 200px
621max: 300px
622max: 400px
623E13====
624
625
626
627# Test 14
628S14====
6291 1
6301 1
631E14====
632
633
634
635# Test 15
636S15====
637101
638E15====
639
640
641
642# Test 16
643S16====
644 1
645 19
646 119
647E16====
648
649
650
651# Test 17
652S17====
653 100
654 1
655
656 100
657 1
658E17====
659
660
661# Test 18
662S18====
6630
6640
6650
6660
667E18====
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200668
669
670
Bram Moolenaarcc218ab2015-08-04 18:23:22 +0200671# Test 19
672S19====
6731
6741a
675E19====
676
677
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200678
Bram Moolenaar25c2f672015-08-11 19:36:42 +0200679# Test 20
680S20====
681a
682E20====
683
684
685
Bram Moolenaar5adfea12015-09-01 18:51:39 +0200686# Test 21
687S21====
6880x123456
689E21====
690
691
692
Bram Moolenaar887c1fe2016-01-02 17:56:35 +0100693# Test 22
694S22====
6950b1
6960b1
697E22====
698
699
700
701
702# Test 23
703S23====
7040b1001
705E23====
706
707
708
709
710# Test 24
711S24====
7120x0b1001
713E24====
714
715
716
717
718# Test 25
719S25====
7200b1001a
721E25====
722
723
724
725
726# Test 26
727S26====
Bram Moolenaard3343962016-01-02 18:17:16 +01007280b11111111111111111111111111111110
Bram Moolenaar887c1fe2016-01-02 17:56:35 +0100729E26====
730
731
Bram Moolenaar9bb19302015-07-03 12:44:07 +0200732
Bram Moolenaar3a304b22015-06-25 13:57:36 +0200733ENDTEST
734