Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

   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
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
.\"	$NetBSD: vi.cmd.roff,v 1.1 2013/11/22 16:00:45 christos Exp $
.\"
.\" Copyright (c) 1994
.\"	The Regents of the University of California.  All rights reserved.
.\" Copyright (c) 1994, 1995, 1996
.\"	Keith Bostic.  All rights reserved.
.\"
.\" See the LICENSE file for redistribution information.
.\"
.\"	@(#)vi.cmd.roff	8.49 (Berkeley) 8/17/96
.\"
.SH 1 "Vi Description"
.pp
.CO Vi
takes up the entire screen to display the edited file,
except for the bottom line of the screen.
The bottom line of the screen is used to enter
.CO ex
commands, and for
.CO vi
error and informational messages.
If no other information is being displayed,
the default display can show the current cursor row and cursor column,
an indication of whether the file has been modified,
and the current mode of the editor.
See the
.OP ruler
and
.OP showmode
options for more information.
.pp
Empty lines do not have any special representation on the screen,
but lines on the screen that would logically come after the end of
the file are displayed as a single tilde
.PQ ~
character.
To differentiate between empty lines and lines consisting of only
whitespace characters, use the
.OP list
option.
Historically, implementations of
.CO vi
have also displayed some lines as single asterisk
.PQ @
characters.
These were lines that were not correctly displayed, i.e. lines on the
screen that did not correspond to lines in the file, or lines that did
not fit on the current screen.
.CO Nvi
never displays lines in this fashion.
.pp
.CO Vi
is a modeful editor, i.e. it has two modes,
.QQ command
mode and
.QQ "text input"
mode.
When
.CO vi
first starts, it is in command mode.
There are several commands that change
.CO vi
into text input mode.
The
.LI <escape>
character is used to resolve the text input into the file,
and exit back into command mode.
In
.CO vi
command mode, the cursor is always positioned on the last column of
characters which take up more than one column on the screen.
In
.CO vi
text insert mode, the cursor is positioned on the first column of
characters which take up more than one column on the screen.
.pp
When positioning the cursor to a new line and column,
the type of movement is defined by the distance to the new cursor position.
If the new position is close,
the screen is scrolled to the new location.
If the new position is far away,
the screen is repainted so that the new position is on the screen.
If the screen is scrolled,
it is moved a minimal amount,
and the cursor line will usually appear at the top or bottom of the screen.
If the screen is repainted,
the cursor line will appear in the center of the screen,
unless the cursor is sufficiently close to the beginning or end of the file
that this isn't possible.
If the
.OP leftright
option is set, the screen may be scrolled or repainted in a horizontal
direction as well as in a vertical one.
.pp
A major difference between the historical
.CO vi
presentation and
.CO nvi
is in the scrolling and screen oriented position commands,
.CO <control-B> ,
.CO <control-D> ,
.CO <control-E> ,
.CO <control-F> ,
.CO <control-U> ,
.CO <control-Y> ,
.CO H ,
.CO L
and
.CO M .
In historical implementations of
.CO vi ,
these commands acted on physical (as opposed to logical, or screen)
lines.
For lines that were sufficiently long in relation to the size of the
screen, this meant that single line scroll commands might repaint the
entire screen, scrolling or screen positioning commands might not change
the screen or move the cursor at all, and some lines simply could not
be displayed, even though
.CO vi
would edit the file that contained them.
In
.CO nvi ,
these commands act on logical, i.e. screen lines.
You are unlikely to notice any difference unless you are editing files
with lines significantly longer than a screen width.
.pp
.CO Vi
keeps track of the currently
.QQ "most attractive"
cursor position.
Each command description (for commands that alter the current cursor
position),
specifies if the cursor is set to a specific location in the line,
or if it is moved to the
.QQ "most attractive cursor position" .
The latter means that the cursor is moved to the cursor position that
is horizontally as close as possible to the current cursor position.
If the current line is shorter than the cursor position
.CO vi
would select, the cursor is positioned on the last character in the line.
(If the line is empty, the cursor is positioned on the first column
of the line.)
If a command moves the cursor to the most attractive position,
it does not alter the current cursor position, and a subsequent
movement will again attempt to move the cursor to that position.
Therefore, although a movement to a line shorter than the currently
most attractive position will cause the cursor to move to the end of
that line, a subsequent movement to a longer line will cause the
cursor to move back to the most attractive position.
.pp
In addition, the
.CO $
command makes the end of each line the most attractive cursor position
rather than a specific column.
.pp
Each
.CO vi
command described below notes where the cursor ends up after it is
executed.
This position is described in terms of characters on the line, i.e.
.QQ "the previous character" ,
or,
.QQ "the last character in the line" .
This is to avoid needing to continually refer to on what part of the
character the cursor rests.
.pp
The following words have special meaning for
.CO vi
commands.
.KY "previous context"
.IP "previous context"
The position of the cursor before the command which caused the
last absolute movement was executed.
Each 
.CO vi
command described in the next section that is considered an
absolute movement is so noted.
In addition, specifying
.i any
address to an
.CO ex
command is considered an absolute movement.
.KY "motion"
.IP "motion"
A second
.CO vi
command can be used as an optional trailing argument to the
.CO vi
.CO \&< ,
.CO \&> ,
.CO \&! ,
.CO \&c ,
.CO \&d ,
.CO \&y ,
and (depending on the
.OP tildeop
option)
.CO \&~
commands.
This command indicates the end of the region of text that's affected by
the command.
The motion command may be either the command character repeated (in
which case it means the current line) or a cursor movement command.
In the latter case, the region affected by the command is from the
starting or stopping cursor position which comes first in the file,
to immediately before the starting or stopping cursor position which
comes later in the file.
Commands that operate on lines instead of using beginning and ending
cursor positions operate on all of the lines that are wholly or
partially in the region.
In addition, some other commands become line oriented depending on
where in the text they are used.
The command descriptions below note these special cases.
.sp
The following commands may all be used as motion components for
.CO vi
commands:
.sp
.ne 12v
.ft C
.TS
r r r r.
<control-A>	<control-H>	<control-J>	<control-M>
<control-N>	<control-P>	<space>	$
%	'<character>	(	)
+	,	-	/
0	;	?	B
E	F	G	H
L	M	N	T
W	[[	]]	^
\&_	`<character>	b	e
f	h	j	k
l	n	t	w
{	|	}
.TE
.ft R
.sp
The optional count prefix available for some of the
.CO vi
commands that take motion commands,
or the count prefix available for the
.CO vi
commands that are used as motion components,
may be included and is
.i always
considered part of the motion argument.
For example, the commands
.QT c2w
and
.QT 2cw
are equivalent, and the region affected by the
.CO c
command is two words of text.
In addition,
if the optional count prefix is specified for both the
.CO vi
command and its motion component,
the effect is multiplicative and is considered part of the motion argument.
For example, the commands
.QT 4cw
and
.QT 2c2w
are equivalent, and the region affected by the
.CO c
command is four words of text.
.KY "count"
.IP "count"
A positive number used as an optional argument to most commands,
either to give a size or a position (for display or movement commands),
or as a repeat count (for commands that modify text).
The count argument is always optional and defaults to 1 unless otherwise
noted in the command description.
.sp
When a
.CO vi
command synopsis shows both a
.LI [buffer]
and
.LI [count] ,
they may be presented in any order.
.KY word
.IP word
Generally, in languages where it is applicable,
.CO vi
recognizes two kinds of words.
First, a sequence of letters, digits and underscores,
delimited at both ends by:
characters other than letters, digits, or underscores,
the beginning or end of a line, and the beginning or end of the file.
Second, a sequence of characters other than letters, digits, underscores,
or whitespace characters, delimited at both ends by: a letter, digit,
underscore, or whitespace character,
the beginning or end of a line, and the beginning or end of the file.
For example, the characters
.QT " !@#abc$%^ "
contain three words:
.QT "!@#" ,
.QT "abc"
and
.QT "$%^" .
.sp
Groups of empty lines (or lines containing only whitespace characters)
are treated as a single word.
.KY "bigword"
.IP "bigword"
A set of non-whitespace characters preceded and followed by whitespace
characters or the beginning or end of the file or line.
For example, the characters
.QT " !@#abc$%^ "
contain one bigword:
.QT "!@#abc$%^" .
.sp
Groups of empty lines (or lines containing only whitespace characters)
are treated as a single bigword.
.KY "paragraph"
.IP "paragraph"
An area of text that begins with either the beginning of a file,
an empty line, or a section boundary, and continues until either
an empty line, section boundary, or the end of the file.
.sp
Groups of empty lines (or lines containing only whitespace characters)
are treated as a single paragraph.
.sp
Additional paragraph boundaries can be defined using the
.OP paragraphs
option.
.KY "section"
.IP "section"
An area of text that starts with the beginning of the file or a line
whose first character is an open brace
.PQ {
and continues until the next section or the end of the file.
.sp
Additional section boundaries can be defined using the
.OP sections
option.
.KY "sentence"
.IP "sentence"
An area of text that begins with either the beginning of the file or the
first nonblank character following the previous sentence, paragraph, or
section boundary and continues until the end of the file or a period
.PQ \&.
exclamation point
.PQ !
or question mark
.PQ ?
character,
followed by either an end-of-line or two whitespace characters.
Any number of closing parentheses
.PQ ) ,
brackets
.PQ ] ,
double-quote
.PQ """"
or single quote
.PQ '
characters can appear between the period, exclamation point,
or question mark and the whitespace characters or end-of-line.
.sp
Groups of empty lines (or lines containing only whitespace characters)
are treated as a single sentence.
.SH 1 "Vi Commands"
.pp
The following section describes the commands available in the command
mode of the
.CO vi
editor.
In each entry below, the tag line is a usage synopsis for the command
character.
In addition, the final line and column the cursor rests upon,
and any options which affect the command are noted.
.KY <control-A>
.IP "[count] <control-A>"
Search forward
.LI count
times for the current word.
The current word begins at the first non-whitespace character on or
after the current cursor position,
and extends up to the next non-word character or the end of the line.
The search is literal, i.e. no characters in the word have any special
meaning in terms of Regular Expressions.
It is an error if no matching pattern is found between the starting position
and the end of the file.
.sp
The
.CO <control-A>
command is an absolute movement.
The
.CO <control-A>
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Set to the line where the word is found.
.SP Column:
Set to the first character of the word.
.SP Options:
Affected by the
.OP ignorecase
and
.OP wrapscan
options.
.SE
.KY <control-B>
.IP "[count] <control-B>"
Page backward
.LI count
screens.
Two lines of overlap are maintained, if possible,
by displaying the window starting at line
.LI "(top_line - count * window_size) + 2" ,
where
.LI window_size
is the value of the
.OP window
option.
(In the case of split screens, this size is corrected to the
current screen size.)
It is an error if the movement is past the beginning of the file.
.SS
.SP Line:
Set to the last line of text displayed on the screen.
.SP Column:
Set to the first nonblank character of the line.
.SP Options:
Affected by the
.OP window
option.
.SE
.KY <control-D>
.IP "[count] <control-D>"
Scroll forward
.LI count
lines.
If
.LI count
is not specified, scroll forward the number of lines specified by the last
.CO <control-D>
or
.CO <control-U>
command.
If this is the first
.CO <control-D>
or
.CO <control-U>
command,
scroll forward half the number of lines in the screen.
(In the case of split screens, the default scrolling distance is
corrected to half the current screen size.)
It is an error if the movement is past the end of the file.
.SS
.SP Line:
Set to the current line plus the number of lines scrolled.
.SP Column:
Set to the first nonblank character of the line.
.SP Options:
None.
.SE
.KY <control-E>
.IP "[count] <control-E>"
Scroll forward
.LI count
lines, leaving the cursor on the current line and column, if possible.
It is an error if the movement is past the end of the file.
.SS
.SP Line:
Unchanged unless the current line scrolls off the screen,
in which case it is set to the first line on the screen.
.SP Column:
Unchanged unless the current line scrolls off the screen,
in which case it is set to the most attractive cursor position.
.SP Options:
None.
.SE
.KY <control-F>
.IP "[count] <control-F>"
Page forward
.LI count
screens.
Two lines of overlap are maintained, if possible,
by displaying the window starting at line
.LI "top_line + count * window_size - 2" ,
where
.LI window_size
is the value of the
.OP window
option.
(In the case of split screens, this size is corrected to the
current screen size.)
It is an error if the movement is past the end of the file.
.SS
.SP Line:
Set to the first line on the screen.
.SP Column:
Set to the first nonblank character of the current line.
.SP Options:
Affected by the
.OP window
option.
.SE
.KY <control-G>
.IP "<control-G>"
Display the file information.
The information includes the current pathname, the current line,
the number of total lines in the file, the current line as a percentage
of the total lines in the file, if the file has been modified,
was able to be locked, if the file's name has been changed,
and if the edit session is read-only.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged.
.SP Options:
None.
.SE
.KY <control-H>
.IP "[count] <control-H>"
.Ip "[count] h"
Move the cursor back
.LI count
characters in the current line.
It is an error if the cursor is on the first character in the line.
.sp
The
.CO <control-H>
and
.CO h
commands may be used as the motion component of other
.CO vi
commands,
in which case any text copied into a buffer is character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the
.LI "current - count"
character, or, the first character in the line if
.LI count
is greater than or equal to the number of characters in the line
before the cursor.
.SP Options:
None.
.SE
.KY <control-J>
.IP "[count] <control-J>"
.KY <control-N>
.Ip "[count] <control-N>"
.KY j
.Ip "[count] j"
Move the cursor down
.LI count
lines without changing the current column.
It is an error if the movement is past the end of the file.
.sp
The
.CO <control-J> ,
.CO <control-N>
and
.CO j
commands may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.SS
.SP Line:
Set to the current line plus
.LI count .
.SP Column:
The most attractive cursor position.
.SP Options:
None.
.SE
.KY <control-L>
.IP "<control-L>"
.KY <control-R>
.Ip "<control-R>"
Repaint the screen.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged.
.SP Options:
None.
.SE
.KY <control-M>
.IP "[count] <control-M>"
.KY +
.Ip "[count] +"
Move the cursor down
.LI count
lines to the first nonblank character of that line.
It is an error if the movement is past the end of the file.
.sp
The
.CO <control-M>
and
.CO +
commands may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.SS
.SP Line:
Set to the current line plus
.LI count .
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
None.
.SE
.KY <control-P>
.IP "[count] <control-P>"
.KY k
.Ip "[count] k"
Move the cursor up
.LI count
lines, without changing the current column.
It is an error if the movement is past the beginning of the file.
.sp
The
.CO <control-P>
and
.CO k
commands may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.SS
.SP Line:
Set to the current line minus
.LI count .
.SP Column:
The most attractive cursor position.
.SP Options:
None.
.SE
.KY <control-T>
.IP "<control-T>"
Return to the most recent tag context.
The
.CO <control-T>
command is an absolute movement.
.SS
.SP Line:
Set to the context of the previous tag command.
.SP Column:
Set to the context of the previous tag command.
.SP Options:
None.
.SE
.KY <control-U>
.IP "[count] <control-U>"
Scroll backward
.LI count
lines.
If
.LI count
is not specified, scroll backward the number of lines specified by the
last
.CO <control-D>
or
.CO <control-U>
command.
If this is the first
.CO <control-D>
or
.CO <control-U>
command,
scroll backward half the number of lines in the screen.
(In the case of split screens, the default scrolling distance is
corrected to half the current screen size.)
It is an error if the movement is past the beginning of the file.
.SS
.SP Line:
Set to the current line minus the amount scrolled.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
None.
.SE
.KY <control-W>
.IP "<control-W>"
Switch to the next lower screen in the window, or, to the first
screen if there are no lower screens in the window.
.SS
.SP Line:
Set to the previous cursor position in the window.
.SP Column:
Set to the previous cursor position in the window.
.SP Options:
None.
.SE
.KY <control-Y>
.IP "[count] <control-Y>"
Scroll backward
.LI count
lines, leaving the current line and column as is, if possible.
It is an error if the movement is past the beginning of the file.
.SS
.SP Line:
Unchanged unless the current line scrolls off the screen,
in which case it is set to the last line of text displayed
on the screen.
.SP Column:
Unchanged unless the current line scrolls off the screen,
in which case it is the most attractive cursor position.
.SP Options:
None.
.SE
.KY <control-Z>
.IP "<control-Z>"
Suspend the current editor session.
If the file has been modified since it was last completely written,
and the
.OP autowrite
option is set, the file is written before the editor session is
suspended.
If this write fails, the editor session is not suspended.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged.
.SP Options:
Affected by the
.OP autowrite
option.
.SE
.KY <escape>
.IP "<escape>"
Execute
.CO ex
commands or cancel partial commands.
If an
.CO ex
command is being entered (e.g.
.CO / ,
.CO ? ,
.CO :
or
.CO ! ),
the command is executed.
If a partial command has been entered, e.g.
.QT "[0-9]*" ,
or
.QT "[0-9]*[!<>cdy]" ,
the command is cancelled.
Otherwise, it is an error.
.SS
.SP Line:
When an
.CO ex
command is being executed, the current line is set as described for
that command.
Otherwise, unchanged.
.SP Column:
When an
.CO ex
command is being executed, the current column is set as described for
that command.
Otherwise, unchanged.
.SP Options:
None.
.SE
.KY <control-]>
.IP "<control-]>"
Push a tag reference onto the tag stack.
The tags files (see the
.OP tags
option for more information) are searched for a tag matching the
current word.
The current word begins at the first non-whitespace character on or
after the current cursor position,
and extends up to the next non-word character or the end of the line.
If a matching tag is found, the current file is discarded and the
file containing the tag reference is edited.
.sp
If the current file has been modified since it was last completely
written, the command will fail.
The
.CO <control-]>
command is an absolute movement.
.SS
.SP Line:
Set to the line containing the matching tag string.
.SP Column:
Set to the start of the matching tag string.
.SP Options:
Affected by the
.OP tags
and
.OP taglength
options.
.SE
.KY <control-^>
.IP "<control-^>"
Switch to the most recently edited file.
.sp
If the file has been modified since it was last completely written,
and the
.OP autowrite
option is set, the file is written out.
If this write fails, the command will fail.
Otherwise, if the current file has been modified since it was last
completely written, the command will fail.
.SS
.SP Line:
Set to the line the cursor was on when the file was last edited.
.SP Column:
Set to the column the cursor was on when the file was last edited.
.SP Options:
Affected by the
.OP autowrite
option.
.SE
.KY <space>
.IP "[count] <space>"
.KY l
.Ip "[count] l"
Move the cursor forward
.LI count
characters without changing the current line.
It is an error if the cursor is on the last character in the line.
.sp
The
.CO <space>
and
.CO \&l
commands may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
In addition, these commands may be used as the motion components
of other commands when the cursor is on the last character in the
line, without error.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the current character plus the next
.LI count
characters, or to the last character on the line if
.LI count
is greater than the number of characters in the line after the
current character.
.SP Options:
None.
.SE
.KY !
.IP "[count] ! motion shell-argument(s)<carriage-return>"
Replace text with results from a shell command.
Pass the lines specified by the
.LI count
and
.LI motion
arguments as standard input to the program named by the
.OP shell
option, and replace those lines with the output (both
standard error and standard output) of that command.
.sp
After the motion is entered,
.CO vi
prompts for arguments to the shell command.
.sp
Within those arguments,
.QT %
and
.QT #
characters are expanded to the current and alternate pathnames,
respectively.
The
.QT !
character is expanded with the command text of the previous
.CO !
or
.CO :!
commands.
(Therefore, the command
.CO !<motion>!
repeats the previous
.CO !
command.)
The special meanings of
.QT % ,
.QT #
and
.QT !
can be overridden by escaping them with a backslash.
If no
.CO !
or
.CO :!
command has yet been executed,
it is an error to use an unescaped
.QT !
character as a shell argument.
The
.CO !
command does
.i not
do shell expansion on the strings provided as arguments.
If any of the above expansions change the arguments the user entered,
the command is redisplayed at the bottom of the screen.
.sp
.CO Vi
then executes the program named by the
.OP shell
option, with a
.b \-c
flag followed by the arguments (which are bundled into a single argument).
.sp
The
.CO !
command is permitted in an empty file.
.sp
If the file has been modified since it was last completely written,
the
.CO !
command will warn you.
.SS
.SP Line:
The first line of the replaced text.
.SP Column:
The first column of the replaced text.
.SP Options:
Affected by the
.OP shell
option.
.SE
.KY #
.IP "[count] # #|+|-"
Increment or decrement the number referenced by the cursor.
If the trailing character is a
.LI \&+
or
.LI \&# ,
the number is incremented by
.LI count .
If the trailing character is a
.LI \&- ,
the number is decremented by
.LI count .
.sp
A leading
.QT \&0X
or
.QT \&0x
causes the number to be interpreted as a hexadecimal number.
Otherwise, a leading
.QT \&0
causes the number to be interpreted as an octal number, unless a non-octal
digit is found as part of the number.
Otherwise, the number is interpreted as a decimal number, and may
have a leading
.LI \&+
or
.LI \&-
sign.
The current number begins at the first non-blank character at or after
the current cursor position, and extends up to the end of the line or
the first character that isn't a possible character for the numeric type.
The format of the number (e.g. leading 0's, signs) is retained unless
the new value cannot be represented in the previous format.
.sp
Octal and hexadecimal numbers, and the result of the operation, must fit
into an
.QT "unsigned long" .
Similarly, decimal numbers and their result must fit into a
.QT "signed long" .
It is an error to use this command when the cursor is not positioned at
a number.
.sp
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the first character in the cursor number.
.SP Options:
None.
.SE
.KY $
.IP "[count] $"
Move the cursor to the end of a line.
If
.LI count
is specified, the cursor moves down
.LI "count - 1"
lines.
.sp
It is not an error to use the
.CO $
command when the cursor is on the last character in the line or
when the line is empty.
.sp
The
.CO $
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the cursor is at, or before the first
nonblank character in the line, in which case it is line oriented.
It is not an error to use the
.CO $
command as a motion component when the cursor is on the last character
in the line, although it is an error when the line is empty.
.SS
.SP Line:
Set to the current line plus
.LI count
minus 1.
.SP Column:
Set to the last character in the line.
.SP Options:
None.
.SE
.KY %
.IP %
Move to the matching character.
The cursor moves to the bracket character that
.i matches
the bracket found at the current cursor position
or which is the closest one to the right of the cursor on the line.
The bracket characters are defined by the
.OP matchchars
option.
An error will be reported if none of the
.OP matchchars
characters is found, or if no matching character is found.
If the open and close brackes are identical (e.g.: if they are
.QT '
or
.QT " ),
then repeating a
.CO %
command will perform a backwards search from the original opening bracket.
Historically, any
.LI count
specified to the
.CO %
command was ignored.
.sp
The
.CO %
command is an absolute movement.
The
.CO %
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the starting point of the region is at
or before the first nonblank character on its line, and the ending
point is at or after the last nonblank character on its line, in
which case it is line oriented.
.SS
.SP Line:
Set to the line containing the matching character.
.SP Column:
Set to the matching character.
.SP Options:
None.
.SE
.KY &
.IP "&"
Repeat the previous substitution command on the current line.
.sp
Historically, any
.LI count
specified to the
.CO &
command was ignored.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged if the cursor was on the last character in the line,
otherwise, set to the first nonblank character in the line.
.SP Options:
Affected by the
.OP edcompatible ,
.OP extended ,
.OP ignorecase
and
.OP magic
options.
.SE
.KY SQUOTE<character>
.IP \'<character>
.KY `<character>
.Ip `<character>
Return to a context marked by the character
.LI <character> .
If
.LI <character>
is the
.QT '
or
.QT `
character, return to the previous context.
If
.LI <character>
is any other character,
return to the context marked by that character (see the
.CO m
command for more information).
If the command is the
.CO \'
command, only the line value is restored,
and the cursor is placed on the first nonblank character of that line.
If the command is the
.CO `
command, both the line and column values are restored.
.sp
It is an error if the context no longer exists because of
line deletion.
(Contexts follow lines that are moved, or which are deleted
and then restored.)
.sp
The
.CO \'
and
.CO `
commands are both absolute movements.
They may be used as a motion component for other
.CO vi
commands.
For the
.CO \'
command, any text copied into a buffer is line oriented.
For the
.CO `
command,
any text copied into a buffer is character oriented,
unless it both starts and stops at the first character in the line,
in which case it is line oriented.
In addition, when using the
.CO `
command as a motion component,
commands which move backward and started at the first character in the line,
or move forward and ended at the first character in the line,
are corrected to the last character of the line preceding the starting and
ending lines, respectively.
.SS
.SP Line:
Set to the line from the context.
.SP Column:
Set to the first nonblank character in the line, for the
.CO \'
command, and set to the context's column for the
.CO `
command.
.SP Options:
None.
.SE
.KY (
.IP "[count] ("
Back up
.LI count
sentences.
.sp
The
.CO (
command is an absolute movement.
The
.CO (
command may be used as the motion component of other
.CO vi
commands,
in which case any text copied into a buffer is character oriented,
unless the starting and stopping points of the region are the first
character in the line,
in which case it is line oriented.
If it is line oriented,
the starting point of the region is adjusted to be the end of the line
immediately before the starting cursor position.
.SS
.SP Line:
Set to the line containing the beginning of the sentence.
.SP Column:
Set to the first nonblank character of the sentence.
.SP Options:
Affected by the
.OP lisp
option.
.SE
.KY )
.IP "[count] )"
Move forward
.LI count
sentences.
.sp
The
.CO )
command is an absolute movement.
The
.CO )
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the starting point of the region is the
first character in the line, in which case it is line oriented.
In the latter case, if the stopping point of the region is also
the first character in the line, it is adjusted to be the end of the
line immediately before it.
.SS
.SP Line:
Set to the line containing the beginning of the sentence.
.SP Column:
Set to the first nonblank character of the sentence.
.SP Options:
Affected by the
.OP lisp
option.
.SE
.KY ,
.IP "[count] ,"
Reverse find character
.LI count
times.
Reverse the last
.CO F ,
.CO f ,
.CO T
or
.CO t
command, searching the other way in the line,
.LI count
times.
It is an error if a
.CO F ,
.CO f ,
.CO T
or
.CO t
command has not been performed yet.
.sp
The
.CO ,
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the searched-for character for the
.CO F
and
.CO f
commands,
before the character for the
.CO t
command
and after the character for the
.CO T
command.
.SP Options:
None.
.SE
.KY MINUSSIGN
.IP "[count] \-"
Move to the first nonblank of the previous line,
.LI count
times.
.sp
It is an error if the movement is past the beginning of the file.
.sp
The
.CO -
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.SS
.SP Line:
Set to the current line minus
.LI count .
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
None.
.SE
.KY \&.
.IP "[count] \&."
Repeat the last
.CO vi
command that modified text.
The repeated command may be a command and motion component combination.
If
.LI count
is specified, it replaces
.i both
the count specified for the repeated command, and, if applicable, for
the repeated motion component.
If
.LI count
is not specified, the counts originally specified to the command being
repeated are used again.
.sp
As a special case, if the
.CO \.
command is executed immediately after the
.CO u
command, the change log is rolled forward or backward, depending on
the action of the
.CO u
command.
.SS
.SP Line:
Set as described for the repeated command.
.SP Column:
Set as described for the repeated command.
.SP Options:
None.
.SE
.KY /RE/
.IP "/RE<carriage-return>"
.Ip "/RE/ [offset]<carriage-return>"
.KY ?RE?
.Ip "?RE<carriage-return>"
.Ip "?RE? [offset]<carriage-return>"
.KY N
.Ip "N"
.KY n
.Ip "n"
Search forward or backward for a regular expression.
The commands beginning with a slash
.PQ /
character are forward searches, the commands beginning with a
question mark
.PQ ?
are backward searches.
.CO Vi
prompts with the leading character on the last line of the screen
for a string.
It then searches forward or backward in the file for the next
occurrence of the string, which is interpreted as a Basic Regular
Expression.
.sp
The
.CO /
and
.CO ?
commands are absolute movements.
They may be used as the motion components of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the search started and ended on
the first column of a line, in which case it is line oriented.
In addition, forward searches ending at the first character of a line,
and backward searches beginning at the first character in the line,
are corrected to begin or end at the last character of the previous line.
(Note, forward and backward searches can occur for both
.CO /
and
.CO ?
commands, if the
.OP wrapscan
option is set.)
.sp
If an offset from the matched line is specified (i.e. a trailing
.QT /
or
.QT ?
character is followed by a signed offset), the buffer will always
be line oriented (e.g.
.QT /string/+0
will always guarantee a line orientation).
.sp
The
.CO N
command repeats the previous search, but in the reverse direction.
The
.CO n
command repeats the previous search.
If either the
.CO N
or
.CO n
commands are used as motion components for the 
.CO !
command, you will not be prompted for the text of the bang command,
instead the previous bang command will be executed.
.sp
Missing RE's (e.g.
.QT //<carriage-return> ,
.QT /<carriage-return> ,
.QT ??<carriage-return> ,
or
.QT ?<carriage-return>
search for the last search RE, in the indicated direction.
.sp
Searches may be interrupted using the
.LI <interrupt>
character.
.sp
Multiple search patterns may be grouped together by delimiting
them with semicolons and zero or more whitespace characters, e.g.
.LI "/foo/ ; ?bar?"
searches forward for
.LI foo
and then, from that location, backwards for
.LI bar .
When search patterns are grouped together in this manner,
the search patterns are evaluated left to right with the
final cursor position determined by the last search pattern.
.sp
It is also permissible to append a
.CO z
command to the search strings, e.g.
.LI "/foo/ z."
searches forward for the next occurrence of
.LI foo ,
and then positions that line in the middle of screen.
.SS
.SP Line:
Set to the line in which the match occurred.
.SP Column:
Set to the first character of the matched string.
.SP Options:
Affected by the
.OP edcompatible ,
.OP extended ,
.OP ignorecase ,
.OP magic ,
and
.OP wrapscan
options.
.SE
.KY 0
.IP "0"
Move to the first character in the current line.
It is not an error to use the
.CO 0
command when the cursor is on the first character in the line,
.sp
The
.CO 0
command may be used as the motion component of other
.CO vi
commands,
in which case it is an error if the cursor is on the first character
in the line,
and any text copied into a buffer is character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the first character in the line.
.SP Options:
None.
.SE
.KY :
.IP ":"
Execute an
.CO ex
command.
.CO Vi
prompts for an
.CO ex
command on the last line of the screen, using a colon
.PQ :
character.
The command is terminated by a
.LI <carriage-return> ,
.LI <newline>
or
.LI <escape>
character; all of these characters may be escaped by using a
.LI "<literal-next>"
character.
The command is then executed.
.sp
If the
.CO ex
command writes to the screen,
.CO vi
will prompt the user for a
.LI <carriage-return>
before continuing
when the
.CO ex
command finishes.
Large amounts of output from the
.CO ex
command will be paged for the user, and the user prompted for a
.LI <carriage-return>
or
.LI <space>
key to continue.
In some cases, a quit (normally a
.QQ q
character) or
.LI <interrupt>
may be entered to interrupt the
.CO ex
command.
.sp
When the
.CO ex
command finishes, and the user is prompted to resume visual mode,
it is also possible to enter another
.QT :
character followed by another
.CO ex
command.
.SS
.SP Line:
The current line is set as described for the
.CO ex
command.
.SP Column:
The current column is set as described for the
.CO ex
command.
.SP Options:
Affected as described for the
.CO ex
command.
.SE
.KY ;
.IP "[count] ;"
Repeat the last character find
.LI count
times.
The last character find is one of the
.CO F ,
.CO f ,
.CO T
or
.CO t
commands.
It is an error if a
.CO F ,
.CO f ,
.CO T
or
.CO t
command has not been performed yet.
.sp
The
.CO ;
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the searched-for character for the
.CO F
and
.CO f
commands,
before the character for the
.CO t
command
and after the character for the
.CO T
command.
.SP Options:
None.
.SE
.KY <
.IP "[count] < motion"
.KY >
.Ip "[count] > motion"
Shift lines left or right.
Shift the number of lines in the region specified by the
.LI count
and
.LI motion
left (for the
.CO <
command) or right (for the
.CO >
command) by the number of columns specified by the
.OP shiftwidth
option.
Only whitespace characters are deleted when shifting left.
Once the first character in the line no longer contains a whitespace
character, the command will succeed,
but the line will not be modified.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
Affected by the
.OP shiftwidth
option.
.SE
.KY @
.IP "@ buffer"
Execute a named buffer.
Execute the named buffer as
.CO vi
commands.
The buffer may include
.CO ex
commands, too, but they must be expressed as a
.CO :
command.
If the buffer is line oriented,
.LI <newline>
characters are logically appended to each line of the buffer.
If the buffer is character oriented,
.LI <newline>
characters are logically appended to all but the last line in the buffer.
.sp
If the buffer name is
.QT @ ,
or
.QT * ,
then the last buffer executed shall be used.
It is an error to specify
.QT @@
or
.QT @*
if there were no previous buffer executions.
The text of a buffer may contain a
.CO @
command,
and it is possible to create infinite loops in this manner.
(The
.LI <interrupt>
character may be used to interrupt the loop.)
.SS
.SP Line:
The current line is set as described for the command(s).
.SP Column:
The current column is set as described for the command(s).
.SP Options:
None.
.SE
.KY A
.IP "[count] A"
Enter input mode, appending the text after the end of the line.
If
.LI count
is specified, the text is repeatedly input
.LI "count - 1"
more times after input mode is exited.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY B
.IP "[count] B"
Move backward
.LI count
bigwords.
Move the cursor backward to the beginning of a bigword by repeating the
following algorithm: if the current position is at the beginning of a
bigword or the character at the current position cannot be part of a bigword,
move to the first character of the preceding bigword.
Otherwise, move to the first character of the bigword at the current position.
If no preceding bigword exists on the current line, move to the first
character of the last bigword on the first preceding line that contains a
bigword.
.sp
The
.CO B
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Set to the line containing the word selected.
.SP Column:
Set to the first character of the word selected.
.SP Options:
None.
.SE
.KY C
.IP "[buffer] [count] C"
Change text from the current position to the end-of-line.
If
.LI count
is specified, the input text replaces from the current position to
the end-of-line, plus
.LI "count - 1"
subsequent lines.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY D
.IP "[buffer] D"
Delete text from the current position to the end-of-line.
.sp
It is not an error to execute the
.CO D
command on an empty line.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the character before the current character, or, column 1 if
the cursor was on column 1.
.SP Options:
None.
.SE
.KY E
.IP "[count] E"
Move forward
.LI count
end-of-bigwords.
Move the cursor forward to the end of a bigword by repeating the
following algorithm: if the current position is the end of a
bigword or the character at that position cannot be part of a bigword,
move to the last character of the following bigword.
Otherwise, move to the last character of the bigword at the current
position.
If no succeeding bigword exists on the current line,
move to the last character of the first bigword on the next following
line that contains a bigword.
.sp
The
.CO E
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Set to the line containing the word selected.
.SP Column:
Set to the last character of the word selected.
.SP Options:
None.
.SE
.KY F
.IP "[count] F <character>"
Search
.LI count
times backward through the current line for
.LI <character> .
.sp
The
.CO F
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the searched-for character.
.SP Options:
None.
.SE
.KY G
.IP "[count] G"
Move to line
.LI count ,
or the last line of the file if
.LI count
not specified.
.sp
The
.CO G
command is an absolute movement.
The
.CO \&G
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.SS
.SP Line:
Set to
.LI count ,
if specified, otherwise, the last line.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
None.
.SE
.KY H
.IP "[count] H"
Move to the screen line
.LI "count - 1"
lines below the top of the screen.
.sp
The
.CO H
command is an absolute movement.
The
.CO H
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.SS
.SP Line:
Set to the line
.LI "count - 1"
lines below the top of the screen.
.SP Column:
Set to the first nonblank character of the
.i screen
line.
.SP Options:
None.
.SE
.KY I
.IP "[count] I"
Enter input mode, inserting the text at the beginning of the line.
If
.LI count
is specified, the text input is repeatedly input
.LI "count - 1"
more times.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
None.
.SE
.KY J
.IP "[count] J"
Join lines.
If
.LI count
is specified,
.LI count
lines are joined; a minimum of two lines are always joined,
regardless of the value of
.LI count .
.sp
If the current line ends with a whitespace character, all whitespace
is stripped from the next line.
Otherwise, if the next line starts with a open parenthesis
.PQ (
do nothing.
Otherwise, if the current line ends with a question mark
.PQ ? ,
period
.PQ \&.
or exclamation point
.PQ ! ,
insert two spaces.
Otherwise, insert a single space.
.sp
It is not an error to join lines past the end of the file,
i.e. lines that do not exist.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the character after the last character of the next-to-last
joined line.
.SP Options:
None.
.SE
.KY L
.IP "[count] L"
Move to the screen line
.LI "count - 1"
lines above the bottom of the screen.
.sp
The
.CO L
command is an absolute movement.
The
.CO L
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.SS
.SP Line:
Set to the line
.LI "count - 1"
lines above the bottom of the screen.
.SP Column:
Set to the first nonblank character of the
.i screen
line.
.SP Options:
None.
.SE
.KY  M
.IP " M"
Move to the screen line in the middle of the screen.
.sp
The
.CO M
command is an absolute movement.
The
.CO M
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.sp
Historically, any
.LI count
specified to the
.CO M
command was ignored.
.SS
.SP Line:
Set to the line in the middle of the screen.
.SP Column:
Set to the first nonblank character of the
.i screen
line.
.SP Options:
None.
.SE
.KY O
.IP "[count] O"
Enter input mode, appending text in a new line above the current line.
If
.LI count
is specified, the text input is repeatedly input
.LI "count - 1"
more times.
.sp
Historically, any
.LI count
specified to the
.CO O
command was ignored.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY P
.IP "[buffer] P"
Insert text from a buffer.
Text from the buffer (the unnamed buffer by default) is inserted
before the current column or, if the buffer is line oriented,
before the current line.
.SS
.SP Line:
Set to the lowest numbered line insert,
if the buffer is line oriented, otherwise unchanged.
.SP Column:
Set to the first nonblank character of the appended text,
if the buffer is line oriented, otherwise, the last character
of the appended text.
.SP Options:
None.
.SE
.KY Q
.IP "Q"
Exit
.CO vi
(or visual) mode and switch to
.CO ex
mode.
.SS
.SP Line:
Unchanged.
.SP Column:
No longer relevant.
.SP Options:
None.
.SE
.KY R
.IP "[count] R"
Enter input mode, replacing the characters in the current line.
If
.LI count
is specified, the text input is repeatedly input
.LI "count - 1"
more times.
.sp
If the end of the current line is reached, no more characters are
replaced and any further characters input are appended to the line.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY S
.IP "[buffer] [count] S"
Substitute
.LI count
lines.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY T
.IP "[count] T <character>"
Search backward,
.LI count
times,
through the current line for the character
.i after
the specified
.LI <character> .
.sp
The
.CO T
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the character
.i after
the searched-for character.
.SP Options:
None.
.SE
.KY U
.IP "U"
Restore the current line to its state before the cursor last
moved to it.
.SS
.SP Line:
Unchanged.
.SP Column:
The first character in the line.
.SP Options:
None.
.SE
.KY W
.IP "[count] W"
Move forward
.LI count
bigwords.
Move the cursor forward to the beginning of a bigword by repeating the
following algorithm: if the current position is within a bigword or the
character at that position cannot be part of a bigword, move to the first
character of the next bigword.
If no subsequent bigword exists on the current line,
move to the first character of the first bigword on the first following
line that contains a bigword.
.sp
The
.CO W
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
The line containing the word selected.
.SP Column:
The first character of the word selected.
.SP Options:
None.
.SE
.KY X
.IP "[buffer] [count] X"
Delete
.LI count
characters before the cursor.
If the number of characters to be deleted is greater than or equal to
the number of characters to the beginning of the line, all of the
characters before the current cursor position, to the beginning of the
line, are deleted.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the current character minus
.LI count ,
or the first character if count is greater than the number of
characters in the line before the cursor.
.SP Options:
None.
.SE
.KY Y
.IP "[buffer] [count] Y"
Copy (or
.QQ yank )
.LI count
lines into the specified buffer.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged.
.SP Options:
None.
.SE
.KY ZZ
.IP "ZZ"
Write the file and exit
.CO vi .
The file is only written if it has been modified since the last
complete write of the file to any file.
.sp
The
.CO ZZ
command will exit the editor after writing the file,
if there are no further files to edit.
Entering two
.QQ quit
commands (i.e.
.CO wq ,
.CO quit ,
.CO xit
or
.CO ZZ )
in a row will override this check and the editor will exit,
ignoring any files that have not yet been edited.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged.
.SP Options:
None.
.SE
.KY [[
.IP "[count] [["
Back up
.LI count
section boundaries.
.sp
The
.CO [[
command is an absolute movement.
The
.CO [[
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the starting position is column 0,
in which case it is line oriented.
.sp
It is an error if the movement is past the beginning of the file.
.SS
.SP Line:
Set to the previous line that is
.LI count
section boundaries back,
or the first line of the file if no more section boundaries exist
preceding the current line.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
Affected by the
.OP sections
option.
.SE
.KY ]]
.IP "[count] ]]"
Move forward
.LI count
section boundaries.
.sp
The
.CO ]]
command is an absolute movement.
The
.CO ]]
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the starting position is column 0,
in which case it is line oriented.
.sp
It is an error if the movement is past the end of the file.
.SS
.SP Line:
Set to the line that is
.LI count
section boundaries forward,
or to the last line of the file if no more section
boundaries exist following the current line.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
Affected by the
.OP sections
option.
.SE
.KY ^
.IP "\&^"
Move to first nonblank character on the current line.
.sp
The
.CO ^
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the first nonblank character of the current line.
.SP Options:
None.
.SE
.KY _
.IP "[count] _"
Move down
.LI "count - 1"
lines, to the first nonblank character.
The
.CO _
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
line oriented.
.sp
It is not an error to execute the
.CO _
command when the cursor is on the first character in the line.
.SS
.SP Line:
The current line plus
.LI "count - 1" .
.SP Column:
The first nonblank character in the line.
.SP Options:
None.
.SE
.KY a
.IP "[count] a"
Enter input mode, appending the text after the cursor.
If
.LI count
is specified, the text input is repeatedly input
.LI "count - 1"
more times.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY b
.IP "[count] b"
Move backward
.LI count
words.
Move the cursor backward to the beginning of a word by repeating the
following algorithm: if the current position is at the beginning of a word,
move to the first character of the preceding word.
Otherwise, the current position moves to the first character of the word
at the current position.
If no preceding word exists on the current line, move to the first
character of the last word on the first preceding line that contains
a word.
.sp
The
.CO b
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Set to the line containing the word selected.
.SP Column:
Set to the first character of the word selected.
.SP Options:
None.
.SE
.KY c
.IP "[buffer] [count] c motion"
Change the region of text specified by the
.LI count
and
.LI motion .
If only part of a single line is affected, then the last character
being changed is marked with a
.QT $ .
Otherwise, the region of text is deleted, and input mode is entered.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY d
.IP "[buffer] [count] d motion"
Delete the region of text specified by the
.LI count
and
.LI motion .
.SS
.SP Line:
Set to the line where the region starts.
.SP Column:
Set to the first character in the line after the last character in the
region.
If no such character exists, set to the last character before the region.
.SP Options:
None.
.SE
.KY e
.IP "[count] e"
Move forward
.LI count
end-of-words.
Move the cursor forward to the end of a word by repeating the following
algorithm: if the current position is the end of a word,
move to the last character of the following word.
Otherwise, move to the last character of the word at the current position.
If no succeeding word exists on the current line, move to the last character
of the first word on the next following line that contains a word.
.sp
The
.CO e
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Set to the line containing the word selected.
.SP Column:
Set to the last character of the word selected.
.SP Options:
None.
.SE
.KY f
.IP "[count] f <character>"
Search forward,
.LI count
times, through the rest of the current line for
.LI <character> .
.sp
The
.CO f
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the searched-for character.
.SP Options:
None.
.SE
.KY i
.IP "[count] i"
Enter input mode, inserting the text before the cursor.
If
.LI count
is specified, the text input is repeatedly input
.LI "count - 1"
more times.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY m
.IP "m <character>"
Save the current context (line and column) as
.LI <character> .
The exact position is referred to by
.QT `<character> .
The line is referred to by
.QT '<character> .
.sp
Historically,
.LI <character>
was restricted to lower-case letters.
.CO Nvi
permits the use of any character.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged.
.SP Options:
None.
.SE
.KY o
.IP "[count] o"
Enter input mode, appending text in a new line under the current line.
If
.LI count
is specified, the text input is repeatedly input
.LI "count - 1"
more times.
.sp
Historically, any
.LI count
specified to the
.CO o
command was ignored.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY p
.IP "[buffer] p"
Append text from a buffer.
Text from the buffer (the unnamed buffer by default) is appended
after the current column or, if the buffer is line oriented,
after the current line.
.SS
.SP Line:
Set to the first line appended, if the buffer is line oriented,
otherwise unchanged.
.SP Column:
Set to the first nonblank character of the appended text if the buffer
is line oriented, otherwise, the last character of the appended text.
.SP Options:
None.
.SE
.KY r
.IP "[count] r <character>"
Replace characters.
The next
.LI count
characters in the line are replaced with
.LI <character> .
Replacing characters with
.LI <newline>
characters results in creating new, empty lines into the file.
.sp
If
.LI <character>
is
.LI <escape> ,
the command is cancelled.
.SS
.SP Line:
Unchanged unless the replacement character is a
.LI <newline> ,
in which case it is set to the current line plus
.LI "count - 1" .
.SP Column:
Set to the last character replaced,
unless the replacement character is a
.LI <newline> ,
in which case the cursor is in column 1 of the last line inserted.
.SP Options:
None.
.SE
.KY s
.IP "[buffer] [count] s"
Substitute
.LI count
characters in the current line starting with the current character.
.SS
.SP Line:
Set to the last line upon which characters were entered.
.SP Column:
Set to the last character entered.
.SP Options:
Affected by the
.OP altwerase ,
.OP autoindent ,
.OP beautify ,
.OP showmatch ,
.OP ttywerase
and
.OP wrapmargin
options.
.SE
.KY t
.IP "[count] t <character>"
Search forward,
.LI count
times, through the current line for the character immediately
.i before
.LI <character> .
.sp
The
.CO t
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the character
.i before
the searched-for character.
.SP Options:
None.
.SE
.KY u
.IP "u"
Undo the last change made to the file.
If repeated, the
.CO u
command alternates between these two states, and is its own inverse.
When used after an insert that inserted text on more than one line,
the lines are saved in the numeric buffers.
.sp
The
.CO \&.
command, when used immediately after the
.CO u
command, causes the change log to be rolled forward or backward,
depending on the action of the
.CO u
command.
.SS
.SP Line:
Set to the position of the first line changed, if the reversal affects
only one line or represents an addition or change; otherwise, the line
preceding the deleted text.
.SP Column:
Set to the cursor position before the change was made.
.SP Options:
None.
.SE
.KY w
.IP "[count] w"
Move forward
.LI count
words.
Move the cursor forward to the beginning of a word by repeating the
following algorithm: if the current position is at the
beginning of a word, move to the first character of the next word.
If no subsequent word exists on the current line, move to the first
character of the first word on the first following line that contains
a word.
.sp
The
.CO w
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
.SS
.SP Line:
Set to the line containing the word selected.
.SP Column:
Set to the first character of the word selected.
.SP Options:
None.
.SE
.KY x
.IP "[buffer] [count] x"
Delete
.LI count
characters.
The deletion is at the current character position.
If the number of characters to be deleted is greater than or equal to
the number of characters to the end of the line, all of the characters
from the current cursor position to the end of the line are deleted.
.SS
.SP Line:
Unchanged.
.SP Column:
Unchanged unless the last character in the line is deleted and the cursor
is not already on the first character in the line, in which case it is
set to the previous character.
.SP Options:
None.
.SE
.KY y
.IP "[buffer] [count] y motion"
Copy (or
.QQ yank )
the text region specified by the
.LI count
and
.LI motion ,
into a buffer.
.SS
.SP Line:
Unchanged, unless the region covers more than a single line,
in which case it is set to the line where the region starts.
.SP Column:
Unchanged, unless the region covers more than a single line,
in which case it is set to the character were the region starts.
.SP Options:
None.
.SE
.KY z
.IP "[count1] z [count2] type"
Redraw the screen with a window
.LI count2
lines long, with line
.LI count1
placed as specified by the
.LI type
character.
If
.LI count1
is not specified, it defaults to the current line.
If
.LI count2
is not specified, it defaults to the current window size.
.sp
The following
.LI type
characters may be used:
.SS
.SP +
If
.LI count1
is specified, place the line
.LI count1
at the top of the screen.
Otherwise, display the screen after the current screen, similarly to the
.CO <control-F>
command.
.SP <carriage-return>
Place the line
.LI count1
at the top of the screen.
.SP \&.
Place the line
.LI count1
in the center of the screen.
.SP \-
Place the line
.LI count1
at the bottom of the screen.
.SP ^
If
.LI count1
is specified, place the line that is at the top of the screen 
when
.LI count1
is at the bottom of the screen, at the bottom of the screen,
i.e. display the screen before the screen before
.LI count1 .
Otherwise, display the screen before the current screen, similarly to the
.CO <control-B>
command.
.SE
.SS
.SP Line:
Set to
.LI count1
unless
.LI count1
is not specified and the
.LI type
character was either
.QT ^
or
.QT + ,
in which case it is set to the line before the first line on the
previous screen or the line after the last line on the previous
screen, respectively.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
None.
.SE
.KY {
.IP "[count] {"
Move backward
.LI count
paragraphs.
.sp
The
.CO {
command is an absolute movement.
The
.CO {
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the starting character is the first
character on its line, in which case it is line oriented.
.SS
.SP Line:
Set to the line containing the beginning of the previous paragraph.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
Affected by the
.OP paragraph
option.
.SE
.KY |
.IP "[count] |"
Move to a specific
.i column
position on the current line.
.sp
The
.CO |
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented.
It is an error to use the
.CO |
command as a motion component and for the cursor not to move.
.SS
.SP Line:
Unchanged.
.SP Column:
Set to the character occupying the column position identified by
.LI count ,
if the position exists in the line.
If the column length of the current line is less than
.LI count ,
the cursor is moved to the last character in the line.
.SP Options:
None.
.SE
.KY }
.IP "[count] }"
Move forward
.LI count
paragraphs.
.sp
The
.CO }
command is an absolute movement.
The
.CO }
command may be used as the motion component of other
.CO vi
commands, in which case any text copied into a buffer is
character oriented, unless the starting character is at or
before any nonblank characters in its line,
in which case it is line oriented.
.SS
.SP Line:
Set to the line containing the beginning of the next paragraph.
.SP Column:
Set to the first nonblank character in the line.
.SP Options:
Affected by the
.OP paragraph
option.
.SE
.KY ~
.IP "[count] ~"
Reverse the case of the next
.LI count
character(s).
This is the historic semantic for the
.CO ~
command and it is only in effect if the
.OP tildeop
option is not set.
.sp
Lowercase alphabetic characters are changed to uppercase,
and uppercase characters are changed to lowercase.
No other characters are affected.
.sp
Historically, the
.CO ~
command did not take an associated count, nor did it move past the
end of the current line.
As it had no associated motion it was difficult to change the case
of large blocks of text.
In
.CO nvi ,
if the cursor is on the last character of a line, and there are
more lines in the file, the cursor moves to the next line.
.sp
It is not an error to specify a count larger than the number of
characters between the cursor and the end of the file.
.SS
.SP Line:
Set to the line of the character after
.LI count
characters, or, end of file.
.SP Column:
Set to the character after
.LI count
characters, or, end-of-file.
.SP Options:
Affected by the
.OP tildeop
option.
.SE
.KY ~
.IP "[count] ~ motion"
Reverse the case of the characters in a text region specified by the
.LI count
and
.LI motion .
Only in effect if the
.OP tildeop
option is set.
.sp
Lowercase characters are changed to uppercase,
and uppercase characters are changed to lowercase.
No other characters are affected.
.SS
.SP Line:
Set to the line of the character after the last character in the region.
.SP Column:
Set to the character after the last character in the region.
.SP Options:
Affected by the
.OP tildeop
option.
.SE
.KY <interrupt>
.IP "<interrupt>"
Interrupt the current operation.
Many of the potentially long-running
.CO vi
commands may be interrupted using the terminal interrupt character.
These operations include searches, file reading and writing, filter
operations and map character expansion.
Interrupts are also enabled when running commands outside of
.CO vi .
.sp
If the
.LI <interrupt>
character is used to interrupt while entering an
.CO ex
command, the command is aborted, the cursor returns to its previous
position, and
.CO vi
remains in command mode.
.sp
Generally, if the
.LI <interrupt>
character is used to interrupt any
operation, any changes made before the interrupt are left in place.
.SS
.SP Line:
Dependent on the operation being interrupted.
.SP Column:
Dependent on the operation being interrupted.
.SP Options:
None.
.SH 1 "Vi Text Input Commands"
.pp
The following section describes the commands available in the text
input mode of the
.CO vi
editor.
.pp
Historically,
.CO vi
implementations only permitted the characters inserted on the current
line to be erased.
In addition, only the
.LI <control-D>
erase character and the
.QT 0<control-D>
and
.QT ^<control-D>
erase strings could erase autoindent characters.
(Autoindent characters include both the characters inserted automatically
at the beginning of an input line as well as characters inserted using the
.LI <control-T>
command.)
This implementation permits erasure to continue past the beginning
of the current line, and back to where text input mode was entered.
In addition, autoindent characters may be erased using the standard
erase characters.
For the line and word erase characters, reaching the autoindent
characters forms a
.QQ soft
boundary, denoting the end of the current word or line erase.
Repeating the word or line erase key will erase the autoindent characters.
.pp
Historically,
.CO vi
always used
.LI <control-H>
and
.LI <control-W>
as character and word erase characters, respectively, regardless of
the current terminal settings.
This implementation accepts, in addition to these two characters,
the current terminal characters for those operations.
.KY <nul>
.IP "<nul>"
If the first character of the input is a
.LI <nul> ,
the previous input is replayed, as if just entered.
.KY <control-D>
.IP "<control-D>"
If the previous character on the line was an autoindent character,
erase characters to move the cursor back to the column immediately
after the previous (1-based) column which is a multiple of the
.OP shiftwidth
edit option.
This may result in any number of
.LI <tab>
and
.LI <space>
characters preceding the cursor being changed.
.sp
Otherwise, if the
.OP autoindent
option is set and the user is entering the first character in the line,
.LI <control-D>
is ignored.
Otherwise, a literal
.LI <control-D>
character is entered.
.KY ^<control-D>
.IP "^<control-D>"
If the previous character on the line was an autoindent character,
erase all of the autoindent characters on the line.
In addition, the autoindent level is reset to 0.
.KY 0<control-D>
.IP "0<control-D>"
If the previous character on the line was an autoindent character,
erase all of the autoindent characters on the line.
The autoindent level is not altered.
.KY <control-T>
.IP "<control-T>"
Insert sufficient
.LI <tab>
and
.LI <space>
characters to move the cursor forward to the column immediately
after the next (1-based) column which is a multiple of the
.OP shiftwidth
edit option.
This may result in any number of
.LI <tab>
and
.LI <space>
characters preceding the cursor being changed.
.sp
Historically,
.CO vi
did not permit the
.LI <control-T>
command to be used unless the cursor was at the first column of a new
line or it was preceded only by autoindent characters.
.CO Nvi
permits it to be used at any time during insert mode.
.KY <erase>
.IP <erase>
.KY <control-H>
.Ip <control-H>
Erase the last character.
.KY "<literal-next>"
.IP "<literal-next>"
Quote the next character.
The next character will not be mapped (see the
.CO map
command for more information)
or interpreted specially.
A carat
.PQ ^
character will be displayed immediately as a placeholder,
but will be replaced by the next character.
.KY <escape>
.IP <escape>
If on the colon command line, and the
.OP filec
edit option is set, behave as described for that option.
Otherwise, if on the colon command line,
execute the command.
Otherwise, if not on the colon command line,
resolve all text input into the file, and return to command mode.
.KY "<line erase>"
.IP "<line erase>"
Erase the current line.
.KY "<control-W>"
.IP "<control-W>"
.KY "<word erase>"
.Ip "<word erase>"
Erase the last word.
The definition of word is dependent on the
.OP altwerase
and
.OP ttywerase
options.
.KY "<control-X>"
.IP "<control-X>[0-9A-Fa-f]+"
Insert a character with the specified hexadecimal value into the text.
The value is delimited by any non-hexadecimal character or the input
of the maximum number of characters that can be translated into a single
character value.
.KY <interrupt>
.IP "<interrupt>"
Interrupt text input mode, returning to command mode.
If the
.LI <interrupt>
character is used to interrupt inserting text into the file,
it is as if the
.LI <escape>
character was used; all text input up to the interruption is
resolved into the file.