1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
|
Tests for using Ctrl-A/Ctrl-X on visual selections
Test cases
==========
1) Ctrl-A on visually selected number
Text:
foobar-10
Expected:
1) Ctrl-A on start of line:
foobar-9
2) Ctrl-A on visually selected "-10":
foobar-9
3) Ctrl-A on visually selected "10":
foobar-11
4) Ctrl-X on visually selected "-10"
foobar-11
5) Ctrl-X on visually selected "10"
foobar-9
2) Ctrl-A on visually selected lines
Text:
10
20
30
40
Expected:
1) Ctrl-A on visually selected lines:
11
21
31
41
2) Ctrl-X on visually selected lines:
9
19
29
39
3) g Ctrl-A on visually selected lines, with non-numbers in between
Text:
10
20
30
40
Expected:
1) 2 g Ctrl-A on visually selected lines:
12
24
36
48
2) 2 g Ctrl-X on visually selected lines
8
16
24
32
4) Ctrl-A on non-number
Text:
foobar-10
Expected:
1) visually select foobar:
foobar-10
5) g<Ctrl-A> on letter
Test:
a
a
a
a
Expected:
1) g Ctrl-A on visually selected lines
b
c
d
e
6) g<Ctrl-A> on letter
Test:
z
z
z
z
Expected:
1) g Ctrl-X on visually selected lines
y
x
w
v
7) <Ctrl-A> on letter
Test:
2
1
0
-1
-2
Expected:
1) Ctrl-A on visually selected lines
3
2
1
0
-1
2) Ctrl-X on visually selected lines
1
0
-1
-2
-3
8) Block increment on 0x9
Text:
0x9
0x9
Expected:
1) Ctrl-A on visually block selected region (cursor at beginning):
0xa
0xa
2) Ctrl-A on visually block selected region (cursor at end)
0xa
0xa
9) Increment and redo
Text:
2
2
3
3
Expected:
1) 2 Ctrl-A on first 2 visually selected lines
4
4
2) redo (.) on 3
5
5
10) sequentially decrement 1
Text:
1
1
1
1
Expected:
1) g Ctrl-X on visually selected lines
0
-1
-2
-3
11) visually block selected indented lines
Text:
1
1
1
1
Expexted:
1) g Ctrl-A on block selected indented lines
2
1
3
4
12) visually selected several columns
Text:
0 0
0 0
0 0
Expected:
1) 'v' select last zero and first zeroes
0 1
1 0
1 0
13) visually selected part of columns
Text:
max: 100px
max: 200px
max: 300px
max: 400px
Expected:
1) 'v' on first two numbers Ctrl-A
max: 110px
max: 220px
max: 330px
max: 400px
2) 'v' on first two numbers Ctrl-X
max: 90px
max: 190px
max: 290px
max: 400px
14) redo in block mode
Text:
1 1
1 1
Expected:
1) Ctrl-a on first column, redo on second column
2 2
2 2
15) block select single numbers
Text:
101
Expected:
1) Ctrl-a on visually selected zero
111
16) increment right aligned numbers
Text:
1
19
119
Expected:
1) Ctrl-a on line selected region
2
20
120
17) block-wise increment and redo
Text:
100
1
100
1
Expected:
1) Ctrl-V j $ on first block, afterwards '.' on second
101
2
101
2
18) repeat of g<Ctrl-a>
Text:
0
0
0
0
Expected:
1) V 4j g<ctrl-a>, repeat twice afterwards with .
3
6
9
12
19) increment on number with nrformat including alpha
Text:
1
1a
Expected:
1) <Ctrl-V>j$ <ctrl-a>
2
2a
20) increment a single letter
Text:
a
Expected:
1) <Ctrl-a> and cursor is on a
b
21) block-wise increment on part of hexadecimal
Text:
0x123456
Expected:
1) Ctrl-V f3 <ctrl-a>
0x124456
22) Block increment on 0b0
Text:
0b1
0b1
Expected:
1) Ctrl-A on visually block selected region (cursor at beginning):
0b10
0b10
2) Ctrl-A on visually block selected region (cursor at end)
0b10
0b10
23) block-wise increment on part of binary
Text:
0b1001
Expected:
1) Ctrl-V 5l <ctrl-a>
0b1011
24) increment hexadecimal
Text:
0x0b1001
Expected:
1) <ctrl-a>
0x0b1002
25) increment binary with nrformats including alpha
Text:
0b1001a
Expected:
1) <ctrl-a>
0b1010a
26) increment binary with 64 bits
Text:
0b1111111111111111111111111111111111111111111111111111111111111110
Expected:
1) <ctrl-a>
0b1111111111111111111111111111111111111111111111111111111111111111
STARTTEST
:so small.vim
:"
:" Avoid CTRL-X being mapped in Visual mode for MS-Windows
:vmapclear
:"
:" Test 1
:/^S1=/+,/^E1=/-y a
:/^E1=/+put a
:/^E1=/+2put a
f-v$:/^E1=/+3put a
f1v$:/^E1=/+4put a
f-v$:/^E1=/+5put a
f1v$
:" Test 2
:/^S2=/+,/^E2=/-y a
:/^E2=/+put a
V3k$3j:.+put a
V3k$
:" Test 3
:/^S3=/+,/^E3=/-y a
:/^E3=/+put a
V6k2g6j:.+put a
V6k2g
:" Test 4
:/^S4=/+,/^E4=/-y a
:/^E4=/+put a
vf-
:" Test 5
:set nrformats+=alpha
:/^S5=/+,/^E5=/-y a
:/^E5=/+put a
v3kg
:" Test 6
:/^S6=/+,/^E6=/-y a
:/^E6=/+put a
v3kg
:" Test 7
:set nrformats&vim
:/^S7=/+,/^E7=/-y a
:/^E7=/+put a
V4k4j:.+put a
V4k
:" Test 8
:/^S8=/+,/^E8=/-y a
:/^E8=/+put a
kj$j:.+put a
k$+
:" Test 9
:/^S9=/+,/^E9=/-y a
:/^E9=/+put a
5kVj23j.
:" Test 10
:/^S10=/+,/^E10=/-y a
:/^E10=/+put a
V3kg
: Test 11
:/^S11=/+,/^E11=/-y a
:/^E11=/+put a
3kf13jg
:" Test 12
:/^S12=/+,/^E12=/-y a
:/^E12=/+put a
2k$v++
:" Test 13
:/^S13=/+,/^E13=/-y a
:/^E13=/+put a
3kf1l2j3j:.+put a
3kf1l2j
:" Test 14
:/^S14=/+,/^E14=/-y a
:/^E14=/+put a
kw.
:" Test 15
:/^S15=/+,/^E15=/-y a
:/^E15=/+put a
lv
:" Test 16
:/^S16=/+,/^E16=/-y a
:/^E16=/+put a
V3k
:" Test 17
:/^S17=/+,/^E17=/-y a
:/^E17=/+put a
4kj$2j.
:" Test 18
:/^S18=/+,/^E18=/-y a
:/^E18=/+put a
V3kg..
:" Test 19
:set nrformats+=alpha
:/^S19=/+,/^E19=/-y a
:/^E19=/+put a
k$
:set nrformats&vim
:" Test 20
:set nrformats+=alpha
:/^S20=/+,/^E20=/-y a
:/^E20=/+put a
:.put =col('.')
:set nrformats&vim
:" Test 21
:/^S21=/+,/^E21=/-y a
:/^E21=/+put a
:set nrformats&vim
f3
:" Test 22
:/^S22=/+,/^E22=/-y a
:/^E22=/+put a
kj$j:.+put a
k$+
:" Test 23
:/^S23=/+,/^E23=/-y a
:/^E23=/+put a
:set nrformats&vim
4l
:" Test 24
:/^S24=/+,/^E24=/-y a
:/^E24=/+put a
:set nrformats&vim
$
:" Test 25
:set nrformats+=alpha
:/^S25=/+,/^E25=/-y a
:/^E25=/+put a
k$
:set nrformats&vim
:" Test 26
:set nrformats+=alpha
:/^S26=/+,/^E26=/-y a
:/^E26=/+put a
k$
:set nrformats&vim
:" Save the report
:/^# Test 1/,$w! test.out
:qa!
# Test 1
S1======
foobar-10
E1======
# Test 2
S2=====
10
20
30
40
E2=====
# Test 3
S3=====
10
20
30
40
E3=====
# Test 4
S4=====
foobar-10
E4=====
# Test 5
S5====
a
a
a
a
E5====
# Test 6
S6====
z
z
z
z
E6====
# Test 7
S7====
2
1
0
-1
-2
E7====
# Test 8
S8====
0x9
0x9
E8====
# Test 9
S9====
2
2
3
3
E9====
# Test 10
S10====
1
1
1
1
E10====
# Test 11
S11====
1
1
1
1
E11====
# Test 12
S12====
0 0
0 0
0 0
E12====
# Test 13
S13====
max: 100px
max: 200px
max: 300px
max: 400px
E13====
# Test 14
S14====
1 1
1 1
E14====
# Test 15
S15====
101
E15====
# Test 16
S16====
1
19
119
E16====
# Test 17
S17====
100
1
100
1
E17====
# Test 18
S18====
0
0
0
0
E18====
# Test 19
S19====
1
1a
E19====
# Test 20
S20====
a
E20====
# Test 21
S21====
0x123456
E21====
# Test 22
S22====
0b1
0b1
E22====
# Test 23
S23====
0b1001
E23====
# Test 24
S24====
0x0b1001
E24====
# Test 25
S25====
0b1001a
E25====
# Test 26
S26====
0b11111111111111111111111111111110
E26====
ENDTEST
|