/usr/share/doc/vim/html/insert.html is in vim-doc 2:8.0.1453-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: insert</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: insert</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>
<HR>
<PRE>
*<A NAME="insert.txt"></A><B>insert.txt</B>* For Vim version 8.0. Last change: 2018 Jan 26
VIM REFERENCE MANUAL by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>
*<A NAME="Insert"></A><B>Insert</B>* *<A NAME="Insert-mode"></A><B>Insert-mode</B>*
Inserting and <A HREF="change.html#replacing">replacing</A> text *<A NAME="mode-ins-repl"></A><B>mode-ins-repl</B>*
Most of this file is about <A HREF="#Insert">Insert</A> and <A HREF="#Replace">Replace</A> mode. At the end are a few
commands for <A HREF="#inserting">inserting</A> text in other ways.
An overview of the most often used commands can be found in chapter 24 of the
user manual |<A HREF="usr_24.html">usr_24.txt</A>|.
1. <A HREF="eval.html#Special">Special</A> keys |<A HREF="#ins-special-keys">ins-special-keys</A>|
2. <A HREF="eval.html#Special">Special</A> special keys |<A HREF="#ins-special-special">ins-special-special</A>|
3. <A HREF="options.html#'textwidth'">'textwidth'</A> and <A HREF="options.html#'wrapmargin'">'wrapmargin'</A> <A HREF="options.html#options">options</A> |<A HREF="#ins-textwidth">ins-textwidth</A>|
4. <A HREF="options.html#'expandtab'">'expandtab'</A>, <A HREF="options.html#'smarttab'">'smarttab'</A> and <A HREF="options.html#'softtabstop'">'softtabstop'</A> <A HREF="options.html#options">options</A> |<A HREF="#ins-expandtab">ins-expandtab</A>|
5. Replace mode |<A HREF="#Replace-mode">Replace-mode</A>|
6. Virtual Replace mode |<A HREF="#Virtual-Replace-mode">Virtual-Replace-mode</A>|
7. <A HREF="#Insert">Insert</A> mode completion |<A HREF="#ins-completion">ins-completion</A>|
8. <A HREF="#Insert">Insert</A> mode commands |<A HREF="#inserting">inserting</A>|
9. <A HREF="intro.html#Ex">Ex</A> insert commands |<A HREF="#inserting-ex">inserting-ex</A>|
10. Inserting a file |<A HREF="#inserting-file">inserting-file</A>|
Also see <A HREF="options.html#'virtualedit'">'virtualedit'</A>, for moving the cursor to positions where there is no
character. Useful for editing a table.
==============================================================================
1. <A HREF="eval.html#Special">Special</A> keys *<A NAME="ins-special-keys"></A><B>ins-special-keys</B>*
In <A HREF="#Insert">Insert</A> and <A HREF="#Replace">Replace</A> mode, the following characters have a special meaning;
other characters are inserted directly. To insert one of these special
characters into the buffer, precede <A HREF="motion.html#it">it</A> with <A HREF="visual.html#CTRL-V">CTRL-V</A>. To insert a <A HREF="intro.html#<Nul>"><Nul></A>
character use "<A HREF="visual.html#CTRL-V">CTRL-V</A> CTRL-@" or "<A HREF="visual.html#CTRL-V">CTRL-V</A> 000". On some systems, you have to
use "<A HREF="visual.html#CTRL-V">CTRL-V</A> 003" to insert a <A HREF="pattern.html#CTRL-C">CTRL-C</A>. Note: When <A HREF="visual.html#CTRL-V">CTRL-V</A> is mapped you can
often use CTRL-Q instead |<A HREF="#i_CTRL-Q">i_CTRL-Q</A>|.
If you are working in a special language mode when <A HREF="#inserting">inserting</A> text, see the
'langmap' option, |<A HREF="options.html#'langmap'">'langmap'</A>|, on how to avoid switching this mode on and off
all the time.
If you have <A HREF="options.html#'insertmode'">'insertmode'</A> set, <A HREF="intro.html#<Esc>"><Esc></A> and a few other keys get another meaning.
See |<A HREF="options.html#'insertmode'">'insertmode'</A>|.
<B><FONT COLOR="PURPLE">char action </FONT></B>
*<A NAME="i_CTRL-["></A><B>i_CTRL-[</B>* *<A NAME="i_<Esc>"></A><B>i_<Esc></B>*
<A HREF="intro.html#<Esc>"><Esc></A> or CTRL-[ End insert or <A HREF="#Replace">Replace</A> mode, go back to <A HREF="intro.html#Normal">Normal</A> mode. Finish
abbreviation.
Note: If your <A HREF="intro.html#<Esc>"><Esc></A> key is hard to hit on your keyboard, train
yourself to use CTRL-[.
If Esc doesn't work and you are using a <A HREF="os_mac.html#Mac">Mac</A>, try CTRL-Esc.
Or disable Listening under Accessibility preferences.
*<A NAME="i_CTRL-C"></A><B>i_CTRL-C</B>*
<A HREF="pattern.html#CTRL-C">CTRL-C</A> Quit insert mode, go back to <A HREF="intro.html#Normal">Normal</A> mode. Do not check for
<A HREF="map.html#abbreviations">abbreviations</A>. Does not trigger the |<A HREF="autocmd.html#InsertLeave">InsertLeave</A>| <A HREF="autocmd.html#autocommand">autocommand</A>
event.
*<A NAME="i_CTRL-@"></A><B>i_CTRL-@</B>*
CTRL-@ <A HREF="#Insert">Insert</A> previously inserted text and stop insert. {Vi: only
when typed <A HREF="motion.html#as">as</A> first char, only up to 128 chars}
*<A NAME="i_CTRL-A"></A><B>i_CTRL-A</B>*
<A HREF="change.html#CTRL-A">CTRL-A</A> <A HREF="#Insert">Insert</A> previously inserted text. {not in Vi}
*<A NAME="i_CTRL-H"></A><B>i_CTRL-H</B>* *<A NAME="i_<BS>"></A><B>i_<BS></B>* *<A NAME="i_BS"></A><B>i_BS</B>*
<A HREF="motion.html#<BS>"><BS></A> or <A HREF="motion.html#CTRL-H">CTRL-H</A> Delete the character before the cursor (see |<A HREF="#i_backspacing">i_backspacing</A>|
about joining lines).
See |<A HREF="options.html#:fixdel">:fixdel</A>| if your <A HREF="motion.html#<BS>"><BS></A> key does not <A HREF="diff.html#do">do</A> what you want.
{Vi: does not delete autoindents}
*<A NAME="i_<Del>"></A><B>i_<Del></B>* *<A NAME="i_DEL"></A><B>i_DEL</B>*
<A HREF="change.html#<Del>"><Del></A> Delete the character under the cursor. If the cursor is at
the end of the line, and the <A HREF="options.html#'backspace'">'backspace'</A> option includes
"eol", delete the <A HREF="intro.html#<EOL>"><EOL></A>; the next line is appended after the
current one.
See |<A HREF="options.html#:fixdel">:fixdel</A>| if your <A HREF="change.html#<Del>"><Del></A> key does not <A HREF="diff.html#do">do</A> what you want.
{not in Vi}
*<A NAME="i_CTRL-W"></A><B>i_CTRL-W</B>*
<A HREF="index.html#CTRL-W">CTRL-W</A> Delete the <A HREF="motion.html#word">word</A> before the cursor (see |<A HREF="#i_backspacing">i_backspacing</A>| about
joining lines). See the section "<A HREF="motion.html#word">word</A> motions",
|<A HREF="motion.html#word-motions">word-motions</A>|, for the definition of a word.
*<A NAME="i_CTRL-U"></A><B>i_CTRL-U</B>*
<A HREF="scroll.html#CTRL-U">CTRL-U</A> Delete all entered characters before the cursor in the current
line. If there are no newly entered characters and
<A HREF="options.html#'backspace'">'backspace'</A> is not empty, delete all characters before the
cursor in the current line.
See |<A HREF="#i_backspacing">i_backspacing</A>| about joining lines.
*<A NAME="i_CTRL-I"></A><B>i_CTRL-I</B>* *<A NAME="i_<Tab>"></A><B>i_<Tab></B>* *<A NAME="i_Tab"></A><B>i_Tab</B>*
<A HREF="motion.html#<Tab>"><Tab></A> or <A HREF="motion.html#CTRL-I">CTRL-I</A> <A HREF="#Insert">Insert</A> a <A HREF="intro.html#tab">tab</A>. If the <A HREF="options.html#'expandtab'">'expandtab'</A> option is on, the
equivalent number of spaces is inserted (use <A HREF="visual.html#CTRL-V">CTRL-V</A> <A HREF="motion.html#<Tab>"><Tab></A> to
avoid the expansion; use <A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A> <A HREF="motion.html#<Tab>"><Tab></A> if <A HREF="visual.html#CTRL-V">CTRL-V</A> is mapped
|<A HREF="#i_CTRL-Q">i_CTRL-Q</A>|). See also the <A HREF="options.html#'smarttab'">'smarttab'</A> option and
|<A HREF="#ins-expandtab">ins-expandtab</A>|.
*<A NAME="i_CTRL-J"></A><B>i_CTRL-J</B>* *<A NAME="i_<NL>"></A><B>i_<NL></B>*
<A HREF="motion.html#<NL>"><NL></A> or <A HREF="motion.html#CTRL-J">CTRL-J</A> Begin new line.
*<A NAME="i_CTRL-M"></A><B>i_CTRL-M</B>* *<A NAME="i_<CR>"></A><B>i_<CR></B>*
<A HREF="motion.html#<CR>"><CR></A> or <A HREF="motion.html#CTRL-M">CTRL-M</A> Begin new line.
*<A NAME="i_CTRL-K"></A><B>i_CTRL-K</B>*
CTRL-K {char1} [char2]
Enter digraph (see |<A HREF="digraph.html#digraphs">digraphs</A>|). When {char1} is a special
key, the code for that key is inserted in <A HREF="intro.html#<>"><></A> form. For
example, the <A HREF="eval.html#string">string</A> "<S-Space>" can be entered by typing
<C-K><S-Space> (two keys). Neither char is considered for
<A HREF="map.html#mapping">mapping</A>. {not in Vi}
CTRL-N Find next keyword (see |<A HREF="#i_CTRL-N">i_CTRL-N</A>|). {not in Vi}
CTRL-P Find previous keyword (see |<A HREF="#i_CTRL-P">i_CTRL-P</A>|). {not in Vi}
<A HREF="undo.html#CTRL-R">CTRL-R</A> {0-9a-z"%#*+:.-=} *<A NAME="i_CTRL-R"></A><B>i_CTRL-R</B>*
<A HREF="#Insert">Insert</A> the contents of a <A HREF="sponsor.html#register">register</A>. Between typing <A HREF="undo.html#CTRL-R">CTRL-R</A> and
the second character, '"'' will be displayed to indicate that
you are expected to enter the name of a <A HREF="sponsor.html#register">register</A>.
The text is inserted <A HREF="motion.html#as">as</A> if you typed <A HREF="motion.html#it">it</A>, but mappings and
<A HREF="map.html#abbreviations">abbreviations</A> are not used. If you have <A HREF="options.html#options">options</A> like
<A HREF="options.html#'textwidth'">'textwidth'</A>, <A HREF="options.html#'formatoptions'">'formatoptions'</A>, or <A HREF="options.html#'autoindent'">'autoindent'</A> set, this will
influence what will be inserted. This is different from what
happens with the "<A HREF="change.html#p">p</A>" command and pasting with the mouse.
<A HREF="eval.html#Special">Special</A> <A HREF="change.html#registers">registers</A>:
'"'' the unnamed <A HREF="sponsor.html#register">register</A>, containing the text of
the last delete or <A HREF="change.html#yank">yank</A>
'<A HREF="motion.html#%">%</A>' the current file name
'<A HREF="pattern.html##">#</A>' the alternate file name
'*' the <A HREF="gui.html#clipboard">clipboard</A> contents (X11: primary selection)
'<A HREF="motion.html#+">+</A>' the <A HREF="gui.html#clipboard">clipboard</A> contents
'<A HREF="pattern.html#/">/</A>' the last search <A HREF="pattern.html#pattern">pattern</A>
'<A HREF="cmdline.html#:">:</A>' the last command-line
'<A HREF="repeat.html#.">.</A>' the last inserted text
'<A HREF="motion.html#-">-</A>' the last small (less than a line) delete
*<A NAME="i_CTRL-R_="></A><B>i_CTRL-R_=</B>*
'<A HREF="change.html#=">=</A>' the <A HREF="eval.html#expression">expression</A> <A HREF="sponsor.html#register">register</A>: you are prompted to
enter an expression (see |<A HREF="eval.html#expression">expression</A>|)
Note that 0x80 (128 decimal) is used for
special keys. E.g., you can use this to move
the cursor up:
<A HREF="undo.html#CTRL-R">CTRL-R</A> ="\<Up>"
Use <A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="undo.html#CTRL-R">CTRL-R</A> to insert text literally.
When the result is a |<A HREF="eval.html#List">List</A>| the items are used
<A HREF="motion.html#as">as</A> lines. They can have line breaks inside
too.
When the result is a <A HREF="eval.html#Float">Float</A> it's automatically
converted to a <A HREF="eval.html#String">String</A>.
When <A HREF="eval.html#append()">append()</A> or <A HREF="eval.html#setline()">setline()</A> is invoked the <A HREF="undo.html#undo">undo</A>
sequence will be broken.
See |<A HREF="change.html#registers">registers</A>| about registers. {not in Vi}
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="undo.html#CTRL-R">CTRL-R</A> {0-9a-z"%#*+/:.-=} *<A NAME="i_CTRL-R_CTRL-R"></A><B>i_CTRL-R_CTRL-R</B>*
<A HREF="#Insert">Insert</A> the contents of a <A HREF="sponsor.html#register">register</A>. Works like using a single
<A HREF="undo.html#CTRL-R">CTRL-R</A>, but the text is inserted literally, not <A HREF="motion.html#as">as</A> if typed.
This differs when the <A HREF="sponsor.html#register">register</A> contains characters like <A HREF="motion.html#<BS>"><BS></A>.
Example, where <A HREF="sponsor.html#register">register</A> a contains "ab^Hc":
<B> CTRL-R a results in "ac".</B>
<B> CTRL-R CTRL-R a results in "ab^Hc".</B>
Options <A HREF="options.html#'textwidth'">'textwidth'</A>, <A HREF="options.html#'formatoptions'">'formatoptions'</A>, etc. still apply. If
you also want to avoid these, use <A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="motion.html#CTRL-O">CTRL-O</A>, see below.
The '<A HREF="repeat.html#.">.</A>' <A HREF="sponsor.html#register">register</A> (last inserted text) is still inserted <A HREF="motion.html#as">as</A>
typed. {not in Vi}
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> {0-9a-z"%#*+/:.-=} *<A NAME="i_CTRL-R_CTRL-O"></A><B>i_CTRL-R_CTRL-O</B>*
<A HREF="#Insert">Insert</A> the contents of a <A HREF="sponsor.html#register">register</A> literally and don't
auto-indent. Does the same <A HREF="motion.html#as">as</A> pasting with the mouse
|<A HREF="change.html#<MiddleMouse>"><MiddleMouse></A>|. When the <A HREF="sponsor.html#register">register</A> is <A HREF="motion.html#linewise">linewise</A> this will
insert the text above the current line, like with `P`.
Does not replace characters!
The '<A HREF="repeat.html#.">.</A>' <A HREF="sponsor.html#register">register</A> (last inserted text) is still inserted <A HREF="motion.html#as">as</A>
typed. {not in Vi}
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> {0-9a-z"%#*+/:.-=} *<A NAME="i_CTRL-R_CTRL-P"></A><B>i_CTRL-R_CTRL-P</B>*
<A HREF="#Insert">Insert</A> the contents of a <A HREF="sponsor.html#register">register</A> literally and fix the
indent, like |<A HREF="change.html#[<MiddleMouse>">[<MiddleMouse></A>|.
Does not replace characters!
The '<A HREF="repeat.html#.">.</A>' <A HREF="sponsor.html#register">register</A> (last inserted text) is still inserted <A HREF="motion.html#as">as</A>
typed. {not in Vi}
*<A NAME="i_CTRL-T"></A><B>i_CTRL-T</B>*
<A HREF="tagsrch.html#CTRL-T">CTRL-T</A> <A HREF="#Insert">Insert</A> one shiftwidth of indent at the start of the current
line. The indent is always rounded to a <A HREF="options.html#'shiftwidth'">'shiftwidth'</A> (this is
<A HREF="intro.html#vi">vi</A> compatible). {Vi: only when in indent}
*<A NAME="i_CTRL-D"></A><B>i_CTRL-D</B>*
<A HREF="scroll.html#CTRL-D">CTRL-D</A> Delete one shiftwidth of indent at the start of the current
line. The indent is always rounded to a <A HREF="options.html#'shiftwidth'">'shiftwidth'</A> (this is
<A HREF="intro.html#vi">vi</A> compatible). {Vi: <A HREF="scroll.html#CTRL-D">CTRL-D</A> works only when used after
autoindent}
*<A NAME="i_0_CTRL-D"></A><B>i_0_CTRL-D</B>*
0 <A HREF="scroll.html#CTRL-D">CTRL-D</A> Delete all indent in the current line. {Vi: <A HREF="scroll.html#CTRL-D">CTRL-D</A> works
only when used after autoindent}
*<A NAME="i_^_CTRL-D"></A><B>i_^_CTRL-D</B>*
^ <A HREF="scroll.html#CTRL-D">CTRL-D</A> Delete all indent in the current line. The indent is
restored in the next line. This is useful when <A HREF="#inserting">inserting</A> a
label. {Vi: <A HREF="scroll.html#CTRL-D">CTRL-D</A> works only when used after autoindent}
*<A NAME="i_CTRL-V"></A><B>i_CTRL-V</B>*
<A HREF="visual.html#CTRL-V">CTRL-V</A> <A HREF="#Insert">Insert</A> next non-digit literally. For special keys, the
<A HREF="terminal.html#terminal">terminal</A> code is inserted. It's also possible to enter the
decimal, <A HREF="eval.html#octal">octal</A> or hexadecimal value of a character
|<A HREF="#i_CTRL-V_digit">i_CTRL-V_digit</A>|.
The characters typed right after <A HREF="visual.html#CTRL-V">CTRL-V</A> are not considered for
<A HREF="map.html#mapping">mapping</A>. {Vi: no decimal byte entry}
Note: When <A HREF="visual.html#CTRL-V">CTRL-V</A> is mapped (e.g., to paste text) you can
often use CTRL-Q instead |<A HREF="#i_CTRL-Q">i_CTRL-Q</A>|.
*<A NAME="i_CTRL-Q"></A><B>i_CTRL-Q</B>*
<A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A> Same <A HREF="motion.html#as">as</A> <A HREF="visual.html#CTRL-V">CTRL-V</A>.
Note: Some <A HREF="terminal.html#terminal">terminal</A> connections may eat <A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A>, <A HREF="motion.html#it">it</A> doesn't
work then. It does work in the <A HREF="gui.html#GUI">GUI</A>.
<A HREF="change.html#CTRL-X">CTRL-X</A> Enter <A HREF="change.html#CTRL-X">CTRL-X</A> mode. This is a sub-mode where commands can
be given to complete words or scroll the <A HREF="windows.html#window">window</A>. See
|<A HREF="#i_CTRL-X">i_CTRL-X</A>| and |<A HREF="#ins-completion">ins-completion</A>|. {not in Vi}
*<A NAME="i_CTRL-E"></A><B>i_CTRL-E</B>*
<A HREF="scroll.html#CTRL-E">CTRL-E</A> <A HREF="#Insert">Insert</A> the character which is below the cursor. {not in Vi}
*<A NAME="i_CTRL-Y"></A><B>i_CTRL-Y</B>*
<A HREF="scroll.html#CTRL-Y">CTRL-Y</A> <A HREF="#Insert">Insert</A> the character which is above the cursor. {not in Vi}
Note that for <A HREF="scroll.html#CTRL-E">CTRL-E</A> and <A HREF="scroll.html#CTRL-Y">CTRL-Y</A> <A HREF="options.html#'textwidth'">'textwidth'</A> is not used, to be
able to copy characters from a long line.
*<A NAME="i_CTRL-_"></A><B>i_CTRL-_</B>*
CTRL-_ Switch between languages, <A HREF="motion.html#as">as</A> follows:
- When in a rightleft <A HREF="windows.html#window">window</A>, revins and nohkmap are toggled,
since English will likely be inserted in this <A HREF="change.html#case">case</A>.
- When in a norightleft <A HREF="windows.html#window">window</A>, revins and hkmap are toggled,
since Hebrew will likely be inserted in this <A HREF="change.html#case">case</A>.
CTRL-_ moves the cursor to the end of the typed text.
This command is only available when the <A HREF="options.html#'allowrevins'">'allowrevins'</A> option
is set.
Please refer to |<A HREF="rileft.html">rileft.txt</A>| for more information about
right-to-left mode.
{not in Vi}
Only if compiled with the |<A HREF="various.html#+rightleft">+rightleft</A>| feature.
*<A NAME="i_CTRL-^"></A><B>i_CTRL-^</B>*
<A HREF="editing.html#CTRL-^">CTRL-^</A> Toggle the use of typing language characters.
When language |<A HREF="map.html#:lmap">:lmap</A>| mappings are defined:
- If <A HREF="options.html#'iminsert'">'iminsert'</A> is 1 (langmap mappings used) <A HREF="motion.html#it">it</A> becomes 0 (no
langmap mappings used).
- If <A HREF="options.html#'iminsert'">'iminsert'</A> has another value <A HREF="motion.html#it">it</A> becomes 1, thus langmap
mappings are enabled.
When no language mappings are defined:
- If <A HREF="options.html#'iminsert'">'iminsert'</A> is 2 (Input Method used) <A HREF="motion.html#it">it</A> becomes 0 (no
Input Method used).
- If <A HREF="options.html#'iminsert'">'iminsert'</A> has another value <A HREF="motion.html#it">it</A> becomes 2, thus the Input
Method is enabled.
When set to 1, the value of the "b:keymap_name" variable, the
<A HREF="options.html#'keymap'">'keymap'</A> option or "<lang>" appears in the status line.
The language mappings are normally used to type characters
that are different from what the keyboard produces. The
<A HREF="options.html#'keymap'">'keymap'</A> option can be used to <A HREF="usr_90.html#install">install</A> a whole number of them.
{not in Vi}
*<A NAME="i_CTRL-]"></A><B>i_CTRL-]</B>*
<A HREF="tagsrch.html#CTRL-]">CTRL-]</A> Trigger abbreviation, without <A HREF="#inserting">inserting</A> a character. {not in
Vi}
*<A NAME="i_<Insert>"></A><B>i_<Insert></B>*
<A HREF="#<Insert>"><Insert></A> Toggle between <A HREF="#Insert">Insert</A> and <A HREF="#Replace">Replace</A> mode. {not in Vi}
*<A NAME="i_backspacing"></A><B>i_backspacing</B>*
The effect of the <A HREF="motion.html#<BS>"><BS></A>, <A HREF="index.html#CTRL-W">CTRL-W</A>, and <A HREF="scroll.html#CTRL-U">CTRL-U</A> depend on the <A HREF="options.html#'backspace'">'backspace'</A> option
(unless <A HREF="options.html#'revins'">'revins'</A> is set). This is a comma separated <A HREF="eval.html#list">list</A> of items:
<B><FONT COLOR="PURPLE">item action </FONT></B>
indent allow backspacing over autoindent
eol allow backspacing over end-of-line (join lines)
start allow backspacing over the start position of insert; <A HREF="index.html#CTRL-W">CTRL-W</A> and
<A HREF="scroll.html#CTRL-U">CTRL-U</A> stop once at the start position
When <A HREF="options.html#'backspace'">'backspace'</A> is empty, <A HREF="intro.html#Vi">Vi</A> compatible backspacing is used. You cannot
backspace over autoindent, before column 1 or before where insert started.
For backwards compatibility the values "<A HREF="motion.html#0">0</A>", "1" and "2" are also allowed, see
|<A HREF="options.html#'backspace'">'backspace'</A>|.
If the <A HREF="options.html#'backspace'">'backspace'</A> option does contain "eol" and the cursor is in column 1
when one of the three keys is used, the current line is joined with the
previous line. This effectively deletes the <A HREF="intro.html#<EOL>"><EOL></A> in front of the cursor.
{Vi: does not cross lines, does not delete past start position of insert}
*<A NAME="i_CTRL-V_digit"></A><B>i_CTRL-V_digit</B>*
With <A HREF="visual.html#CTRL-V">CTRL-V</A> the decimal, <A HREF="eval.html#octal">octal</A> or hexadecimal value of a character can be
entered directly. This way you can enter any character, except a line break
(<NL>, value 10). There are five ways to enter the character value:
<B><FONT COLOR="PURPLE">first char mode max nr of chars max value </FONT></B>
(none) decimal 3 255
<A HREF="#o">o</A> or <A HREF="#O">O</A> <A HREF="eval.html#octal">octal</A> 3 377 (255)
<A HREF="change.html#x">x</A> or X hexadecimal 2 ff (255)
<A HREF="undo.html#u">u</A> hexadecimal 4 ffff (65535)
<A HREF="undo.html#U">U</A> hexadecimal 8 7fffffff (2147483647)
Normally you would type the maximum number of characters. Thus to enter a
space (value 32) you would type <C-V>032. You can omit the leading zero, in
which <A HREF="change.html#case">case</A> the character typed after the number must be a non-digit. This
happens for the other modes <A HREF="motion.html#as">as</A> well: As soon <A HREF="motion.html#as">as</A> you type a character that is
invalid for the mode, the value before <A HREF="motion.html#it">it</A> will be used and the "invalid"
character is dealt with in the normal way.
If you enter a value of 10, <A HREF="motion.html#it">it</A> will end up in the file <A HREF="motion.html#as">as</A> a 0. The 10 is a
<A HREF="motion.html#<NL>"><NL></A>, which is used internally to represent the <A HREF="intro.html#<Nul>"><Nul></A> character. When <A HREF="editing.html#writing">writing</A>
the buffer to a file, the <A HREF="motion.html#<NL>"><NL></A> character is translated into <A HREF="intro.html#<Nul>"><Nul></A>. The <A HREF="motion.html#<NL>"><NL></A>
character is written at the end of each line. Thus if you want to insert a
<A HREF="motion.html#<NL>"><NL></A> character in a file you will have to make a line break.
*<A NAME="i_CTRL-X"></A><B>i_CTRL-X</B>* *<A NAME="insert_expand"></A><B>insert_expand</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> enters a sub-mode where several commands can be used. Most of these
commands <A HREF="diff.html#do">do</A> keyword completion; see |<A HREF="#ins-completion">ins-completion</A>|. These are not available
when Vim was compiled without the |<A HREF="various.html#+insert_expand">+insert_expand</A>| feature.
Two commands can be used to scroll the <A HREF="windows.html#window">window</A> up or down, without <A HREF="starting.html#exiting">exiting</A>
insert mode:
*<A NAME="i_CTRL-X_CTRL-E"></A><B>i_CTRL-X_CTRL-E</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="scroll.html#CTRL-E">CTRL-E</A> scroll <A HREF="windows.html#window">window</A> one line up.
When doing completion look here: |<A HREF="#complete_CTRL-E">complete_CTRL-E</A>|
*<A NAME="i_CTRL-X_CTRL-Y"></A><B>i_CTRL-X_CTRL-Y</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="scroll.html#CTRL-Y">CTRL-Y</A> scroll <A HREF="windows.html#window">window</A> one line down.
When doing completion look here: |<A HREF="#complete_CTRL-Y">complete_CTRL-Y</A>|
After <A HREF="change.html#CTRL-X">CTRL-X</A> is pressed, each <A HREF="scroll.html#CTRL-E">CTRL-E</A> (CTRL-Y) scrolls the <A HREF="windows.html#window">window</A> up (down) by
one line unless that would cause the cursor to move from its current position
in the file. As soon <A HREF="motion.html#as">as</A> another key is pressed, <A HREF="change.html#CTRL-X">CTRL-X</A> mode is exited and
that key is interpreted <A HREF="motion.html#as">as</A> in <A HREF="#Insert">Insert</A> mode.
==============================================================================
2. <A HREF="eval.html#Special">Special</A> special keys *<A NAME="ins-special-special"></A><B>ins-special-special</B>*
The following keys are special. They stop the current insert, <A HREF="diff.html#do">do</A> something,
and then restart insertion. This means you can <A HREF="diff.html#do">do</A> something without getting
out of <A HREF="#Insert">Insert</A> mode. This is very handy if you prefer to use the <A HREF="#Insert">Insert</A> mode
all the time, just like editors that don't have a separate <A HREF="intro.html#Normal">Normal</A> mode. You
may also want to set the <A HREF="options.html#'backspace'">'backspace'</A> option to "indent,eol,start" and set the
<A HREF="options.html#'insertmode'">'insertmode'</A> option. You can use <A HREF="motion.html#CTRL-O">CTRL-O</A> if you want to map a function key to
a command.
The changes (inserted or deleted characters) before and after these keys can
be undone separately. Only the last change can be redone and always behaves
like an "<A HREF="#i">i</A>" command.
<B><FONT COLOR="PURPLE">char action </FONT></B>
<A HREF="motion.html#<Up>"><Up></A> cursor one line up *<A NAME="i_<Up>"></A><B>i_<Up></B>*
<A HREF="motion.html#<Down>"><Down></A> cursor one line down *<A NAME="i_<Down>"></A><B>i_<Down></B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="motion.html#<Up>"><Up></A> cursor one line up, insert start column *<A NAME="i_CTRL-G_<Up>"></A><B>i_CTRL-G_<Up></B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="motion.html#k">k</A> cursor one line up, insert start column *<A NAME="i_CTRL-G_k"></A><B>i_CTRL-G_k</B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> CTRL-K cursor one line up, insert start column *<A NAME="i_CTRL-G_CTRL-K"></A><B>i_CTRL-G_CTRL-K</B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="motion.html#<Down>"><Down></A> cursor one line down, insert start column *<A NAME="i_CTRL-G_<Down>"></A><B>i_CTRL-G_<Down></B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="motion.html#j">j</A> cursor one line down, insert start column *<A NAME="i_CTRL-G_j"></A><B>i_CTRL-G_j</B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="motion.html#CTRL-J">CTRL-J</A> cursor one line down, insert start column *<A NAME="i_CTRL-G_CTRL-J"></A><B>i_CTRL-G_CTRL-J</B>*
<A HREF="motion.html#<Left>"><Left></A> cursor one character left *<A NAME="i_<Left>"></A><B>i_<Left></B>*
<A HREF="motion.html#<Right>"><Right></A> cursor one character right *<A NAME="i_<Right>"></A><B>i_<Right></B>*
<A HREF="motion.html#<S-Left>"><S-Left></A> cursor one <A HREF="motion.html#word">word</A> back (like "<A HREF="motion.html#b">b</A>" command) *<A NAME="i_<S-Left>"></A><B>i_<S-Left></B>*
<A HREF="motion.html#<C-Left>"><C-Left></A> cursor one <A HREF="motion.html#word">word</A> back (like "<A HREF="motion.html#b">b</A>" command) *<A NAME="i_<C-Left>"></A><B>i_<C-Left></B>*
<A HREF="motion.html#<S-Right>"><S-Right></A> cursor one <A HREF="motion.html#word">word</A> forward (like "<A HREF="motion.html#w">w</A>" command) *<A NAME="i_<S-Right>"></A><B>i_<S-Right></B>*
<A HREF="motion.html#<C-Right>"><C-Right></A> cursor one <A HREF="motion.html#word">word</A> forward (like "<A HREF="motion.html#w">w</A>" command) *<A NAME="i_<C-Right>"></A><B>i_<C-Right></B>*
<A HREF="motion.html#<Home>"><Home></A> cursor to first char in the line *<A NAME="i_<Home>"></A><B>i_<Home></B>*
<A HREF="motion.html#<End>"><End></A> cursor to after last char in the line *<A NAME="i_<End>"></A><B>i_<End></B>*
<A HREF="motion.html#<C-Home>"><C-Home></A> cursor to first char in the file *<A NAME="i_<C-Home>"></A><B>i_<C-Home></B>*
<A HREF="motion.html#<C-End>"><C-End></A> cursor to after last char in the file *<A NAME="i_<C-End>"></A><B>i_<C-End></B>*
<A HREF="visual.html#<LeftMouse>"><LeftMouse></A> cursor to position of mouse click *<A NAME="i_<LeftMouse>"></A><B>i_<LeftMouse></B>*
<A HREF="scroll.html#<S-Up>"><S-Up></A> move <A HREF="windows.html#window">window</A> one page up *<A NAME="i_<S-Up>"></A><B>i_<S-Up></B>*
<A HREF="scroll.html#<PageUp>"><PageUp></A> move <A HREF="windows.html#window">window</A> one page up *<A NAME="i_<PageUp>"></A><B>i_<PageUp></B>*
<A HREF="scroll.html#<S-Down>"><S-Down></A> move <A HREF="windows.html#window">window</A> one page down *<A NAME="i_<S-Down>"></A><B>i_<S-Down></B>*
<A HREF="scroll.html#<PageDown>"><PageDown></A> move <A HREF="windows.html#window">window</A> one page down *<A NAME="i_<PageDown>"></A><B>i_<PageDown></B>*
<A HREF="scroll.html#<ScrollWheelDown>"><ScrollWheelDown></A> move <A HREF="windows.html#window">window</A> three lines down *<A NAME="i_<ScrollWheelDown>"></A><B>i_<ScrollWheelDown></B>*
<A HREF="scroll.html#<S-ScrollWheelDown>"><S-ScrollWheelDown></A> move <A HREF="windows.html#window">window</A> one page down *<A NAME="i_<S-ScrollWheelDown>"></A><B>i_<S-ScrollWheelDown></B>*
<A HREF="scroll.html#<ScrollWheelUp>"><ScrollWheelUp></A> move <A HREF="windows.html#window">window</A> three lines up *<A NAME="i_<ScrollWheelUp>"></A><B>i_<ScrollWheelUp></B>*
<A HREF="scroll.html#<S-ScrollWheelUp>"><S-ScrollWheelUp></A> move <A HREF="windows.html#window">window</A> one page up *<A NAME="i_<S-ScrollWheelUp>"></A><B>i_<S-ScrollWheelUp></B>*
<A HREF="scroll.html#<ScrollWheelLeft>"><ScrollWheelLeft></A> move <A HREF="windows.html#window">window</A> six columns left *<A NAME="i_<ScrollWheelLeft>"></A><B>i_<ScrollWheelLeft></B>*
<A HREF="scroll.html#<S-ScrollWheelLeft>"><S-ScrollWheelLeft></A> move <A HREF="windows.html#window">window</A> one page left *<A NAME="i_<S-ScrollWheelLeft>"></A><B>i_<S-ScrollWheelLeft></B>*
<A HREF="scroll.html#<ScrollWheelRight>"><ScrollWheelRight></A> move <A HREF="windows.html#window">window</A> six columns right *<A NAME="i_<ScrollWheelRight>"></A><B>i_<ScrollWheelRight></B>*
<A HREF="scroll.html#<S-ScrollWheelRight>"><S-ScrollWheelRight></A> move <A HREF="windows.html#window">window</A> one page right *<A NAME="i_<S-ScrollWheelRight>"></A><B>i_<S-ScrollWheelRight></B>*
<A HREF="motion.html#CTRL-O">CTRL-O</A> execute one command, return to <A HREF="#Insert">Insert</A> mode *<A NAME="i_CTRL-O"></A><B>i_CTRL-O</B>*
CTRL-\ <A HREF="motion.html#CTRL-O">CTRL-O</A> like <A HREF="motion.html#CTRL-O">CTRL-O</A> but don't move the cursor *<A NAME="i_CTRL-\_CTRL-O"></A><B>i_CTRL-\_CTRL-O</B>*
<A HREF="various.html#CTRL-L">CTRL-L</A> when <A HREF="options.html#'insertmode'">'insertmode'</A> is set: go to <A HREF="intro.html#Normal">Normal</A> mode *<A NAME="i_CTRL-L"></A><B>i_CTRL-L</B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="undo.html#u">u</A> break <A HREF="undo.html#undo">undo</A> sequence, start new change *<A NAME="i_CTRL-G_u"></A><B>i_CTRL-G_u</B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="undo.html#U">U</A> don't break <A HREF="undo.html#undo">undo</A> with next left/right cursor *<A NAME="i_CTRL-G_U"></A><B>i_CTRL-G_U</B>*
<A HREF="intro.html#movement">movement</A> (but only if the cursor stays
within same the line)
Note: If the cursor keys take you out of <A HREF="#Insert">Insert</A> mode, check the <A HREF="options.html#'noesckeys'">'noesckeys'</A>
option.
The <A HREF="motion.html#CTRL-O">CTRL-O</A> command sometimes has a side effect: If the cursor was beyond the
end of the line, <A HREF="motion.html#it">it</A> will be put on the last character in the line. In
mappings it's often better to use <A HREF="intro.html#<Esc>"><Esc></A> (first put an "<A HREF="change.html#x">x</A>" in the text, <A HREF="intro.html#<Esc>"><Esc></A>
will then always put the cursor on <A HREF="motion.html#it">it</A>). Or use CTRL-\ <A HREF="motion.html#CTRL-O">CTRL-O</A>, but then
beware of the cursor possibly being beyond the end of the line. Note that the
command following CTRL-\ <A HREF="motion.html#CTRL-O">CTRL-O</A> can still move the cursor, <A HREF="motion.html#it">it</A> is not restored
to its original position.
The <A HREF="motion.html#CTRL-O">CTRL-O</A> command takes you to <A HREF="intro.html#Normal">Normal</A> mode. If you then use a command enter
<A HREF="#Insert">Insert</A> mode again <A HREF="motion.html#it">it</A> normally doesn't nest. Thus when typing "a<C-O>a" and
then <A HREF="intro.html#<Esc>"><Esc></A> takes you back to <A HREF="intro.html#Normal">Normal</A> mode, you <A HREF="diff.html#do">do</A> not need to type <A HREF="intro.html#<Esc>"><Esc></A> <A HREF="if_cscop.html#twice">twice</A>.
An exception is when not typing the command, e.g. when executing a <A HREF="map.html#mapping">mapping</A> or
sourcing a <A HREF="usr_41.html#script">script</A>. This makes mappings work that briefly switch to <A HREF="#Insert">Insert</A>
mode.
The shifted cursor keys are not available on all terminals.
Another side effect is that a <A HREF="intro.html#count">count</A> specified before the "<A HREF="#i">i</A>" or "<A HREF="#a">a</A>" command is
ignored. That is because <A HREF="repeat.html#repeating">repeating</A> the effect of the command after <A HREF="motion.html#CTRL-O">CTRL-O</A> is
too complicated.
An example for using <A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="undo.html#u">u</A>:
<B> :inoremap <C-H> <C-G>u<C-H></B>
This redefines the backspace key to start a new <A HREF="undo.html#undo">undo</A> sequence. You can now
<A HREF="undo.html#undo">undo</A> the effect of the backspace key, without <A HREF="change.html#changing">changing</A> what you typed before
that, with <A HREF="motion.html#CTRL-O">CTRL-O</A> <A HREF="undo.html#u">u</A>. Another example:
<B> :inoremap <CR> <C-]><C-G>u<CR></B>
This breaks <A HREF="undo.html#undo">undo</A> at each line break. It also expands <A HREF="map.html#abbreviations">abbreviations</A> before
this.
An example for using <A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="undo.html#U">U</A>:
<B> inoremap <Left> <C-G>U<Left></B>
<B> inoremap <Right> <C-G>U<Right></B>
<B> inoremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ?</B>
<B> \ repeat('<C-G>U<Left>', col('.') - 1) :</B>
<B> \ (col('.') < match(getline('.'), '\S') ?</B>
<B> \ repeat('<C-G>U<Right>', match(getline('.'), '\S') + 0) :</B>
<B> \ repeat('<C-G>U<Left>', col('.') - 1 - match(getline('.'), '\S')))</B>
<B> inoremap <expr> <End> repeat('<C-G>U<Right>', col('$') - col('.'))</B>
<B> inoremap ( ()<C-G>U<Left></B>
This makes <A HREF="motion.html#it">it</A> possible to use the cursor keys in <A HREF="#Insert">Insert</A> mode, without breaking
the <A HREF="undo.html#undo">undo</A> sequence and therefore using |<A HREF="repeat.html#.">.</A>| (redo) will work <A HREF="motion.html#as">as</A> expected.
Also entering a text like (with the "<A HREF="motion.html#(">(</A>" <A HREF="map.html#mapping">mapping</A> from above):
<B> Lorem ipsum (dolor</B>
will be repeatable by the |.|to the expected
Lorem ipsum (dolor)
Using <A HREF="motion.html#CTRL-O">CTRL-O</A> splits <A HREF="undo.html#undo">undo</A>: the text typed before and after <A HREF="motion.html#it">it</A> is undone
separately. If you want to avoid this (e.g., in a <A HREF="map.html#mapping">mapping</A>) you might be able
to use CTRL-R = |<A HREF="#i_CTRL-R">i_CTRL-R</A>|. E.g., to call a function:
<B> :imap <F2> <C-R>=MyFunc()<CR></B>
When the <A HREF="options.html#'whichwrap'">'whichwrap'</A> option is set appropriately, the <A HREF="motion.html#<Left>"><Left></A> and <A HREF="motion.html#<Right>"><Right></A>
keys on the first/last character in the line make the cursor wrap to the
previous/next line.
The <A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="motion.html#j">j</A> and <A HREF="editing.html#CTRL-G">CTRL-G</A> <A HREF="motion.html#k">k</A> commands can be used to insert text in front of a
column. Example:
<B> int i;</B>
<B> int j;</B>
Position the cursor on the first "int", type "istatic <C-G>j ". The
result is:
<B> static int i;</B>
<B> int j;</B>
When <A HREF="#inserting">inserting</A> the same text in front of the column in every line, use the
<A HREF="visual.html#Visual">Visual</A> blockwise command "I" |<A HREF="visual.html#v_b_I">v_b_I</A>|.
==============================================================================
3. <A HREF="options.html#'textwidth'">'textwidth'</A> and <A HREF="options.html#'wrapmargin'">'wrapmargin'</A> <A HREF="options.html#options">options</A> *<A NAME="ins-textwidth"></A><B>ins-textwidth</B>*
The <A HREF="options.html#'textwidth'">'textwidth'</A> option can be used to automatically break a line before <A HREF="motion.html#it">it</A>
gets too long. Set the <A HREF="options.html#'textwidth'">'textwidth'</A> option to the desired maximum line
length. If you then type more characters (not spaces or tabs), the
last <A HREF="motion.html#word">word</A> will be put on a new line (unless <A HREF="motion.html#it">it</A> is the only <A HREF="motion.html#word">word</A> on the
line). If you set <A HREF="options.html#'textwidth'">'textwidth'</A> to 0, this feature is disabled.
The <A HREF="options.html#'wrapmargin'">'wrapmargin'</A> option does almost the same. The difference is that
<A HREF="options.html#'textwidth'">'textwidth'</A> has a fixed width while <A HREF="options.html#'wrapmargin'">'wrapmargin'</A> depends on the width of the
screen. When using <A HREF="options.html#'wrapmargin'">'wrapmargin'</A> this is equal to using <A HREF="options.html#'textwidth'">'textwidth'</A> with a
value equal to (columns - 'wrapmargin'), where columns is the width of the
screen.
When <A HREF="options.html#'textwidth'">'textwidth'</A> and <A HREF="options.html#'wrapmargin'">'wrapmargin'</A> are both set, <A HREF="options.html#'textwidth'">'textwidth'</A> is used.
If you don't really want to break the line, but <A HREF="starting.html#view">view</A> the line wrapped at a
convenient place, see the <A HREF="options.html#'linebreak'">'linebreak'</A> option.
The line is only broken automatically when using <A HREF="#Insert">Insert</A> mode, or when
appending to a line. When in replace mode and the line length is not
changed, the line will not be broken.
Long lines are broken if you enter a non-white character after the margin.
The situations where a line will be broken can be restricted by adding
characters to the <A HREF="options.html#'formatoptions'">'formatoptions'</A> option:
"<A HREF="motion.html#l">l</A>" Only break a line if <A HREF="motion.html#it">it</A> was not longer than <A HREF="options.html#'textwidth'">'textwidth'</A> when the insert
started.
"<A HREF="visual.html#v">v</A>" Only break at a white character that has been entered during the
current insert command. This is mostly Vi-compatible.
"lv" Only break if the line was not longer than <A HREF="options.html#'textwidth'">'textwidth'</A> when the insert
started and only at a white character that has been entered during the
current insert command. Only differs from "<A HREF="motion.html#l">l</A>" when entering non-white
characters while crossing the <A HREF="options.html#'textwidth'">'textwidth'</A> boundary.
Normally an internal function will be used to decide where to break the line.
If you want to <A HREF="diff.html#do">do</A> <A HREF="motion.html#it">it</A> in a different way set the <A HREF="options.html#'formatexpr'">'formatexpr'</A> option to an
<A HREF="eval.html#expression">expression</A> that will take care of the line break.
If you want to format a block of text, you can use the "<A HREF="change.html#gq">gq</A>" <A HREF="motion.html#operator">operator</A>. Type
"<A HREF="change.html#gq">gq</A>" and a <A HREF="intro.html#movement">movement</A> command to move the cursor to the end of the block. In
many cases, the command "gq}" will <A HREF="diff.html#do">do</A> what you want (format until the end of
<A HREF="motion.html#paragraph">paragraph</A>). Alternatively, you can use "<A HREF="change.html#gqap">gqap</A>", which will format the whole
<A HREF="motion.html#paragraph">paragraph</A>, no matter where the cursor currently is. Or you can use <A HREF="visual.html#Visual">Visual</A>
mode: hit "<A HREF="visual.html#v">v</A>", move to the end of the block, and type "gq". See also |<A HREF="change.html#gq">gq</A>|.
==============================================================================
4. <A HREF="options.html#'expandtab'">'expandtab'</A>, <A HREF="options.html#'smarttab'">'smarttab'</A> and <A HREF="options.html#'softtabstop'">'softtabstop'</A> <A HREF="options.html#options">options</A> *<A NAME="ins-expandtab"></A><B>ins-expandtab</B>*
If the <A HREF="options.html#'expandtab'">'expandtab'</A> option is on, spaces will be used to fill the amount of
<A HREF="pattern.html#whitespace">whitespace</A> of the <A HREF="intro.html#tab">tab</A>. If you want to enter a real <A HREF="motion.html#<Tab>"><Tab></A>, type <A HREF="visual.html#CTRL-V">CTRL-V</A> first
(use CTRL-Q when <A HREF="visual.html#CTRL-V">CTRL-V</A> is mapped |<A HREF="#i_CTRL-Q">i_CTRL-Q</A>|).
The <A HREF="options.html#'expandtab'">'expandtab'</A> option is off by default. Note that in <A HREF="#Replace">Replace</A> mode, a single
character is replaced with several spaces. The result of this is that the
number of characters in the line increases. Backspacing will delete one
space at a time. The original character will be put back for only one space
that you backspace over (the last one). {Vi does not have the <A HREF="options.html#'expandtab'">'expandtab'</A>
option}
*<A NAME="ins-smarttab"></A><B>ins-smarttab</B>*
When the <A HREF="options.html#'smarttab'">'smarttab'</A> option is on, a <A HREF="motion.html#<Tab>"><Tab></A> inserts <A HREF="options.html#'shiftwidth'">'shiftwidth'</A> positions at
the beginning of a line and <A HREF="options.html#'tabstop'">'tabstop'</A> positions in other places. This means
that often spaces instead of a <A HREF="motion.html#<Tab>"><Tab></A> character are inserted. When <A HREF="options.html#'smarttab'">'smarttab'</A>
is off, a <A HREF="motion.html#<Tab>"><Tab></A> always inserts <A HREF="options.html#'tabstop'">'tabstop'</A> positions, and <A HREF="options.html#'shiftwidth'">'shiftwidth'</A> is only
used for "<A HREF="change.html#>>">>></A>" and the like. {not in Vi}
*<A NAME="ins-softtabstop"></A><B>ins-softtabstop</B>*
When the <A HREF="options.html#'softtabstop'">'softtabstop'</A> option is non-zero, a <A HREF="motion.html#<Tab>"><Tab></A> inserts <A HREF="options.html#'softtabstop'">'softtabstop'</A>
positions, and a <A HREF="motion.html#<BS>"><BS></A> used to delete white space, will delete <A HREF="options.html#'softtabstop'">'softtabstop'</A>
positions. This feels like <A HREF="options.html#'tabstop'">'tabstop'</A> was set to <A HREF="options.html#'softtabstop'">'softtabstop'</A>, but a real
<A HREF="motion.html#<Tab>"><Tab></A> character still takes <A HREF="options.html#'tabstop'">'tabstop'</A> positions, so your file will still look
correct when used by other applications.
If <A HREF="options.html#'softtabstop'">'softtabstop'</A> is non-zero, a <A HREF="motion.html#<BS>"><BS></A> will try to delete <A HREF="motion.html#as">as</A> much white space to
move to the previous <A HREF="options.html#'softtabstop'">'softtabstop'</A> position, except when the previously
inserted character is a space, then <A HREF="motion.html#it">it</A> will only delete the character before
the cursor. Otherwise you cannot always delete a single character before the
cursor. You will have to delete <A HREF="options.html#'softtabstop'">'softtabstop'</A> characters first, and then type
extra spaces to get where you want to be.
==============================================================================
5. <A HREF="#Replace">Replace</A> mode *<A NAME="Replace"></A><B>Replace</B>* *<A NAME="Replace-mode"></A><B>Replace-mode</B>* *<A NAME="mode-replace"></A><B>mode-replace</B>*
Enter <A HREF="#Replace">Replace</A> mode with the "<A HREF="change.html#R">R</A>" command in normal mode.
In <A HREF="#Replace">Replace</A> mode, one character in the line is deleted for every character you
type. If there is no character to delete (at the end of the line), the
typed character is appended (as in <A HREF="#Insert">Insert</A> mode). Thus the number of
characters in a line stays the same until you get to the end of the line.
If a <A HREF="motion.html#<NL>"><NL></A> is typed, a line break is inserted and no character is deleted.
Be careful with <A HREF="motion.html#<Tab>"><Tab></A> characters. If you type a normal <A HREF="print.html#printing">printing</A> character in
its place, the number of characters is still the same, but the number of
columns will become smaller.
If you delete characters in <A HREF="#Replace">Replace</A> mode (with <A HREF="motion.html#<BS>"><BS></A>, <A HREF="index.html#CTRL-W">CTRL-W</A>, or CTRL-U), what
happens is that you delete the changes. The characters that were replaced
are restored. If you had typed past the existing text, the characters you
added are deleted. This is effectively a character-at-a-time <A HREF="undo.html#undo">undo</A>.
If the <A HREF="options.html#'expandtab'">'expandtab'</A> option is on, a <A HREF="motion.html#<Tab>"><Tab></A> will replace one character with
several spaces. The result of this is that the number of characters in the
line increases. Backspacing will delete one space at a time. The original
character will be put back for only one space that you backspace over (the
last one). {Vi does not have the <A HREF="options.html#'expandtab'">'expandtab'</A> option}
==============================================================================
6. Virtual <A HREF="#Replace">Replace</A> mode *<A NAME="vreplace-mode"></A><B>vreplace-mode</B>* *<A NAME="Virtual-Replace-mode"></A><B>Virtual-Replace-mode</B>*
Enter Virtual <A HREF="#Replace">Replace</A> mode with the "<A HREF="change.html#gR">gR</A>" command in normal mode.
{not available when compiled without the |<A HREF="various.html#+vreplace">+vreplace</A>| feature}
{Vi does not have Virtual <A HREF="#Replace">Replace</A> mode}
Virtual <A HREF="#Replace">Replace</A> mode is similar to <A HREF="#Replace">Replace</A> mode, but instead of <A HREF="change.html#replacing">replacing</A>
actual characters in the file, you are <A HREF="change.html#replacing">replacing</A> screen real estate, so that
characters further on in the file never appear to move.
So if you type a <A HREF="motion.html#<Tab>"><Tab></A> <A HREF="motion.html#it">it</A> may replace several normal characters, and if you
type a <A HREF="print.html#letter">letter</A> on top of a <A HREF="motion.html#<Tab>"><Tab></A> <A HREF="motion.html#it">it</A> may not replace anything at all, since the
<A HREF="motion.html#<Tab>"><Tab></A> will still line up to the same place <A HREF="motion.html#as">as</A> before.
Typing a <A HREF="motion.html#<NL>"><NL></A> still doesn't cause characters later in the file to appear to
move. The rest of the current line will be replaced by the <A HREF="motion.html#<NL>"><NL></A> (that is,
they are deleted), and <A HREF="change.html#replacing">replacing</A> continues on the next line. A new line is
NOT inserted unless you go past the end of the file.
Interesting effects are seen when using <A HREF="tagsrch.html#CTRL-T">CTRL-T</A> and <A HREF="scroll.html#CTRL-D">CTRL-D</A>. The characters
before the cursor are shifted sideways <A HREF="motion.html#as">as</A> normal, but characters later in the
line still remain still. <A HREF="tagsrch.html#CTRL-T">CTRL-T</A> will hide some of the old line under the
shifted characters, but <A HREF="scroll.html#CTRL-D">CTRL-D</A> will reveal them again.
As with <A HREF="#Replace">Replace</A> mode, using <A HREF="motion.html#<BS>"><BS></A> etc will bring back the characters that were
replaced. This still works in conjunction with <A HREF="options.html#'smartindent'">'smartindent'</A>, <A HREF="tagsrch.html#CTRL-T">CTRL-T</A> and
<A HREF="scroll.html#CTRL-D">CTRL-D</A>, <A HREF="options.html#'expandtab'">'expandtab'</A>, <A HREF="options.html#'smarttab'">'smarttab'</A>, <A HREF="options.html#'softtabstop'">'softtabstop'</A>, etc.
In <A HREF="options.html#'list'">'list'</A> mode, Virtual <A HREF="#Replace">Replace</A> mode acts <A HREF="motion.html#as">as</A> if <A HREF="motion.html#it">it</A> was not in <A HREF="options.html#'list'">'list'</A> mode,
unless "<A HREF="motion.html#L">L</A>" is in <A HREF="options.html#'cpoptions'">'cpoptions'</A>.
Note that the only situations for which characters beyond the cursor should
appear to move are in <A HREF="eval.html#List">List</A> mode |<A HREF="options.html#'list'">'list'</A>|, and occasionally when <A HREF="options.html#'wrap'">'wrap'</A> is set
(and the line changes length to become shorter or wider than the width of the
screen). In other cases spaces may be inserted to avoid following characters
to move.
This mode is very useful for editing <A HREF="motion.html#<Tab>"><Tab></A> separated columns in tables, for
entering new data while keeping all the columns aligned.
==============================================================================
7. <A HREF="#Insert">Insert</A> mode completion *<A NAME="ins-completion"></A><B>ins-completion</B>*
In <A HREF="#Insert">Insert</A> and <A HREF="#Replace">Replace</A> mode, there are several commands to complete part of a
keyword or line that has been typed. This is useful if you are using
complicated keywords (e.g., function names with capitals and underscores).
These commands are not available when the |<A HREF="various.html#+insert_expand">+insert_expand</A>| feature was
disabled at compile time.
Completion can be done for:
1. Whole lines |<A HREF="#i_CTRL-X_CTRL-L">i_CTRL-X_CTRL-L</A>|
2. keywords in the current file |<A HREF="#i_CTRL-X_CTRL-N">i_CTRL-X_CTRL-N</A>|
3. keywords in <A HREF="options.html#'dictionary'">'dictionary'</A> |<A HREF="#i_CTRL-X_CTRL-K">i_CTRL-X_CTRL-K</A>|
4. keywords in <A HREF="options.html#'thesaurus'">'thesaurus'</A>, thesaurus-style |<A HREF="#i_CTRL-X_CTRL-T">i_CTRL-X_CTRL-T</A>|
5. keywords in the current and included files |<A HREF="#i_CTRL-X_CTRL-I">i_CTRL-X_CTRL-I</A>|
6. <A HREF="tagsrch.html#tags">tags</A> |<A HREF="#i_CTRL-X_CTRL-]">i_CTRL-X_CTRL-]</A>|
7. file names |<A HREF="#i_CTRL-X_CTRL-F">i_CTRL-X_CTRL-F</A>|
8. <A HREF="intro.html#definitions">definitions</A> or macros |<A HREF="#i_CTRL-X_CTRL-D">i_CTRL-X_CTRL-D</A>|
9. Vim command-line |<A HREF="#i_CTRL-X_CTRL-V">i_CTRL-X_CTRL-V</A>|
10. <A HREF="autocmd.html#User">User</A> defined completion |<A HREF="#i_CTRL-X_CTRL-U">i_CTRL-X_CTRL-U</A>|
11. omni completion |<A HREF="#i_CTRL-X_CTRL-O">i_CTRL-X_CTRL-O</A>|
12. Spelling suggestions |<A HREF="#i_CTRL-X_s">i_CTRL-X_s</A>|
13. keywords in <A HREF="options.html#'complete'">'complete'</A> |<A HREF="#i_CTRL-N">i_CTRL-N</A>| |<A HREF="#i_CTRL-P">i_CTRL-P</A>|
All these, except <A HREF="motion.html#CTRL-N">CTRL-N</A> and <A HREF="motion.html#CTRL-P">CTRL-P</A>, are done in <A HREF="change.html#CTRL-X">CTRL-X</A> mode. This is a
sub-mode of <A HREF="#Insert">Insert</A> and <A HREF="#Replace">Replace</A> modes. You enter <A HREF="change.html#CTRL-X">CTRL-X</A> mode by typing <A HREF="change.html#CTRL-X">CTRL-X</A>
and one of the <A HREF="change.html#CTRL-X">CTRL-X</A> commands. You exit <A HREF="change.html#CTRL-X">CTRL-X</A> mode by typing a key that is
not a valid <A HREF="change.html#CTRL-X">CTRL-X</A> mode command. Valid keys are the <A HREF="change.html#CTRL-X">CTRL-X</A> command itself,
<A HREF="motion.html#CTRL-N">CTRL-N</A> (next), and <A HREF="motion.html#CTRL-P">CTRL-P</A> (previous).
Also see the <A HREF="options.html#'infercase'">'infercase'</A> option if you want to adjust the <A HREF="change.html#case">case</A> of the match.
*<A NAME="complete_CTRL-E"></A><B>complete_CTRL-E</B>*
When completion is active you can use <A HREF="scroll.html#CTRL-E">CTRL-E</A> to stop <A HREF="motion.html#it">it</A> and go back to the
originally typed text. The <A HREF="scroll.html#CTRL-E">CTRL-E</A> will not be inserted.
*<A NAME="complete_CTRL-Y"></A><B>complete_CTRL-Y</B>*
When the popup menu is displayed you can use <A HREF="scroll.html#CTRL-Y">CTRL-Y</A> to stop completion and
accept the currently selected entry. The <A HREF="scroll.html#CTRL-Y">CTRL-Y</A> is not inserted. Typing a
space, Enter, or some other unprintable character will leave completion mode
and insert that typed character.
When the popup menu is displayed there are a few more special keys, see
|<A HREF="#popupmenu-keys">popupmenu-keys</A>|.
Note: The keys that are valid in <A HREF="change.html#CTRL-X">CTRL-X</A> mode are not mapped. This allows for
"<A HREF="map.html#:map">:map</A> ^F ^X^F" to work (where ^F is <A HREF="scroll.html#CTRL-F">CTRL-F</A> and ^X is <A HREF="change.html#CTRL-X">CTRL-X</A>). The key that
ends <A HREF="change.html#CTRL-X">CTRL-X</A> mode (any key that is not a valid <A HREF="change.html#CTRL-X">CTRL-X</A> mode command) is mapped.
Also, when doing completion with <A HREF="options.html#'complete'">'complete'</A> mappings apply <A HREF="motion.html#as">as</A> usual.
Note: While completion is active <A HREF="#Insert">Insert</A> mode can't be used recursively.
Mappings that somehow invoke "<A HREF="various.html#:normal">:normal</A> i.." will generate an <A HREF="options.html#E523">E523</A> error.
The following mappings are suggested to make typing the completion commands
a bit easier (although they will hide other commands):
<B> :inoremap ^] ^X^]</B>
<B> :inoremap ^F ^X^F</B>
<B> :inoremap ^D ^X^D</B>
<B> :inoremap ^L ^X^L</B>
As a special <A HREF="change.html#case">case</A>, typing <A HREF="undo.html#CTRL-R">CTRL-R</A> to perform <A HREF="sponsor.html#register">register</A> insertion (see
|<A HREF="#i_CTRL-R">i_CTRL-R</A>|) will not exit <A HREF="change.html#CTRL-X">CTRL-X</A> mode. This is primarily to allow the use of
the '<A HREF="change.html#=">=</A>' <A HREF="sponsor.html#register">register</A> to call some function to determine the next operation. If
the contents of the <A HREF="sponsor.html#register">register</A> (or result of the '<A HREF="change.html#=">=</A>' <A HREF="sponsor.html#register">register</A> evaluation) are
not valid <A HREF="change.html#CTRL-X">CTRL-X</A> mode keys, then <A HREF="change.html#CTRL-X">CTRL-X</A> mode will be exited <A HREF="motion.html#as">as</A> if those keys
had been typed.
For example, the following will map <A HREF="motion.html#<Tab>"><Tab></A> to either actually insert a <A HREF="motion.html#<Tab>"><Tab></A> if
the current line is currently only <A HREF="pattern.html#whitespace">whitespace</A>, or start/continue a <A HREF="motion.html#CTRL-N">CTRL-N</A>
completion operation:
<B> function! CleverTab()</B>
<B> if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'</B>
<B> return "\<Tab>"</B>
<B> else</B>
<B> return "\<C-N>"</B>
<B> endif</B>
<B> endfunction</B>
<B> inoremap <Tab> <C-R>=CleverTab()<CR></B>
Completing whole lines *<A NAME="compl-whole-line"></A><B>compl-whole-line</B>*
*<A NAME="i_CTRL-X_CTRL-L"></A><B>i_CTRL-X_CTRL-L</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="various.html#CTRL-L">CTRL-L</A> Search backwards for a line that starts with the
same characters <A HREF="motion.html#as">as</A> those in the current line before
the cursor. Indent is ignored. The matching line is
inserted in front of the cursor.
The <A HREF="options.html#'complete'">'complete'</A> option is used to decide which <A HREF="windows.html#buffers">buffers</A>
are searched for a match. Both loaded and unloaded
<A HREF="windows.html#buffers">buffers</A> are used.
<A HREF="various.html#CTRL-L">CTRL-L</A> or
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backwards for next matching line. This line
replaces the previous matching line.
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forward for next matching line. This line
replaces the previous matching line.
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="various.html#CTRL-L">CTRL-L</A> After expanding a line you can additionally get the
line next to <A HREF="motion.html#it">it</A> by typing <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="various.html#CTRL-L">CTRL-L</A> again, unless
a double <A HREF="change.html#CTRL-X">CTRL-X</A> is used. Only works for loaded
<A HREF="windows.html#buffers">buffers</A>.
Completing keywords in current file *<A NAME="compl-current"></A><B>compl-current</B>*
*<A NAME="i_CTRL-X_CTRL-P"></A><B>i_CTRL-X_CTRL-P</B>*
*<A NAME="i_CTRL-X_CTRL-N"></A><B>i_CTRL-X_CTRL-N</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> Search forwards for words that start with the keyword
in front of the cursor. The found keyword is inserted
in front of the cursor.
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> Search backwards for words that start with the keyword
in front of the cursor. The found keyword is inserted
in front of the cursor.
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forward for next matching keyword. This
keyword replaces the previous matching keyword.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> or
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> Further use of <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> or <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> will
copy the words following the previous expansion in
other contexts unless a double <A HREF="change.html#CTRL-X">CTRL-X</A> is used.
If there is a keyword in front of the cursor (a name made out of alphabetic
characters and characters in 'iskeyword'), <A HREF="motion.html#it">it</A> is used <A HREF="motion.html#as">as</A> the search <A HREF="pattern.html#pattern">pattern</A>,
with "\<" prepended (meaning: start of a <A HREF="motion.html#word">word</A>). Otherwise "\<\k\k" is used
<A HREF="motion.html#as">as</A> search <A HREF="pattern.html#pattern">pattern</A> (start of any keyword of at least two characters).
In <A HREF="#Replace">Replace</A> mode, the number of characters that are replaced depends on the
length of the matched <A HREF="eval.html#string">string</A>. This works like typing the characters of the
matched <A HREF="eval.html#string">string</A> in <A HREF="#Replace">Replace</A> mode.
If there is not a valid keyword character before the cursor, any keyword of
at least two characters is matched.
e.g., to get:
printf("(%g, %g, %g)", vector[0], vector[1], vector[2]);
just type:
printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);
The search wraps around the end of the file, the value of <A HREF="options.html#'wrapscan'">'wrapscan'</A> is not
used here.
Multiple repeats of the same completion are skipped; thus a different match
will be inserted at each <A HREF="motion.html#CTRL-N">CTRL-N</A> and <A HREF="motion.html#CTRL-P">CTRL-P</A> (unless there is only one
matching keyword).
Single character matches are never included, <A HREF="motion.html#as">as</A> they usually just get in
the way of what you were really after.
e.g., to get:
printf("name = %s\n", name);
just type:
printf("name = %s\n", n^P);
or even:
printf("name = %s\n", ^P);
The '<A HREF="pattern.html#n">n</A>' in '\n' is skipped.
After expanding a <A HREF="motion.html#word">word</A>, you can use <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> or <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> to get the
<A HREF="motion.html#word">word</A> following the expansion in other contexts. These sequences search for
the text just expanded and further expand by getting an extra <A HREF="motion.html#word">word</A>. This is
useful if you need to repeat a sequence of complicated words. Although <A HREF="motion.html#CTRL-P">CTRL-P</A>
and <A HREF="motion.html#CTRL-N">CTRL-N</A> look just for strings of at least two characters, <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> and
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> can be used to expand words of just one character.
e.g., to get:
M&eacute;xico
you can type:
M^N^P^X^P^X^P
<A HREF="motion.html#CTRL-N">CTRL-N</A> starts the expansion and then <A HREF="motion.html#CTRL-P">CTRL-P</A> takes back the single character
"<A HREF="motion.html#M">M</A>", the next two <A HREF="change.html#CTRL-X">CTRL-X</A> CTRL-P's get the words "&eacute" and ";xico".
If the previous expansion was split, because <A HREF="motion.html#it">it</A> got longer than <A HREF="options.html#'textwidth'">'textwidth'</A>,
then just the text in the current line will be used.
If the match found is at the end of a line, then the first <A HREF="motion.html#word">word</A> in the next
line will be inserted and the message "<A HREF="motion.html#word">word</A> from next line" displayed, if
this <A HREF="motion.html#word">word</A> is accepted the next <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> or <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> will search
for those lines starting with this <A HREF="motion.html#word">word</A>.
Completing keywords in <A HREF="options.html#'dictionary'">'dictionary'</A> *<A NAME="compl-dictionary"></A><B>compl-dictionary</B>*
*<A NAME="i_CTRL-X_CTRL-K"></A><B>i_CTRL-X_CTRL-K</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> CTRL-K Search the files given with the <A HREF="options.html#'dictionary'">'dictionary'</A> option
for words that start with the keyword in front of the
cursor. This is like <A HREF="motion.html#CTRL-N">CTRL-N</A>, but only the dictionary
files are searched, not the current file. The found
keyword is inserted in front of the cursor. This
could potentially be pretty slow, since all matches
are found before the first match is used. By default,
the <A HREF="options.html#'dictionary'">'dictionary'</A> option is empty.
For suggestions where to find a <A HREF="eval.html#list">list</A> of words, see the
<A HREF="options.html#'dictionary'">'dictionary'</A> option.
CTRL-K or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forward for next matching keyword. This
keyword replaces the previous matching keyword.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.
*<A NAME="i_CTRL-X_CTRL-T"></A><B>i_CTRL-X_CTRL-T</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="tagsrch.html#CTRL-T">CTRL-T</A> Works <A HREF="motion.html#as">as</A> <A HREF="change.html#CTRL-X">CTRL-X</A> CTRL-K, but in a special way. It uses
the <A HREF="options.html#'thesaurus'">'thesaurus'</A> option instead of <A HREF="options.html#'dictionary'">'dictionary'</A>. If a
match is found in the thesaurus file, all the
remaining words on the same line are included <A HREF="motion.html#as">as</A>
matches, even though they don't complete the <A HREF="motion.html#word">word</A>.
Thus a <A HREF="motion.html#word">word</A> can be completely replaced.
For an example, imagine the <A HREF="options.html#'thesaurus'">'thesaurus'</A> file has a
line like this:
<B> angry furious mad enraged</B>
Placing the cursor after the letters "ang" and typing
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="tagsrch.html#CTRL-T">CTRL-T</A> would complete the <A HREF="motion.html#word">word</A> "angry";
subsequent presses would change the <A HREF="motion.html#word">word</A> to "furious",
"mad" etc.
Other uses include translation between two languages,
or grouping API <A HREF="eval.html#functions">functions</A> by keyword.
<A HREF="tagsrch.html#CTRL-T">CTRL-T</A> or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forward for next matching keyword. This
keyword replaces the previous matching keyword.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.
Completing keywords in the current and included files *<A NAME="compl-keyword"></A><B>compl-keyword</B>*
The <A HREF="options.html#'include'">'include'</A> option is used to specify a line that contains an include file
name. The <A HREF="options.html#'path'">'path'</A> option is used to search for include files.
*<A NAME="i_CTRL-X_CTRL-I"></A><B>i_CTRL-X_CTRL-I</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-I">CTRL-I</A> Search for the first keyword in the current and
included files that starts with the same characters
<A HREF="motion.html#as">as</A> those before the cursor. The matched keyword is
inserted in front of the cursor.
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forwards for next matching keyword. This
keyword replaces the previous matching keyword.
Note: <A HREF="motion.html#CTRL-I">CTRL-I</A> is the same <A HREF="motion.html#as">as</A> <A HREF="motion.html#<Tab>"><Tab></A>, which is likely to
be typed after a successful completion, therefore
<A HREF="motion.html#CTRL-I">CTRL-I</A> is not used for searching for the next match.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backward for previous matching keyword. This
keyword replaces the previous matching keyword.
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-I">CTRL-I</A> Further use of <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-I">CTRL-I</A> will copy the words
following the previous expansion in other contexts
unless a double <A HREF="change.html#CTRL-X">CTRL-X</A> is used.
Completing <A HREF="tagsrch.html#tags">tags</A> *<A NAME="compl-tag"></A><B>compl-tag</B>*
*<A NAME="i_CTRL-X_CTRL-]"></A><B>i_CTRL-X_CTRL-]</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="tagsrch.html#CTRL-]">CTRL-]</A> Search for the first <A HREF="tagsrch.html#tag">tag</A> that starts with the same
characters <A HREF="motion.html#as">as</A> before the cursor. The matching <A HREF="tagsrch.html#tag">tag</A> is
inserted in front of the cursor. Alphabetic
characters and characters in <A HREF="options.html#'iskeyword'">'iskeyword'</A> are used
to decide which characters are included in the <A HREF="tagsrch.html#tag">tag</A>
name (same <A HREF="motion.html#as">as</A> for a keyword). See also |<A HREF="tagsrch.html#CTRL-]">CTRL-]</A>|.
The <A HREF="options.html#'showfulltag'">'showfulltag'</A> option can be used to add context
from around the <A HREF="tagsrch.html#tag">tag</A> definition.
<A HREF="tagsrch.html#CTRL-]">CTRL-]</A> or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forwards for next matching <A HREF="tagsrch.html#tag">tag</A>. This <A HREF="tagsrch.html#tag">tag</A>
replaces the previous matching <A HREF="tagsrch.html#tag">tag</A>.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backward for previous matching <A HREF="tagsrch.html#tag">tag</A>. This <A HREF="tagsrch.html#tag">tag</A>
replaces the previous matching <A HREF="tagsrch.html#tag">tag</A>.
Completing file names *<A NAME="compl-filename"></A><B>compl-filename</B>*
*<A NAME="i_CTRL-X_CTRL-F"></A><B>i_CTRL-X_CTRL-F</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="scroll.html#CTRL-F">CTRL-F</A> Search for the first file name that starts with the
same characters <A HREF="motion.html#as">as</A> before the cursor. The matching
file name is inserted in front of the cursor.
Alphabetic characters and characters in <A HREF="options.html#'isfname'">'isfname'</A>
are used to decide which characters are included in
the file name. Note: the <A HREF="options.html#'path'">'path'</A> option is not used
here (yet).
<A HREF="scroll.html#CTRL-F">CTRL-F</A> or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forwards for next matching file name. This
file name replaces the previous matching file name.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backward for previous matching file name.
This file name replaces the previous matching file
name.
Completing <A HREF="intro.html#definitions">definitions</A> or macros *<A NAME="compl-define"></A><B>compl-define</B>*
The <A HREF="options.html#'define'">'define'</A> option is used to specify a line that contains a definition.
The <A HREF="options.html#'include'">'include'</A> option is used to specify a line that contains an include file
name. The <A HREF="options.html#'path'">'path'</A> option is used to search for include files.
*<A NAME="i_CTRL-X_CTRL-D"></A><B>i_CTRL-X_CTRL-D</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="scroll.html#CTRL-D">CTRL-D</A> Search in the current and included files for the
first definition (or <A HREF="map.html#macro">macro</A>) name that starts with
the same characters <A HREF="motion.html#as">as</A> before the cursor. The found
definition name is inserted in front of the cursor.
<A HREF="scroll.html#CTRL-D">CTRL-D</A> or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forwards for next matching <A HREF="map.html#macro">macro</A> name. This
<A HREF="map.html#macro">macro</A> name replaces the previous matching <A HREF="map.html#macro">macro</A>
name.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backward for previous matching <A HREF="map.html#macro">macro</A> name.
This <A HREF="map.html#macro">macro</A> name replaces the previous matching <A HREF="map.html#macro">macro</A>
name.
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="scroll.html#CTRL-D">CTRL-D</A> Further use of <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="scroll.html#CTRL-D">CTRL-D</A> will copy the words
following the previous expansion in other contexts
unless a double <A HREF="change.html#CTRL-X">CTRL-X</A> is used.
Completing Vim commands *<A NAME="compl-vim"></A><B>compl-vim</B>*
Completion is context-sensitive. It works like on the <A HREF="cmdline.html#Command-line">Command-line</A>. It
completes an <A HREF="intro.html#Ex">Ex</A> command <A HREF="motion.html#as">as</A> well <A HREF="motion.html#as">as</A> its arguments. This is useful when <A HREF="editing.html#writing">writing</A>
a Vim <A HREF="usr_41.html#script">script</A>.
*<A NAME="i_CTRL-X_CTRL-V"></A><B>i_CTRL-X_CTRL-V</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="visual.html#CTRL-V">CTRL-V</A> Guess what kind of item is in front of the cursor and
find the first match for <A HREF="motion.html#it">it</A>.
Note: When <A HREF="visual.html#CTRL-V">CTRL-V</A> is mapped you can often use <A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A>
instead of |<A HREF="#i_CTRL-Q">i_CTRL-Q</A>|.
<A HREF="visual.html#CTRL-V">CTRL-V</A> or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forwards for next match. This match replaces
the previous one.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backwards for previous match. This match
replaces the previous one.
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="visual.html#CTRL-V">CTRL-V</A> Further use of <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="visual.html#CTRL-V">CTRL-V</A> will <A HREF="diff.html#do">do</A> the same <A HREF="motion.html#as">as</A>
<A HREF="visual.html#CTRL-V">CTRL-V</A>. This allows <A HREF="map.html#mapping">mapping</A> a key to <A HREF="diff.html#do">do</A> Vim command
completion, for example:
<B> :imap <Tab> <C-X><C-V></B>
<A HREF="autocmd.html#User">User</A> defined completion *<A NAME="compl-function"></A><B>compl-function</B>*
Completion is done by a function that can be defined by the user with the
<A HREF="options.html#'completefunc'">'completefunc'</A> option. See below for how the function is called and an
example |<A HREF="#complete-functions">complete-functions</A>|.
*<A NAME="i_CTRL-X_CTRL-U"></A><B>i_CTRL-X_CTRL-U</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="scroll.html#CTRL-U">CTRL-U</A> Guess what kind of item is in front of the cursor and
find the first match for <A HREF="motion.html#it">it</A>.
<A HREF="scroll.html#CTRL-U">CTRL-U</A> or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Use the next match. This match replaces the previous
one.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Use the previous match. This match replaces the
previous one.
Omni completion *<A NAME="compl-omni"></A><B>compl-omni</B>*
Completion is done by a function that can be defined by the user with the
<A HREF="options.html#'omnifunc'">'omnifunc'</A> option. This is to be used for filetype-specific completion.
See below for how the function is called and an example |<A HREF="#complete-functions">complete-functions</A>|.
For remarks about specific filetypes see |<A HREF="#compl-omni-filetypes">compl-omni-filetypes</A>|.
More completion scripts will appear, check www.vim.org. Currently there is a
first version for C++.
*<A NAME="i_CTRL-X_CTRL-O"></A><B>i_CTRL-X_CTRL-O</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> Guess what kind of item is in front of the cursor and
find the first match for <A HREF="motion.html#it">it</A>.
<A HREF="motion.html#CTRL-O">CTRL-O</A> or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Use the next match. This match replaces the previous
one.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Use the previous match. This match replaces the
previous one.
Spelling suggestions *<A NAME="compl-spelling"></A><B>compl-spelling</B>*
A <A HREF="motion.html#word">word</A> before or at the cursor is located and correctly spelled words are
suggested to replace <A HREF="motion.html#it">it</A>. If there is a badly spelled <A HREF="motion.html#word">word</A> in the line, before
or under the cursor, the cursor is moved to after <A HREF="motion.html#it">it</A>. Otherwise the <A HREF="motion.html#word">word</A> just
before the cursor is used for suggestions, even though <A HREF="motion.html#it">it</A> isn't badly spelled.
NOTE: CTRL-S suspends display in many <A HREF="os_unix.html#Unix">Unix</A> terminals. Use '<A HREF="change.html#s">s</A>' instead. Type
<A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A> to resume displaying.
*<A NAME="i_CTRL-X_CTRL-S"></A><B>i_CTRL-X_CTRL-S</B>* *<A NAME="i_CTRL-X_s"></A><B>i_CTRL-X_s</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> CTRL-S or
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="change.html#s">s</A> Locate the <A HREF="motion.html#word">word</A> in front of the cursor and find the
first <A HREF="spell.html#spell">spell</A> suggestion for <A HREF="motion.html#it">it</A>.
CTRL-S or
<A HREF="motion.html#CTRL-N">CTRL-N</A> Use the next suggestion. This replaces the previous
one. Note that you can't use '<A HREF="change.html#s">s</A>' here.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Use the previous suggestion. This replaces the
previous one.
Completing keywords from different sources *<A NAME="compl-generic"></A><B>compl-generic</B>*
*<A NAME="i_CTRL-N"></A><B>i_CTRL-N</B>*
<A HREF="motion.html#CTRL-N">CTRL-N</A> Find next match for words that start with the
keyword in front of the cursor, looking in places
specified with the <A HREF="options.html#'complete'">'complete'</A> option. The found
keyword is inserted in front of the cursor.
*<A NAME="i_CTRL-P"></A><B>i_CTRL-P</B>*
<A HREF="motion.html#CTRL-P">CTRL-P</A> Find previous match for words that start with the
keyword in front of the cursor, looking in places
specified with the <A HREF="options.html#'complete'">'complete'</A> option. The found
keyword is inserted in front of the cursor.
<A HREF="motion.html#CTRL-N">CTRL-N</A> Search forward for next matching keyword. This
keyword replaces the previous matching keyword.
<A HREF="motion.html#CTRL-P">CTRL-P</A> Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> or
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> Further use of <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-N">CTRL-N</A> or <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> will
copy the words following the previous expansion in
other contexts unless a double <A HREF="change.html#CTRL-X">CTRL-X</A> is used.
FUNCTIONS FOR FINDING COMPLETIONS *<A NAME="complete-functions"></A><B>complete-functions</B>*
This applies to <A HREF="options.html#'completefunc'">'completefunc'</A> and <A HREF="options.html#'omnifunc'">'omnifunc'</A>.
The function is called in two different ways:
- First the function is called to find the start of the text to be completed.
- Later the function is called to actually find the matches.
On the first invocation the arguments are:
a:findstart 1
a:base empty
The function must return the column where the completion starts. It must be a
number between zero and the cursor column "col('.')". This involves looking
at the characters just before the cursor and including those characters that
could be part of the completed item. The text between this column and the
cursor column will be replaced with the matches.
<A HREF="eval.html#Special">Special</A> return values:
-1 If no completion can be done, the completion will be cancelled with an
error message.
-2 To cancel silently and stay in completion mode.
-3 To cancel silently and leave completion mode.
On the second invocation the arguments are:
a:findstart 0
a:base the text with which matches should match; the text that was
located in the first call (can be empty)
The function must return a <A HREF="eval.html#List">List</A> with the matching words. These matches
usually include the "a:base" text. When there are no matches return an empty
<A HREF="eval.html#List">List</A>.
In order to return more information than the matching words, return a Dict
that contains the <A HREF="eval.html#List">List</A>. The Dict can have these items:
words The <A HREF="eval.html#List">List</A> of matching words (mandatory).
refresh A <A HREF="eval.html#string">string</A> to <A HREF="intro.html#control">control</A> re-invocation of the function
(optional).
The only value currently recognized is "always", the
effect is that the function is called whenever the
leading text is changed.
Other items are ignored.
For acting upon end of completion, see the |<A HREF="autocmd.html#CompleteDone">CompleteDone</A>| <A HREF="autocmd.html#autocommand">autocommand</A> event.
For example, the function can contain this:
<B> let matches = ... list of words ...</B>
<B> return {'words': matches, 'refresh': 'always'}</B>
*<A NAME="complete-items"></A><B>complete-items</B>*
Each <A HREF="eval.html#list">list</A> item can either be a <A HREF="eval.html#string">string</A> or a <A HREF="eval.html#Dictionary">Dictionary</A>. When <A HREF="motion.html#it">it</A> is a <A HREF="eval.html#string">string</A> <A HREF="motion.html#it">it</A>
is used <A HREF="motion.html#as">as</A> the completion. When <A HREF="motion.html#it">it</A> is a <A HREF="eval.html#Dictionary">Dictionary</A> <A HREF="motion.html#it">it</A> can contain these
items:
<A HREF="motion.html#word">word</A> the text that will be inserted, mandatory
abbr abbreviation of "<A HREF="motion.html#word">word</A>"; when not empty <A HREF="motion.html#it">it</A> is used in
the menu instead of "<A HREF="motion.html#word">word</A>"
menu extra text for the popup menu, displayed after "<A HREF="motion.html#word">word</A>"
or "abbr"
info more information about the item, can be displayed in a
preview <A HREF="windows.html#window">window</A>
kind single <A HREF="print.html#letter">letter</A> indicating the type of completion
icase when non-zero <A HREF="change.html#case">case</A> is to be ignored when comparing
items to be equal; when omitted zero is used, thus
items that only differ in <A HREF="change.html#case">case</A> are added
dup when non-zero this match will be added even when an
item with the same <A HREF="motion.html#word">word</A> is already present.
empty when non-zero this match will be added even when <A HREF="motion.html#it">it</A> is
an empty <A HREF="eval.html#string">string</A>
All of these except "icase", "dup" and "empty" must be a <A HREF="eval.html#string">string</A>. If an item
does not meet these requirements then an error message is given and further
items in the <A HREF="eval.html#list">list</A> are not used. You can mix <A HREF="eval.html#string">string</A> and <A HREF="eval.html#Dictionary">Dictionary</A> items in
the returned <A HREF="eval.html#list">list</A>.
The "menu" item is used in the popup menu and may be truncated, thus <A HREF="motion.html#it">it</A> should
be relatively short. The "info" item can be longer, <A HREF="motion.html#it">it</A> will be displayed in
the preview <A HREF="windows.html#window">window</A> when "preview" appears in <A HREF="options.html#'completeopt'">'completeopt'</A>. The "info" item
will also remain displayed after the popup menu has been removed. This is
useful for function arguments. Use a single space for "info" to remove
existing text in the preview <A HREF="windows.html#window">window</A>. The size of the preview <A HREF="windows.html#window">window</A> is three
lines, but <A HREF="options.html#'previewheight'">'previewheight'</A> is used when <A HREF="motion.html#it">it</A> has a value of 1 or 2.
The "kind" item uses a single <A HREF="print.html#letter">letter</A> to indicate the kind of completion. This
may be used to show the completion differently (different color or icon).
Currently these types can be used:
<A HREF="visual.html#v">v</A> variable
<A HREF="motion.html#f">f</A> function or method
<A HREF="motion.html#m">m</A> member of a struct or class
t typedef
<A HREF="change.html#d">d</A> #define or <A HREF="map.html#macro">macro</A>
When searching for matches takes some time call |<A HREF="eval.html#complete_add()">complete_add()</A>| to add each
match to the total <A HREF="eval.html#list">list</A>. These matches should then not appear in the returned
<A HREF="eval.html#list">list</A>! Call |<A HREF="eval.html#complete_check()">complete_check()</A>| now and then to allow the user to press a key
while still searching for matches. Stop searching when <A HREF="motion.html#it">it</A> returns non-zero.
*<A NAME="E839"></A><B>E839</B>* *<A NAME="E840"></A><B>E840</B>*
The function is allowed to move the cursor, <A HREF="motion.html#it">it</A> is restored afterwards.
The function is not allowed to move to another <A HREF="windows.html#window">window</A> or delete text.
An example that completes the names of the months:
<B> fun! CompleteMonths(findstart, base)</B>
<B> if a:findstart</B>
<B> " locate the start of the word</B>
<B> let line = getline('.')</B>
<B> let start = col('.') - 1</B>
<B> while start > 0 && line[start - 1] =~ '\a'</B>
<B> let start -= 1</B>
<B> endwhile</B>
<B> return start</B>
<B> else</B>
<B> " find months matching with "a:base"</B>
<B> let res = []</B>
<B> for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")</B>
<B> if m =~ '^' . a:base</B>
<B> call add(res, m)</B>
<B> endif</B>
<B> endfor</B>
<B> return res</B>
<B> endif</B>
<B> endfun</B>
<B> set completefunc=CompleteMonths</B>
The same, but now pretending searching for matches is slow:
<B> fun! CompleteMonths(findstart, base)</B>
<B> if a:findstart</B>
<B> " locate the start of the word</B>
<B> let line = getline('.')</B>
<B> let start = col('.') - 1</B>
<B> while start > 0 && line[start - 1] =~ '\a'</B>
<B> let start -= 1</B>
<B> endwhile</B>
<B> return start</B>
<B> else</B>
<B> " find months matching with "a:base"</B>
<B> for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")</B>
<B> if m =~ '^' . a:base</B>
<B> call complete_add(m)</B>
<B> endif</B>
<B> sleep 300m " simulate searching for next match</B>
<B> if complete_check()</B>
<B> break</B>
<B> endif</B>
<B> endfor</B>
<B> return []</B>
<B> endif</B>
<B> endfun</B>
<B> set completefunc=CompleteMonths</B>
INSERT COMPLETION POPUP MENU *<A NAME="ins-completion-menu"></A><B>ins-completion-menu</B>*
*<A NAME="popupmenu-completion"></A><B>popupmenu-completion</B>*
Vim can display the matches in a simplistic popup menu.
The menu is used when:
- The <A HREF="options.html#'completeopt'">'completeopt'</A> option contains "menu" or "menuone".
- The <A HREF="terminal.html#terminal">terminal</A> supports at least 8 colors.
- There are at least two matches. One if "menuone" is used.
The <A HREF="options.html#'pumheight'">'pumheight'</A> option can be used to set a maximum height. The default is to
use all space available.
There are three states:
1. A complete match has been inserted, e.g., after using <A HREF="motion.html#CTRL-N">CTRL-N</A> or <A HREF="motion.html#CTRL-P">CTRL-P</A>.
2. A cursor key has been used to select another match. The match was not
inserted then, only the entry in the popup menu is highlighted.
3. Only part of a match has been inserted and characters were typed or the
backspace key was used. The <A HREF="eval.html#list">list</A> of matches was then adjusted for what is
in front of the cursor.
You normally start in the first state, with the first match being inserted.
When "longest" is in <A HREF="options.html#'completeopt'">'completeopt'</A> and there is more than one match you start
in the third state.
If you select another match, e.g., with <A HREF="motion.html#CTRL-N">CTRL-N</A> or <A HREF="motion.html#CTRL-P">CTRL-P</A>, you go to the first
state. This doesn't change the <A HREF="eval.html#list">list</A> of matches.
When you are back at the original text then you are in the third state. To
get there right away you can use a <A HREF="map.html#mapping">mapping</A> that uses <A HREF="motion.html#CTRL-P">CTRL-P</A> right after
starting the completion:
<B> :imap <F7> <C-N><C-P></B>
*<A NAME="popupmenu-keys"></A><B>popupmenu-keys</B>*
In the first state these keys have a special meaning:
<A HREF="motion.html#<BS>"><BS></A> and <A HREF="motion.html#CTRL-H">CTRL-H</A> Delete one character, find the matches for the <A HREF="motion.html#word">word</A> before
the cursor. This reduces the <A HREF="eval.html#list">list</A> of matches, often to one
entry, and switches to the second state.
Any non-special character:
Stop completion without <A HREF="change.html#changing">changing</A> the match and insert the
typed character.
In the second and third state these keys have a special meaning:
<A HREF="motion.html#<BS>"><BS></A> and <A HREF="motion.html#CTRL-H">CTRL-H</A> Delete one character, find the matches for the shorter <A HREF="motion.html#word">word</A>
before the cursor. This may find more matches.
<A HREF="various.html#CTRL-L">CTRL-L</A> Add one character from the current match, may reduce the
number of matches.
any printable, non-white character:
Add this character and reduce the number of matches.
In all three states these can be used:
<A HREF="scroll.html#CTRL-Y">CTRL-Y</A> Yes: Accept the currently selected match and stop completion.
<A HREF="scroll.html#CTRL-E">CTRL-E</A> End completion, go back to what was there before selecting a
match (what was typed or longest common <A HREF="eval.html#string">string</A>).
<A HREF="scroll.html#<PageUp>"><PageUp></A> <A HREF="visual.html#Select">Select</A> a match several entries back, but don't insert <A HREF="motion.html#it">it</A>.
<A HREF="scroll.html#<PageDown>"><PageDown></A> <A HREF="visual.html#Select">Select</A> a match several entries further, but don't insert <A HREF="motion.html#it">it</A>.
<A HREF="motion.html#<Up>"><Up></A> <A HREF="visual.html#Select">Select</A> the previous match, <A HREF="motion.html#as">as</A> if <A HREF="motion.html#CTRL-P">CTRL-P</A> was used, but don't
insert <A HREF="motion.html#it">it</A>.
<A HREF="motion.html#<Down>"><Down></A> <A HREF="visual.html#Select">Select</A> the next match, <A HREF="motion.html#as">as</A> if <A HREF="motion.html#CTRL-N">CTRL-N</A> was used, but don't
insert <A HREF="motion.html#it">it</A>.
<A HREF="motion.html#<Space>"><Space></A> or <A HREF="motion.html#<Tab>"><Tab></A> Stop completion without <A HREF="change.html#changing">changing</A> the match and insert the
typed character.
The behavior of the <A HREF="intro.html#<Enter>"><Enter></A> key depends on the state you are in:
first state: Use the text <A HREF="motion.html#as">as</A> <A HREF="motion.html#it">it</A> is and insert a line break.
second state: <A HREF="#Insert">Insert</A> the currently selected match.
third state: Use the text <A HREF="motion.html#as">as</A> <A HREF="motion.html#it">it</A> is and insert a line break.
In other words: If you used the cursor keys to select another entry in the
<A HREF="eval.html#list">list</A> of matches then the <A HREF="intro.html#<Enter>"><Enter></A> key inserts that match. If you typed
something else then <A HREF="intro.html#<Enter>"><Enter></A> inserts a line break.
The colors of the menu can be changed with these highlight groups:
Pmenu normal item |<A HREF="syntax.html#hl-Pmenu">hl-Pmenu</A>|
PmenuSel selected item |<A HREF="syntax.html#hl-PmenuSel">hl-PmenuSel</A>|
PmenuSbar scrollbar |<A HREF="syntax.html#hl-PmenuSbar">hl-PmenuSbar</A>|
PmenuThumb thumb of the scrollbar |<A HREF="syntax.html#hl-PmenuThumb">hl-PmenuThumb</A>|
There are no special mappings for when the popup menu is visible. However,
you can use an <A HREF="#Insert">Insert</A> mode <A HREF="map.html#mapping">mapping</A> that checks the |<A HREF="eval.html#pumvisible()">pumvisible()</A>| function to
<A HREF="diff.html#do">do</A> something different. Example:
<B> :inoremap <Down> <C-R>=pumvisible() ? "\<lt>C-N>" : "\<lt>Down>"<CR></B>
You can use of <expr> in <A HREF="map.html#mapping">mapping</A> to have the popup menu used when typing a
character and some condition is met. For example, for typing a dot:
<B> inoremap <expr> . MayComplete()</B>
<B> func MayComplete()</B>
<B> if (can complete)</B>
<B> return ".\<C-X>\<C-O>"</B>
<B> endif</B>
<B> return '.'</B>
<B> endfunc</B>
See |<A HREF="map.html#:map-<expr>">:map-<expr></A>| for more info.
FILETYPE-SPECIFIC REMARKS FOR OMNI COMPLETION *<A NAME="compl-omni-filetypes"></A><B>compl-omni-filetypes</B>*
The file used for {filetype} should be autoload/{filetype}complete.vim
in <A HREF="options.html#'runtimepath'">'runtimepath'</A>. Thus for "java" <A HREF="motion.html#it">it</A> is autoload/javacomplete.vim.
C *<A NAME="ft-c-omni"></A><B>ft-c-omni</B>*
Completion of C code requires a <A HREF="tagsrch.html#tags">tags</A> file. You should use Exuberant <A HREF="tagsrch.html#ctags">ctags</A>,
because <A HREF="motion.html#it">it</A> adds extra information that is needed for completion. You can find
it here: <A HREF="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</A> Version 5.6 or later is recommended.
For version 5.5.4 you should add a patch that adds the "typename:" field:
<A HREF="ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch">ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch</A>
A compiled .exe for <A HREF="os_win32.html#MS-Windows">MS-Windows</A> can be found at:
<A HREF="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</A>
https://github.com/universal-ctags/ctags-win32
If you want to complete system <A HREF="eval.html#functions">functions</A> you can <A HREF="diff.html#do">do</A> something like this. Use
<A HREF="tagsrch.html#ctags">ctags</A> to generate a <A HREF="tagsrch.html#tags">tags</A> file for all the system header files:
<B> % ctags -R -f ~/.vim/systags /usr/include /usr/local/include</B>
In your <A HREF="starting.html#vimrc">vimrc</A> file add this <A HREF="tagsrch.html#tags">tags</A> file to the <A HREF="options.html#'tags'">'tags'</A> option:
<B> set tags+=~/.vim/systags</B>
When using <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> after a name without any "<A HREF="repeat.html#.">.</A>" or "->" <A HREF="motion.html#it">it</A> is completed
from the <A HREF="tagsrch.html#tags">tags</A> file directly. This works for any identifier, also function
names. If you want to complete a local variable name, which does not appear
in the <A HREF="tagsrch.html#tags">tags</A> file, use <A HREF="motion.html#CTRL-P">CTRL-P</A> instead.
When using <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> after something that has "<A HREF="repeat.html#.">.</A>" or "->" Vim will attempt
to recognize the type of the variable and figure out what members <A HREF="motion.html#it">it</A> has.
This means only members valid for the variable will be listed.
When a member name already was complete, <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> will add a "<A HREF="repeat.html#.">.</A>" or
"->" for composite types.
Vim doesn't include a C compiler, only the most obviously formatted
declarations are recognized. Preprocessor stuff may cause confusion.
When the same structure name appears in multiple places all possible members
are included.
CSS *<A NAME="ft-css-omni"></A><B>ft-css-omni</B>*
Complete properties and their appropriate values according to CSS 2.1
specification.
HTML *<A NAME="ft-html-omni"></A><B>ft-html-omni</B>*
XHTML *<A NAME="ft-xhtml-omni"></A><B>ft-xhtml-omni</B>*
<A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> provides completion of various elements of (X)HTML files. It is
designed to support <A HREF="editing.html#writing">writing</A> of XHTML 1.0 Strict files but will also work for
other versions of HTML. Features:
- after "<A HREF="change.html#<"><</A>" complete <A HREF="tagsrch.html#tag">tag</A> name depending on context (no div suggestion inside
of an a tag); '/>' indicates empty <A HREF="tagsrch.html#tags">tags</A>
- inside of <A HREF="tagsrch.html#tag">tag</A> complete proper attributes (no width attribute for an a tag);
show also type of attribute; '*' indicates required attributes
- when attribute has limited number of possible values help to complete them
- complete names of entities
- complete values of "class" and "id" attributes with data obtained from
<style> <A HREF="tagsrch.html#tag">tag</A> and included CSS files
- when completing value of "style" attribute or working inside of "style" <A HREF="tagsrch.html#tag">tag</A>
switch to |<A HREF="#ft-css-omni">ft-css-omni</A>| completion
- when completing values of events attributes or working inside of "<A HREF="usr_41.html#script">script</A>"
<A HREF="tagsrch.html#tag">tag</A> switch to |<A HREF="#ft-javascript-omni">ft-javascript-omni</A>| completion
- when used after "</" <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> will close the last opened <A HREF="tagsrch.html#tag">tag</A>
Note: When used first time completion menu will be shown with little delay
- this is time needed for loading of data file.
Note: Completion may fail in badly formatted documents. In such <A HREF="change.html#case">case</A> try to
run |<A HREF="quickfix.html#:make">:make</A>| command to detect <A HREF="change.html#formatting">formatting</A> problems.
HTML flavor *<A NAME="html-flavor"></A><B>html-flavor</B>*
The default HTML completion depends on the <A HREF="filetype.html#filetype">filetype</A>. For HTML files <A HREF="motion.html#it">it</A> is
HTML 4.01 Transitional ('filetype' is "html"), for XHTML <A HREF="motion.html#it">it</A> is XHTML 1.0
Strict ('filetype' is "xhtml").
When doing completion outside of any other <A HREF="tagsrch.html#tag">tag</A> you will have possibility to
choose DOCTYPE and the appropriate data file will be loaded and used for all
next completions.
More about format of data file in |<A HREF="#xml-omni-datafile">xml-omni-datafile</A>|. Some of the data files
may be found on the Vim website (|<A HREF="intro.html#www">www</A>|).
Note that b:html_omni_flavor may point to a file with any XML data. This
makes possible to mix PHP (|<A HREF="#ft-php-omni">ft-php-omni</A>|) completion with any XML dialect
(assuming you have data file for <A HREF="motion.html#it">it</A>). Without setting that variable XHTML 1.0
Strict will be used.
JAVASCRIPT *<A NAME="ft-javascript-omni"></A><B>ft-javascript-omni</B>*
Completion of most elements of JavaScript language and DOM elements.
Complete:
- <A HREF="eval.html#variables">variables</A>
- function name; show function arguments
- function arguments
- properties of <A HREF="eval.html#variables">variables</A> trying to detect type of variable
- complete DOM <A HREF="index.html#objects">objects</A> and properties depending on context
- keywords of language
Completion works in separate JavaScript files (&ft==javascript), inside of
<script> <A HREF="tagsrch.html#tag">tag</A> of (X)HTML and in values of event attributes (including scanning
of external files).
DOM compatibility
At the moment (beginning of 2006) there are two main browsers - MS Internet
Explorer and Mozilla Firefox. These two applications are covering over 90% of
market. Theoretically standards are created by W3C organisation
<A HREF="http://www.w3c.org">http://www.w3c.org</A> but they are not always followed/implemented.
<B><FONT COLOR="PURPLE"> IE FF W3C Omni completion </FONT></B>
<B><FONT COLOR="PURPLE"> +/- +/- + + </FONT></B>
<B><FONT COLOR="PURPLE"> + + - + </FONT></B>
<B><FONT COLOR="PURPLE"> + - - - </FONT></B>
<B><FONT COLOR="PURPLE"> - + - - </FONT></B>
Regardless from state of implementation in browsers but if element is defined
in standards, completion <A HREF="usr_05.html#plugin">plugin</A> will place element in suggestion <A HREF="eval.html#list">list</A>. When
both major engines implemented element, even if this is not in standards <A HREF="motion.html#it">it</A>
will be suggested. All other elements are not placed in suggestion <A HREF="eval.html#list">list</A>.
PHP *<A NAME="ft-php-omni"></A><B>ft-php-omni</B>*
Completion of PHP code requires a <A HREF="tagsrch.html#tags">tags</A> file for completion of data from
external files and for class aware completion. You should use Exuberant <A HREF="tagsrch.html#ctags">ctags</A>
version 5.5.4 or newer. You can find it here: <A HREF="http://ctags.sourceforge.net/">http://ctags.sourceforge.net/</A>
Script completes:
- after $ <A HREF="eval.html#variables">variables</A> name
- if variable was declared <A HREF="motion.html#as">as</A> object add "->", if <A HREF="tagsrch.html#tags">tags</A> file is available show
name of class
- after "->" complete only function and variable names specific for given
class. To find class location and contents <A HREF="tagsrch.html#tags">tags</A> file is required. Because
PHP isn't strongly typed language user can use @var <A HREF="tagsrch.html#tag">tag</A> to declare class:
<B> /* @var $myVar myClass */</B>
<B> $myVar-></B>
Still, to find myClass contents <A HREF="tagsrch.html#tags">tags</A> file is required.
- function names with additional info:
- in <A HREF="change.html#case">case</A> of built-in <A HREF="eval.html#functions">functions</A> <A HREF="eval.html#list">list</A> of possible arguments and after | type
data returned by function
- in <A HREF="change.html#case">case</A> of user function arguments and name of file where function was
defined (if <A HREF="motion.html#it">it</A> is not current file)
- constants names
- class names after "new" declaration
Note: when doing completion first time Vim will load all necessary data into
memory. It may take several seconds. After next use of completion delay
should not be noticeable.
Script detects if cursor is inside <?php ?> <A HREF="tagsrch.html#tags">tags</A>. If <A HREF="motion.html#it">it</A> is outside <A HREF="motion.html#it">it</A> will
automatically switch to HTML/CSS/JavaScript completion. Note: contrary to
original HTML files completion of <A HREF="tagsrch.html#tags">tags</A> (and only <A HREF="tagsrch.html#tags">tags</A>) isn't context aware.
RUBY *<A NAME="ft-ruby-omni"></A><B>ft-ruby-omni</B>*
Completion of <A HREF="if_ruby.html#Ruby">Ruby</A> code requires that vim be built with |<A HREF="various.html#+ruby">+ruby</A>|.
<A HREF="if_ruby.html#Ruby">Ruby</A> completion will parse your buffer on demand in order to provide a <A HREF="eval.html#list">list</A> of
completions. These completions will be drawn from modules loaded by 'require'
and modules defined in the current buffer.
The completions provided by <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> are sensitive to the context:
<B><FONT COLOR="PURPLE"> CONTEXT COMPLETIONS PROVIDED </FONT></B>
1. Not inside a class definition Classes, constants and globals
2. Inside a class definition Methods or constants defined in the class
3. After '<A HREF="repeat.html#.">.</A>', '::' or '<A HREF="cmdline.html#:">:</A>' Methods applicable to the object being
dereferenced
4. After '<A HREF="cmdline.html#:">:</A>' or ':foo' Symbol name (beginning with 'foo')
Notes:
- Vim will load/evaluate code in order to provide completions. This may
cause some code execution, which may be a concern. This is no longer
enabled by default, to enable this feature add
<B> let g:rubycomplete_buffer_loading = 1</B>
- In context 1 above, Vim can parse the entire buffer to add a <A HREF="eval.html#list">list</A> of
classes to the completion results. This feature is turned off by default,
to enable <A HREF="motion.html#it">it</A> add
<B> let g:rubycomplete_classes_in_global = 1</B>
to your <A HREF="starting.html#vimrc">vimrc</A>
- In context 2 above, anonymous classes are not supported.
- In context 3 above, Vim will attempt to determine the methods supported by
the object.
- Vim can detect and load the Rails environment for files within a rails
project. The feature is disabled by default, to enable <A HREF="motion.html#it">it</A> add
<B> let g:rubycomplete_rails = 1</B>
to your <A HREF="starting.html#vimrc">vimrc</A>
SYNTAX *<A NAME="ft-syntax-omni"></A><B>ft-syntax-omni</B>*
Vim has the ability to color <A HREF="syntax.html#syntax">syntax</A> highlight nearly 500 languages. Part of
this highlighting includes knowing what keywords are part of a language. Many
<A HREF="filetype.html#filetypes">filetypes</A> already have custom completion scripts written for them, the
syntaxcomplete <A HREF="usr_05.html#plugin">plugin</A> provides basic completion for all other <A HREF="filetype.html#filetypes">filetypes</A>. It
does this by populating the omni completion <A HREF="eval.html#list">list</A> with the text Vim already
knows how to color highlight. It can be used for any <A HREF="filetype.html#filetype">filetype</A> and provides a
minimal language-sensitive completion.
To enable <A HREF="syntax.html#syntax">syntax</A> code completion you can run:
<B> setlocal omnifunc=syntaxcomplete#Complete</B>
You can automate this by placing the following in your |<A HREF="starting.html#.vimrc">.vimrc</A>| (after any
"<A HREF="filetype.html#:filetype">:filetype</A>" command):
<B> if has("autocmd") && exists("+omnifunc")</B>
<B> autocmd Filetype *</B>
<B> \ if &omnifunc == "" |</B>
<B> \ setlocal omnifunc=syntaxcomplete#Complete |</B>
<B> \ endif</B>
<B> endif</B>
The above will set completion to this <A HREF="usr_41.html#script">script</A> only if a specific <A HREF="usr_05.html#plugin">plugin</A> does
not already exist for that <A HREF="filetype.html#filetype">filetype</A>.
Each <A HREF="filetype.html#filetype">filetype</A> can have a wide range of <A HREF="syntax.html#syntax">syntax</A> items. The <A HREF="usr_05.html#plugin">plugin</A> allows you to
customize which <A HREF="syntax.html#syntax">syntax</A> groups to include or exclude from the <A HREF="eval.html#list">list</A>. Let's have
a look at the PHP <A HREF="filetype.html#filetype">filetype</A> to see how this works.
If you edit a file called, index.php, run the following command:
<B> syntax list</B>
The first thing you will notice is that there are many different <A HREF="syntax.html#syntax">syntax</A> groups.
The PHP language can include elements from different languages like HTML,
JavaScript and many more. The <A HREF="syntax.html#syntax">syntax</A> <A HREF="usr_05.html#plugin">plugin</A> will only include <A HREF="syntax.html#syntax">syntax</A> groups
that begin with the <A HREF="filetype.html#filetype">filetype</A>, "php", in this <A HREF="change.html#case">case</A>. For example these <A HREF="syntax.html#syntax">syntax</A>
groups are included by default with the PHP: phpEnvVar, phpIntVar,
phpFunctions.
If you wish non-filetype <A HREF="syntax.html#syntax">syntax</A> items to also be included, you can use a
regular <A HREF="eval.html#expression">expression</A> <A HREF="syntax.html#syntax">syntax</A> (added in version 13.0 of
autoload\syntaxcomplete.vim) to add items. Looking at the output from
"<A HREF="syntax.html#:syntax">:syntax</A> list" while editing a PHP file I can see some of these entries:
<B> htmlArg,htmlTag,htmlTagName,javaScriptStatement,javaScriptGlobalObjects</B>
To pick up any JavaScript and HTML keyword <A HREF="syntax.html#syntax">syntax</A> groups while editing a PHP
file, you can use 3 different regexs, one for each language. Or you can
simply restrict the include groups to a particular value, without using
a regex <A HREF="eval.html#string">string</A>:
<B> let g:omni_syntax_group_include_php = 'php\w\+,javaScript\w\+,html\w\+'</B>
<B> let g:omni_syntax_group_include_php = 'phpFunctions,phpMethods'</B>
The basic form of this variable is:
<B> let g:omni_syntax_group_include_{filetype} = 'regex,comma,separated'</B>
The PHP language has an enormous number of items which <A HREF="motion.html#it">it</A> knows how to <A HREF="syntax.html#syntax">syntax</A>
highlight. These items will be available within the omni completion <A HREF="eval.html#list">list</A>.
Some people may find this <A HREF="eval.html#list">list</A> unwieldy or are only interested in certain
items. There are two ways to prune this <A HREF="eval.html#list">list</A> (if necessary). If you find
certain <A HREF="syntax.html#syntax">syntax</A> groups you <A HREF="diff.html#do">do</A> not wish displayed you can use two different
methods to identify these groups. The first specifically lists the <A HREF="syntax.html#syntax">syntax</A>
groups by name. The second uses a regular <A HREF="eval.html#expression">expression</A> to identify both
<A HREF="syntax.html#syntax">syntax</A> groups. Simply add one the following to your <A HREF="starting.html#vimrc">vimrc</A>:
<B> let g:omni_syntax_group_exclude_php = 'phpCoreConstant,phpConstant'</B>
<B> let g:omni_syntax_group_exclude_php = 'php\w*Constant'</B>
Add <A HREF="motion.html#as">as</A> many <A HREF="syntax.html#syntax">syntax</A> groups to this <A HREF="eval.html#list">list</A> by comma separating them. The basic
form of this variable is:
<B> let g:omni_syntax_group_exclude_{filetype} = 'regex,comma,separated'</B>
You can create <A HREF="motion.html#as">as</A> many of these <A HREF="eval.html#variables">variables</A> <A HREF="motion.html#as">as</A> you need, varying only the
<A HREF="filetype.html#filetype">filetype</A> at the end of the variable name.
The <A HREF="usr_05.html#plugin">plugin</A> uses the isKeyword option to determine where <A HREF="motion.html#word">word</A> boundaries are
for the <A HREF="syntax.html#syntax">syntax</A> items. For example, in the Scheme language completion should
include the "<A HREF="motion.html#-">-</A>", call-with-output-file. Depending on your <A HREF="filetype.html#filetype">filetype</A>, this may
not provide the words you are expecting. Setting the
g:omni_syntax_use_iskeyword option to 0 will force the <A HREF="syntax.html#syntax">syntax</A> <A HREF="usr_05.html#plugin">plugin</A> to break
on <A HREF="motion.html#word">word</A> characters. This can be controlled adding the following to your
<A HREF="starting.html#vimrc">vimrc</A>:
<B> let g:omni_syntax_use_iskeyword = 0</B>
For <A HREF="usr_05.html#plugin">plugin</A> developers, the <A HREF="usr_05.html#plugin">plugin</A> exposes a public function OmniSyntaxList.
This function can be used to request a <A HREF="eval.html#List">List</A> of <A HREF="syntax.html#syntax">syntax</A> items. When editing a
SQL file (:e syntax.sql) you can use the "<A HREF="syntax.html#:syntax">:syntax</A> list" command to see the
various groups and <A HREF="syntax.html#syntax">syntax</A> items. For example:
<B> syntax list</B>
Yields data similar to this:
<B><FONT COLOR="PURPLE"> sqlOperator xxx some prior all like and any escape exists in is not </FONT></B>
<B><FONT COLOR="PURPLE"> or intersect minus between distinct </FONT></B>
<B><FONT COLOR="PURPLE"> links to Operator </FONT></B>
<B><FONT COLOR="PURPLE"> sqlType xxx varbit varchar nvarchar bigint int uniqueidentifier </FONT></B>
<B><FONT COLOR="PURPLE"> date money long tinyint unsigned xml text smalldate </FONT></B>
<B><FONT COLOR="PURPLE"> double datetime nchar smallint numeric time bit char </FONT></B>
<B><FONT COLOR="PURPLE"> varbinary binary smallmoney </FONT></B>
<B><FONT COLOR="PURPLE"> image float integer timestamp real decimal </FONT></B>
There are two <A HREF="syntax.html#syntax">syntax</A> groups listed here: sqlOperator and sqlType. To retrieve
a <A HREF="eval.html#List">List</A> of <A HREF="syntax.html#syntax">syntax</A> items you can call OmniSyntaxList a number of different
ways. To retrieve all <A HREF="syntax.html#syntax">syntax</A> items regardless of <A HREF="syntax.html#syntax">syntax</A> group:
<B> echo OmniSyntaxList( [] )</B>
To retrieve only the <A HREF="syntax.html#syntax">syntax</A> items for the sqlOperator <A HREF="syntax.html#syntax">syntax</A> group:
<B> echo OmniSyntaxList( ['sqlOperator'] )</B>
To retrieve all <A HREF="syntax.html#syntax">syntax</A> items for both the sqlOperator and sqlType groups:
<B> echo OmniSyntaxList( ['sqlOperator', 'sqlType'] )</B>
A regular <A HREF="eval.html#expression">expression</A> can also be used:
<B> echo OmniSyntaxList( ['sql\w\+'] )</B>
From within a <A HREF="usr_05.html#plugin">plugin</A>, you would typically assign the output to a <A HREF="eval.html#List">List</A>:
<B> let myKeywords = []</B>
<B> let myKeywords = OmniSyntaxList( ['sqlKeyword'] )</B>
SQL *<A NAME="ft-sql-omni"></A><B>ft-sql-omni</B>*
Completion for the SQL language includes statements, <A HREF="eval.html#functions">functions</A>, keywords.
It will also dynamically complete tables, procedures, views and column lists
with data pulled directly from within a database. For detailed instructions
and a tutorial see |<A HREF="ft_sql.html#omni-sql-completion">omni-sql-completion</A>|.
The SQL completion <A HREF="usr_05.html#plugin">plugin</A> can be used in conjunction with other completion
plugins. For example, the PHP <A HREF="filetype.html#filetype">filetype</A> has its own completion <A HREF="usr_05.html#plugin">plugin</A>.
Since PHP is often used to generate dynamic website by accessing a database,
the SQL completion <A HREF="usr_05.html#plugin">plugin</A> can also be enabled. This allows you to complete
PHP code and SQL code at the same time.
XML *<A NAME="ft-xml-omni"></A><B>ft-xml-omni</B>*
Vim 7 provides a mechanism for context aware completion of XML files. It
depends on a special |<A HREF="#xml-omni-datafile">xml-omni-datafile</A>| and two commands: |<A HREF="#:XMLns">:XMLns</A>| and
|<A HREF="#:XMLent">:XMLent</A>|. Features are:
- after "<A HREF="change.html#<"><</A>" complete the <A HREF="tagsrch.html#tag">tag</A> name, depending on context
- inside of a <A HREF="tagsrch.html#tag">tag</A> complete proper attributes
- when an attribute has a limited number of possible values help to complete
them
- complete names of entities (defined in |<A HREF="#xml-omni-datafile">xml-omni-datafile</A>| and in the
current file with "<!ENTITY" declarations)
- when used after "</" <A HREF="change.html#CTRL-X">CTRL-X</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> will close the last opened <A HREF="tagsrch.html#tag">tag</A>
Format of XML data file *<A NAME="xml-omni-datafile"></A><B>xml-omni-datafile</B>*
XML data files are stored in the "autoload/xml" directory in <A HREF="options.html#'runtimepath'">'runtimepath'</A>.
Vim <A HREF="intro.html#distribution">distribution</A> provides examples of data files in the
"$VIMRUNTIME/autoload/xml" directory. They have a meaningful name which will
be used in commands. It should be a unique name which will not create
conflicts. For example, the name xhtml10s.vim means <A HREF="motion.html#it">it</A> is the data file for
XHTML 1.0 Strict.
Each file contains a variable with a name like g:xmldata_xhtml10s . It is
a compound from two parts:
1. "g:xmldata_" general prefix, constant for all data files
2. "xhtml10s" the name of the file and the name of the described XML
dialect; <A HREF="motion.html#it">it</A> will be used <A HREF="motion.html#as">as</A> an argument for the |<A HREF="#:XMLns">:XMLns</A>|
command
Part two must be exactly the same <A HREF="motion.html#as">as</A> name of file.
The variable is a |<A HREF="eval.html#Dictionary">Dictionary</A>|. Keys are <A HREF="tagsrch.html#tag">tag</A> names and each value is a two
element |<A HREF="eval.html#List">List</A>|. The first element of the List is also a List with the names
of possible children. The second element is a |<A HREF="eval.html#Dictionary">Dictionary</A>| with the names of
attributes <A HREF="motion.html#as">as</A> keys and the possible values of attributes <A HREF="motion.html#as">as</A> values. Example:
<B> let g:xmldata_crippled = {</B>
<B> \ "vimxmlentities": ["amp", "lt", "gt", "apos", "quot"],</B>
<B> \ 'vimxmlroot': ['tag1'],</B>
<B> \ 'tag1':</B>
<B> \ [ ['childoftag1a', 'childoftag1b'], {'attroftag1a': [],</B>
<B> \ 'attroftag1b': ['valueofattr1', 'valueofattr2']}],</B>
<B> \ 'childoftag1a':</B>
<B> \ [ [], {'attrofchild': ['attrofchild']}],</B>
<B> \ 'childoftag1b':</B>
<B> \ [ ['childoftag1a'], {'attrofchild': []}],</B>
<B> \ "vimxmltaginfo": {</B>
<B> \ 'tag1': ['Menu info', 'Long information visible in preview window']},</B>
<B> \ 'vimxmlattrinfo': {</B>
<B> \ 'attrofchild': ['Menu info', 'Long information visible in preview window']}}</B>
This example would be put in the "autoload/xml/crippled.vim" file and could
help to write this file:
<B> <tag1 attroftag1b="valueofattr1"></B>
<B> <childoftag1a attrofchild></B>
<B> &amp; &lt;</B>
<B> </childoftag1a></B>
<B> <childoftag1b attrofchild="5"></B>
<B> <childoftag1a></B>
<B> &gt; &apos; &quot;</B>
<B> </childoftag1a></B>
<B> </childoftag1b></B>
<B> </tag1></B>
In the example four special elements are visible:
1. "vimxmlentities" - a special key with <A HREF="eval.html#List">List</A> containing entities of this XML
dialect.
2. If the <A HREF="eval.html#list">list</A> containing possible values of attributes has one element and
this element is equal to the name of the attribute this attribute will be
treated <A HREF="motion.html#as">as</A> <A HREF="options.html#boolean">boolean</A> and inserted <A HREF="motion.html#as">as</A> 'attrname' and not <A HREF="motion.html#as">as</A> 'attrname="'
3. "vimxmltaginfo" - a special key with a <A HREF="eval.html#Dictionary">Dictionary</A> containing <A HREF="tagsrch.html#tag">tag</A>
names <A HREF="motion.html#as">as</A> keys and two element <A HREF="eval.html#List">List</A> <A HREF="motion.html#as">as</A> values, for additional menu info and
the long description.
4. "vimxmlattrinfo" - special key with <A HREF="eval.html#Dictionary">Dictionary</A> containing attribute names
<A HREF="motion.html#as">as</A> keys and two element <A HREF="eval.html#List">List</A> <A HREF="motion.html#as">as</A> values, for additional menu info and long
description.
Note: Tag names in the data file MUST not contain a namespace description.
Check xsl.vim for an example.
Note: All data and <A HREF="eval.html#functions">functions</A> are publicly available <A HREF="motion.html#as">as</A> global
variables/functions and can be used for personal editing <A HREF="eval.html#functions">functions</A>.
DTD -> Vim *<A NAME="dtd2vim"></A><B>dtd2vim</B>*
On |<A HREF="intro.html#www">www</A>| is the <A HREF="usr_41.html#script">script</A> |<A HREF="#dtd2vim">dtd2vim</A>| which parses DTD and creates an XML data file
for Vim XML omni completion.
dtd2vim: <A HREF="http://www.vim.org/scripts/script.php?script_id=1462">http://www.vim.org/scripts/script.php?script_id=1462</A>
Check the beginning of that file for usage details.
The <A HREF="usr_41.html#script">script</A> requires <A HREF="if_perl.html#perl">perl</A> and:
perlSGML: <A HREF="http://savannah.nongnu.org/projects/perlsgml">http://savannah.nongnu.org/projects/perlsgml</A>
Commands
<A HREF="#:XMLns">:XMLns</A> {name} [{namespace}] *<A NAME=":XMLns"></A><B>:XMLns</B>*
Vim has to know which data file should be used and with which namespace. For
loading of the data file and connecting data with the proper namespace use
|<A HREF="#:XMLns">:XMLns</A>| command. The first (obligatory) argument is the name of the data
(xhtml10s, xsl). The second argument is the code of namespace (h, xsl). When
used without a second argument the dialect will be used <A HREF="motion.html#as">as</A> default - without
namespace declaration. For example to use XML completion in .xsl files:
<B> :XMLns xhtml10s</B>
<B> :XMLns xsl xsl</B>
<A HREF="#:XMLent">:XMLent</A> {name} *<A NAME=":XMLent"></A><B>:XMLent</B>*
By default entities will be completed from the data file of the default
namespace. The XMLent command should be used in <A HREF="change.html#case">case</A> when there is no default
namespace:
<B> :XMLent xhtml10s</B>
Usage
While used in this situation (after declarations from previous part, | is
cursor position):
<B> <|</B>
Will complete to an appropriate XHTML <A HREF="tagsrch.html#tag">tag</A>, and in this situation:
<B> <xsl:|</B>
Will complete to an appropriate XSL <A HREF="tagsrch.html#tag">tag</A>.
The <A HREF="usr_41.html#script">script</A> xmlcomplete.vim, provided through the |<A HREF="eval.html#autoload">autoload</A>| mechanism,
has the xmlcomplete#GetLastOpenTag() function which can be used in XML files
to get the name of the last open <A HREF="tagsrch.html#tag">tag</A> (b:unaryTagsStack has to be defined):
<B> :echo xmlcomplete#GetLastOpenTag("b:unaryTagsStack")</B>
==============================================================================
8. <A HREF="#Insert">Insert</A> mode commands *<A NAME="inserting"></A><B>inserting</B>*
The following commands can be used to insert new text into the buffer. They
can all be undone and repeated with the "<A HREF="repeat.html#.">.</A>" command.
*<A NAME="a"></A><B>a</B>*
a Append text after the cursor <A HREF="intro.html#[count]">[count]</A> times. If the
cursor is in the first column of an empty line <A HREF="#Insert">Insert</A>
starts there. But not when <A HREF="options.html#'virtualedit'">'virtualedit'</A> is set!
*<A NAME="A"></A><B>A</B>*
A Append text at the end of the line <A HREF="intro.html#[count]">[count]</A> times.
<insert> or *<A NAME="i"></A><B>i</B>* *<A NAME="insert"></A><B>insert</B>* *<A NAME="<Insert>"></A><B><Insert></B>*
<A HREF="#i">i</A> <A HREF="#Insert">Insert</A> text before the cursor <A HREF="intro.html#[count]">[count]</A> times.
When using CTRL-O in <A HREF="#Insert">Insert</A> mode |<A HREF="#i_CTRL-O">i_CTRL-O</A>| the <A HREF="intro.html#count">count</A>
is not supported.
*<A NAME="I"></A><B>I</B>*
I <A HREF="#Insert">Insert</A> text before the first non-blank in the line
<A HREF="intro.html#[count]">[count]</A> times.
When the '<A HREF="motion.html#H">H</A>' flag is present in <A HREF="options.html#'cpoptions'">'cpoptions'</A> and the
line only contains blanks, insert start just before
the last blank.
*<A NAME="gI"></A><B>gI</B>*
<A HREF="#gI">gI</A> <A HREF="#Insert">Insert</A> text in column 1 <A HREF="intro.html#[count]">[count]</A> times. {not in Vi}
*<A NAME="gi"></A><B>gi</B>*
<A HREF="#gi">gi</A> <A HREF="#Insert">Insert</A> text in the same position <A HREF="motion.html#as">as</A> where <A HREF="#Insert">Insert</A> mode
was stopped last time in the current buffer.
This uses the |<A HREF="motion.html#'^">'^</A>| <A HREF="motion.html#mark">mark</A>. It's different from "`^i"
when the <A HREF="motion.html#mark">mark</A> is past the end of the line.
The position is corrected for inserted/deleted lines,
but NOT for inserted/deleted characters.
When the |<A HREF="motion.html#:keepjumps">:keepjumps</A>| command modifier is used the |<A HREF="motion.html#'^">'^</A>|
<A HREF="motion.html#mark">mark</A> won't be changed.
{not in Vi}
*<A NAME="o"></A><B>o</B>*
<A HREF="#o">o</A> Begin a new line below the cursor and insert text,
repeat <A HREF="intro.html#[count]">[count]</A> times. {Vi: blank <A HREF="intro.html#[count]">[count]</A> screen
lines}
When the '<A HREF="pattern.html##">#</A>' flag is in <A HREF="options.html#'cpoptions'">'cpoptions'</A> the <A HREF="intro.html#count">count</A> is
ignored.
*<A NAME="O"></A><B>O</B>*
<A HREF="#O">O</A> Begin a new line above the cursor and insert text,
repeat <A HREF="intro.html#[count]">[count]</A> times. {Vi: blank <A HREF="intro.html#[count]">[count]</A> screen
lines}
When the '<A HREF="pattern.html##">#</A>' flag is in <A HREF="options.html#'cpoptions'">'cpoptions'</A> the <A HREF="intro.html#count">count</A> is
ignored.
These commands are used to start <A HREF="#inserting">inserting</A> text. You can end insert mode with
<A HREF="intro.html#<Esc>"><Esc></A>. See |<A HREF="#mode-ins-repl">mode-ins-repl</A>| for the other special characters in <A HREF="#Insert">Insert</A> mode.
The effect of <A HREF="intro.html#[count]">[count]</A> takes place after <A HREF="#Insert">Insert</A> mode is exited.
When <A HREF="options.html#'autoindent'">'autoindent'</A> is on, the indent for a new line is obtained from the
previous line. When <A HREF="options.html#'smartindent'">'smartindent'</A> or <A HREF="options.html#'cindent'">'cindent'</A> is on, the indent for a line
is automatically adjusted for C programs.
<A HREF="options.html#'textwidth'">'textwidth'</A> can be set to the maximum width for a line. When a line becomes
too long when appending characters a line break is automatically inserted.
==============================================================================
9. <A HREF="intro.html#Ex">Ex</A> insert commands *<A NAME="inserting-ex"></A><B>inserting-ex</B>*
*<A NAME=":a"></A><B>:a</B>* *<A NAME=":append"></A><B>:append</B>*
:{range}a[ppend][!] <A HREF="#Insert">Insert</A> several lines of text below the specified
line. If the {range} is missing, the text will be
inserted after the current line.
Adding [!] toggles <A HREF="options.html#'autoindent'">'autoindent'</A> for the time this
command is executed.
*<A NAME=":i"></A><B>:i</B>* *<A NAME=":in"></A><B>:in</B>* *<A NAME=":insert"></A><B>:insert</B>*
:{range}i[nsert][!] <A HREF="#Insert">Insert</A> several lines of text above the specified
line. If the {range} is missing, the text will be
inserted before the current line.
Adding [!] toggles <A HREF="options.html#'autoindent'">'autoindent'</A> for the time this
command is executed.
These two commands will keep on asking for lines, until you type a line
containing only a "<A HREF="repeat.html#.">.</A>". Watch out for lines starting with a <A HREF="intro.html#backslash">backslash</A>, see
|<A HREF="repeat.html#line-continuation">line-continuation</A>|.
When in <A HREF="intro.html#Ex">Ex</A> mode (see |<A HREF="starting.html#-e">-e</A>|) a <A HREF="intro.html#backslash">backslash</A> at the end of the line can be used to
insert a NUL character. To be able to have a line ending in a <A HREF="intro.html#backslash">backslash</A> use
two backslashes. This means that the number of backslashes is halved, but
only at the end of the line.
NOTE: These commands cannot be used with |<A HREF="repeat.html#:global">:global</A>| or |<A HREF="repeat.html#:vglobal">:vglobal</A>|.
"<A HREF="#:append">:append</A>" and "<A HREF="#:insert">:insert</A>" don't work properly in between "<A HREF="eval.html#:if">:if</A>" and
"<A HREF="eval.html#:endif">:endif</A>", "<A HREF="eval.html#:for">:for</A>" and "<A HREF="eval.html#:endfor">:endfor</A>", "<A HREF="eval.html#:while">:while</A>" and "<A HREF="eval.html#:endwhile">:endwhile</A>".
*<A NAME=":start"></A><B>:start</B>* *<A NAME=":startinsert"></A><B>:startinsert</B>*
:star[tinsert][!] Start <A HREF="#Insert">Insert</A> mode just after executing this command.
Works like typing "<A HREF="#i">i</A>" in <A HREF="intro.html#Normal">Normal</A> mode. When the ! is
included <A HREF="motion.html#it">it</A> works like "<A HREF="#A">A</A>", append to the line.
Otherwise insertion starts at the cursor position.
Note that when using this command in a function or
<A HREF="usr_41.html#script">script</A>, the insertion only starts after the function
or <A HREF="usr_41.html#script">script</A> is finished.
This command does not work from |<A HREF="various.html#:normal">:normal</A>|.
{not in Vi}
*<A NAME=":stopi"></A><B>:stopi</B>* *<A NAME=":stopinsert"></A><B>:stopinsert</B>*
:stopi[nsert] Stop <A HREF="#Insert">Insert</A> mode <A HREF="motion.html#as">as</A> soon <A HREF="motion.html#as">as</A> possible. Works like
typing <A HREF="intro.html#<Esc>"><Esc></A> in <A HREF="#Insert">Insert</A> mode.
Can be used in an <A HREF="autocmd.html#autocommand">autocommand</A>, example:
<B> :au BufEnter scratch stopinsert</B>
*<A NAME="replacing-ex"></A><B>replacing-ex</B>* *<A NAME=":startreplace"></A><B>:startreplace</B>*
:startr[eplace][!] Start <A HREF="#Replace">Replace</A> mode just after executing this command.
Works just like typing "<A HREF="change.html#R">R</A>" in <A HREF="intro.html#Normal">Normal</A> mode. When the
! is included <A HREF="motion.html#it">it</A> acts just like "$R" had been typed
(ie. begin replace mode at the end-of-line). Other-
wise replacement begins at the cursor position.
Note that when using this command in a function or
<A HREF="usr_41.html#script">script</A> that the replacement will only start after
the function or <A HREF="usr_41.html#script">script</A> is finished.
{not in Vi}
*<A NAME=":startgreplace"></A><B>:startgreplace</B>*
:startg[replace][!] Just like |<A HREF="#:startreplace">:startreplace</A>|, but use Virtual <A HREF="#Replace">Replace</A>
mode, like with |<A HREF="change.html#gR">gR</A>|.
{not in Vi}
==============================================================================
10. Inserting a file *<A NAME="inserting-file"></A><B>inserting-file</B>*
*<A NAME=":r"></A><B>:r</B>* *<A NAME=":re"></A><B>:re</B>* *<A NAME=":read"></A><B>:read</B>*
:r[ead] <A HREF="editing.html#[++opt]">[++opt]</A> [name]
<A HREF="#Insert">Insert</A> the file [name] (default: current file) below
the cursor.
See |<A HREF="editing.html#++opt">++opt</A>| for the possible values of <A HREF="editing.html#[++opt]">[++opt]</A>.
:{range}r[ead] <A HREF="editing.html#[++opt]">[++opt]</A> [name]
<A HREF="#Insert">Insert</A> the file [name] (default: current file) below
the specified line.
See |<A HREF="editing.html#++opt">++opt</A>| for the possible values of <A HREF="editing.html#[++opt]">[++opt]</A>.
*<A NAME=":r!"></A><B>:r!</B>* *<A NAME=":read!"></A><B>:read!</B>*
:[range]r[ead] <A HREF="editing.html#[++opt]">[++opt]</A> !{cmd}
Execute {cmd} and insert its standard output below
the cursor or the specified line. A temporary file is
used to store the output of the command which is then
read into the buffer. <A HREF="options.html#'shellredir'">'shellredir'</A> is used to save
the output of the command, which can be set to include
stderr or not. {cmd} is executed like with ":!{cmd}",
any '!' is replaced with the previous command |<A HREF="various.html#:!">:!</A>|.
See |<A HREF="editing.html#++opt">++opt</A>| for the possible values of <A HREF="editing.html#[++opt]">[++opt]</A>.
These commands insert the contents of a file, or the output of a command,
into the buffer. They can be undone. They cannot be repeated with the "<A HREF="repeat.html#.">.</A>"
command. They work on a line basis, insertion starts below the line in which
the cursor is, or below the specified line. To insert text above the first
line use the command ":0r {name}".
After the "<A HREF="#:read">:read</A>" command, the cursor is left on the first non-blank in the
first new line. Unless in <A HREF="intro.html#Ex">Ex</A> mode, then the cursor is left on the last new
line (sorry, this is <A HREF="intro.html#Vi">Vi</A> compatible).
If a file name is given with "<A HREF="#:r">:r</A>", <A HREF="motion.html#it">it</A> becomes the alternate file. This can be
used, for example, when you want to edit that file instead: ":e! #". This can
be switched off by removing the '<A HREF="#a">a</A>' flag from the <A HREF="options.html#'cpoptions'">'cpoptions'</A> option.
Of the <A HREF="editing.html#[++opt]">[++opt]</A> arguments one is specifically for "<A HREF="#:read">:read</A>", the <A HREF="editing.html#++edit">++edit</A> argument.
This is useful when the "<A HREF="#:read">:read</A>" command is actually used to read a file into
the buffer <A HREF="motion.html#as">as</A> if editing that file. Use this command in an empty buffer:
<B> :read ++edit filename</B>
The effect is that the <A HREF="options.html#'fileformat'">'fileformat'</A>, <A HREF="options.html#'fileencoding'">'fileencoding'</A>, <A HREF="options.html#'bomb'">'bomb'</A>, etc. <A HREF="options.html#options">options</A> are
set to what has been detected for "filename". Note that a single empty line
remains, you may want to delete <A HREF="motion.html#it">it</A>.
*<A NAME="file-read"></A><B>file-read</B>*
The <A HREF="options.html#'fileformat'">'fileformat'</A> option sets the <A HREF="intro.html#<EOL>"><EOL></A> style for a file:
<B><FONT COLOR="PURPLE">'fileformat' characters name </FONT></B>
"<A HREF="os_dos.html#dos">dos</A>" <CR><NL> or <A HREF="motion.html#<NL>"><NL></A> <A HREF="os_dos.html#DOS">DOS</A> format
"<A HREF="os_unix.html#unix">unix</A>" <A HREF="motion.html#<NL>"><NL></A> <A HREF="os_unix.html#Unix">Unix</A> format
"<A HREF="os_mac.html#mac">mac</A>" <A HREF="motion.html#<CR>"><CR></A> <A HREF="os_mac.html#Mac">Mac</A> format
Previously <A HREF="options.html#'textmode'">'textmode'</A> was used. It is obsolete now.
If <A HREF="options.html#'fileformat'">'fileformat'</A> is "<A HREF="os_dos.html#dos">dos</A>", a <A HREF="motion.html#<CR>"><CR></A> in front of an <A HREF="motion.html#<NL>"><NL></A> is ignored and a <A HREF="starting.html#CTRL-Z">CTRL-Z</A>
at the end of the file is ignored.
If <A HREF="options.html#'fileformat'">'fileformat'</A> is "<A HREF="os_mac.html#mac">mac</A>", a <A HREF="motion.html#<NL>"><NL></A> in the file is internally represented by a
<A HREF="motion.html#<CR>"><CR></A>. This is to avoid confusion with a <A HREF="motion.html#<NL>"><NL></A> which is used to represent a
<NUL>. See |<A HREF="pattern.html#CR-used-for-NL">CR-used-for-NL</A>|.
If the <A HREF="options.html#'fileformats'">'fileformats'</A> option is not empty Vim tries to recognize the type of
<A HREF="intro.html#<EOL>"><EOL></A> (see |<A HREF="editing.html#file-formats">file-formats</A>|). However, the <A HREF="options.html#'fileformat'">'fileformat'</A> option will not be
changed, the detected format is only used while reading the file.
A similar thing happens with <A HREF="options.html#'fileencodings'">'fileencodings'</A>.
On non-MS-DOS, <A HREF="os_win32.html#Win32">Win32</A>, and <A HREF="os_os2.html#OS/2">OS/2</A> systems the message "[dos format]" is shown if
a file is read in <A HREF="os_dos.html#DOS">DOS</A> format, to remind you that something unusual is done.
On <A HREF="os_mac.html#Macintosh">Macintosh</A>, <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>, <A HREF="os_win32.html#Win32">Win32</A>, and <A HREF="os_os2.html#OS/2">OS/2</A> the message "[unix format]" is shown if
a file is read in <A HREF="os_unix.html#Unix">Unix</A> format.
On non-Macintosh systems, the message "[Mac format]" is shown if a file is
read in <A HREF="os_mac.html#Mac">Mac</A> format.
An example on how to use "<A HREF="#:r">:r</A> !":
<B> :r !uuencode binfile binfile</B>
This command reads "binfile", uuencodes <A HREF="motion.html#it">it</A> and reads <A HREF="motion.html#it">it</A> into the current
buffer. Useful when you are editing e-mail and want to include a binary
file.
*<A NAME="read-messages"></A><B>read-messages</B>*
When reading a file Vim will display a message with information about the read
file. In the table is an explanation for some of the items. The others are
<A HREF="eval.html#self">self</A> explanatory. Using the long or the short version depends on the
<A HREF="options.html#'shortmess'">'shortmess'</A> option.
<B><FONT COLOR="PURPLE"> long short meaning </FONT></B>
[readonly] {RO} the file is write protected
[fifo/socket] using a stream
[fifo] using a fifo stream
[socket] using a socket stream
[CR missing] reading with "<A HREF="os_dos.html#dos">dos</A>" <A HREF="options.html#'fileformat'">'fileformat'</A> and a
NL without a preceding CR was found.
[NL found] reading with "<A HREF="os_mac.html#mac">mac</A>" <A HREF="options.html#'fileformat'">'fileformat'</A> and a
NL was found (could be "<A HREF="os_unix.html#unix">unix</A>" format)
[long lines split] at least one line was split in two
[NOT converted] conversion from <A HREF="options.html#'fileencoding'">'fileencoding'</A> to
<A HREF="options.html#'encoding'">'encoding'</A> was desired but not
possible
[converted] conversion from <A HREF="options.html#'fileencoding'">'fileencoding'</A> to
<A HREF="options.html#'encoding'">'encoding'</A> done
[crypted] file was decrypted
[READ ERRORS] not all of the file could be read
<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>
</HTML>
|