/usr/share/doc/vile-common/macros.html is in vile-common 9.8o-1.
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 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
$Id: macros.html,v 1.28 2014/07/05 10:19:18 tom Exp $
-->
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux (vers 25 March 2009), see www.w3.org">
<title>Programmed Macros in vile</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii">
<link rev="made" href="mailto:dickey@invisible-island.net">
<link rel="SHORTCUT ICON" href="/img/icons/vile.ico" type=
"image/x-icon">
<link rel="stylesheet" href="/css/simplestyle.css" type=
"text/css">
</head>
<body>
<hr>
<a href="/">http://invisible-island.net/</a><a href=
"/vile/">vile/</a><a href="/vile/vile-toc.html">vile-toc</a><br>
<hr>
<h1 id="toplevel-toc"><a name="toplevel" id="toplevel">Programmed
Macros in vile</a></h1>
<p>vile presents a couple of forms of what are commonly called
"macros". This document presents information on those written in
the builtin "macro language". (The other form of macro is a
"keyboard macro", a simple stored sequence of vile keystrokes,
which can be replayed on command.) Macros written in the macro
language can be bound to keys, run from files or buffers, given
names (in which case they're known as "procedures"), and in the
last case, those names may be directly introduced into vile's
command set.</p>
<p>The language can execute any valid vile command, using one of
it's "named" forms. I.e. the command that would be executed would
be "down-line", "forward-line", or "next-line", but it would not
work to write the macro to use 'j'.</p>
<p>vile commands can be linked together in repetitive or
conditional ways using various builtin directives (e.g. "if",
"else", "while", "break", etc), and intermediate results can be
stored in string-valued temporary variables. Other forms of
variable can be used to reference parts of vile's current state,
e.g. the current line number. Finally, there is a set of
functions that can act on variables, to concatenate them, compare
them, increment them, change their representation, etc.</p>
<p>Each of these language aspects will be described in turn, but
first the execution framework must be explained.</p>
<h2 id="creating-toc"><a name="creating" id="creating">Creating,
executing, storing macros</a></h2>
<p>In the simplest case, valid macro language constructs are
placed in a file or buffer and subsequently executed with one of
these editor commands:</p>
<table border="1" summary="Selection Techniques">
<colgroup></colgroup>
<tr>
<th>command</th>
<th>applies to</th>
<th>example</th>
</tr>
<tr>
<td>execute-buffer</td>
<td>buffer</td>
<td>execute-buffer cfgcmds</td>
</tr>
<tr>
<td>execute-file</td>
<td>disk file</td>
<td>execute-file ~/.projcfg</td>
</tr>
<tr>
<td>source</td>
<td>disk file</td>
<td>source c:/utils/proj.cfg</td>
</tr>
</table>
<p>The most common example of this usage is vile's startup file,
which is "sourced" during the editor's invocation. Typically, the
startup file configures the user's preferences and looks
something like this:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">ai</font></strong><br>
<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">ts</font></strong><strong><font color=
"#800000">=</font></strong><strong><font color=
"#008080">4</font></strong><br>
<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">flash</font></strong><br>
<etc.><br>
<!--atr2html}}--></p>
</blockquote>
<p>A startup/configuration file might also use macro language
directives to conditionally configure the editor. For example, if
xvile executes this startup file fragment:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008000">~if</font> <font color=
"#008080">&sequal</font> <font color=
"#008080">$progname</font> <font color=
"#800080">"xvile"</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">$title</font> <font color=
"#008080">$cbufname</font><br>
<font color="#008000">~endif</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>then the editor's X window titlebar changes. However,
"standard" vile (i.e., non-gui vile) ignores this fragment and
thus, a single startup file can be used to configure both the gui
and non-gui versions of the editor.</p>
<p>vile also provides constructs that encapsulate macro language
elements as numbered and named programs. These programs represent
the entity that most programmers identify as a "true" macro. And
in fact, the remainder of this document will simply assume that
the word "macro" refers to one of aforementioned program
types.</p>
<h3 id="numbered-toc"><a name="numbered" id="numbered">Numbered
macros (anachronism</a>)</h3>The numbered macro syntax looks like
so:
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<<strong><font color=
"#000080">number</font></strong>> <strong><font color=
"#000080">store-macro</font></strong><br>
<language element><br>
...<br>
<language element><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>A numbered macro is executed using this command:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">execute-macro</font></strong>-<<strong><font color="#000080">number</font></strong>><br>
<!--atr2html}}--></p>
</blockquote>
<p>To bind a keystroke to this macro, use this command:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">bind-key</font></strong> <strong><font color=
"#000080">execute-macro</font></strong>-<<strong><font color="#000080">number</font></strong>> <keystroke><br>
<!--atr2html}}--></p>
</blockquote>
<p>Here's an actual example:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#008080">30</font></strong> <strong><font color=
"#000080">store-macro</font></strong><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#800080">"this is a test macro"</font><br>
<font color="#008000">~endm</font><br>
<strong><font color=
"#000080">bind-key</font></strong> <strong><font color=
"#000080">execute-macro-30</font></strong> <font color=
"#800080">#h</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>Now, whenever "#h" is pressed, a message is written on the
editor's message line.</p>
<p>Although this syntax serves a purpose, it's obvious that
numbered programs don't lend themselves to easy recall (quick,
what does macro 22 do?). But this format was an integral part of
vile for many years, simply because named macros could not be
bound to keystrokes. This restriction has been removed, rendering
this feature essentially obsolete. The only advantage of numbered
macros over named macros is that the former do not share the same
namespace as vile's commands. This attribute can be advantageous
when creating macros recalled solely via key bindings.</p>
<p>For completeness sake, it should be mentioned that numbered
macros are allocated from a fixed pool (default is 40 macros).
This fixed pool can be increased via the following configuration
option:</p>
<pre>
--with-exec-macros=N specify count of numbered macros
</pre>
<h3 id="named-toc"><a name="named" id="named">Named
macros</a></h3>A named macro, aka "stored procedure", uses this
syntax:
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> <unique-name> ["help-string"]</font><br>
<language element><br>
...<br>
<language element><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>where:</p>
<dl>
<dt>unique-name</dt>
<dd>is an alpha-numeric identifier that does not conflict with
the name of any existing editor command (the show-commands
command generates a list of all existing commands).</dd>
<dt>help-string</dt>
<dd>is an optional description of the macro. This string is
displayed in the listing created by show-commands.</dd>
</dl>
<p>A stored procedure is executed by simply referencing its name.
To bind a keystroke to this macro, use this command:</p>
<pre>
bind-key <unique-name> <keystroke>
</pre>
<p>Here's the stored procedure equivalent of macro number 30
above:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> write-msg-tst "displays test message"</font><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#800080">"this is a test macro"</font><br>
<font color="#008000">~endm</font><br>
<strong><font color=
"#000080">bind-key</font></strong> write-msg-tst <font color="#800080">#h</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>Two mechanisms now exist for executing this macro:</p>
<ul>
<li>press "#h" within the editor, or</li>
<li>simply use the name "write-msg-tst" as if it were any other
built-in editor command. This means that "write-msg-tst" can be
invoked from another macro, from a startup/configuration file,
or from vile's command line, like so: <!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
:write-msg-tst<br>
<!--atr2html}}--></p>
</li>
</ul>
<p>Named macros may have parameters. Like Bourne shell, the
parameters are denoted '$' followed by a number, e.g., $1 for the
first parameter.</p>
<ul>
<li>$# gives the number of parameters.</li>
<li>$* gives a blank-separated list of all parameters.</li>
<li>$@ gives a blank-separated list of all parameters,
quoted.</li>
<li>$0 is the name of the current procedure, not expanded in
the lists.</li>
</ul>
<p>The individual parameters are evaluated when the macro is
invoked, and may consist of expressions. They are stored as
strings.</p>
<p>The macro interpreter uses a template in the definition to
define the types of parameters which are accepted. For each
parameter, a keyword, optionally followed by the prompt string is
required. Keywords (which may be abbreviated) include</p>
<pre>
bool
buffer
directory
enum (see below)
file
integer
majormode
mode
string
variable
</pre>
<p>Unless overridden, the prompt for each parameter is named
after the keyword. Override the prompt by an assignment,
e.g.,</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> Filter f="Input" f="Output"</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>to begin a macro 'Filter' with two parameters, Input and
Output, internally referenced by $1 and $2.</p>
<p>Here is a simple macro which accepts two parameters and uses
them to position the cursor on a given line and zero-based
character offset.</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color=
"#800000">; macro for wingrep and similar applications that can pass</font><br>
<font color=
"#800000">; both line- and column-number to external tools.</font><br>
<font color=
"#800000">; usage: "winvile +WinGrep $L $C $F"</font><br>
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> WinGrep i="Line" i="Offset"</font><br>
<font color=
"#008000">~local</font> <font color=
"#008080">%col</font><br>
<strong><font color="#000080">setv</font></strong> <font color="#008080">%col</font> <font color="#008080">&sub</font> <font color="#008080">$2</font> <strong><font color="#008080">1</font></strong><br>
<font color=
"#008080">$1</font> <strong><font color=
"#000080">goto-line</font></strong><br>
<strong><font color="#000080">beginning-of-line</font></strong><br>
<font color=
"#008000">~if</font> <font color=
"#008080">&ge</font> <font color=
"#008080">%col</font> <strong><font color=
"#008080">1</font></strong><br>
<font color="#008080">%col</font> <strong><font color="#000080">forward-character-to-eol</font></strong><br>
<font color=
"#008000">~endif</font><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>The 'enum' parameter type is special; it requires a second
keyword which denotes the symbol table which is used for
name-completion. The table name (which cannot be abbreviated)
follows the 'enum' after a colon (:), e.g.,</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> Scheme e:fcolor="Foreground"</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>The 'enum' tables correspond to the enumerated modes:</p>
<pre>
*bool
backup-style
bcolor
byteorder-mark
ccolor
color-scheme
cursor-tokens
fcolor
file-encoding
for-buffers
mcolor
mini-hilite
popup-choices
qualifiers
reader-policy
record-attrs (VMS only)
record-format (VMS only)
recordseparator
showformat
video-attrs
visual-matches
vtflash
</pre>
<h3 id="returning-toc"><a name="returning" id=
"returning">Returning values</a></h3>Any macro can return a value
to a calling script. This is done using special variables:
<dl>
<dt><a name="modevar-return" id=
"modevar-return">$return</a></dt>
<dd>is a symbol that a macro can set to any string.</dd>
<dt><a name="modevar-_" id="modevar-_">$_</a></dt>
<dd>
is copied from $return when completing a macro. If no string
was assigned to $return within the macro, $_ will contain a
readable form of the exit status. These are the standard
values used within vile:
<blockquote>
<pre>
TRUE
FALSE
ABORT
SORTOFTRUE
</pre>
</blockquote>
<p>$_ may also contain the special symbol ERROR if the macro
could not run, e.g., due to too much recursion, or if the
exit status was none of the standard values.</p>
</dd>
</dl>
<h3 id="storing-toc"><a name="storing" id="storing">Storing
macros</a></h3>
<p>In general, macros are stored in the editor's startup file.
Prolific macro authors may instead opt to sprinkle their macros
across one or more external text files and source those file(s)
from the startup file.</p>
<hr>
This concludes the discussion of the macro language execution
framework.
<p>The remainder of this document describes individual language
constructs. The presentation is bottom-up (i.e., reference
format), so individual sections may be read in any order.</p>
<hr>
<h2 id="comments-toc"><a name="comments" id=
"comments">Comments</a></h2>
<p>A semi-colon (;) or double-quote (") denotes a comment that
extends from the delimiter to end of line. The semi-colon is
inherited from MicroEMACS, the double-quote is for vi
compatibility.</p>
<p>Note 1: The double-quote also delimits string arguments, but
the command parser correctly distinguishes the various use
cases.</p>
<p>Note 2: Inline comments (comment text that follows a command)
are permitted except when used in conjunction with commands that
take optional arguments. Here follow two examples of unacceptable
usage:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
winopen <font color=
"#800000">; invoke win32 common open dialog</font><br>
<strong><font color=
"#000080">write-file</font></strong> <font color=
"#800000">; flush curr buffer to disk</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>In the first case, the winopen command attempts to browse ';'
as a directory. In the second case, write-file flushes the
current buffer to disk using ';' as the filename.</p>
<h2 id="joining-toc"><a name="joining" id="joining">Misc macro
syntax features</a></h2>
<p>Lines ending with '\' are joined before interpretation.</p>
<h3 id="limits-toc"><a name="limits" id="limits">Limits</a></h3>
<p>The length of a variable name may not exceed 255 (NLINE-1)
bytes of storage. Most other strings are allocated
dynamically.</p>
<h3 id="strings-toc"><a name="strings" id=
"strings">Strings</a></h3>
<p>Like many simple languages, the macro language operates
exclusively on strings. That is to say, variables are always of
type "string", and need not be declared in advance.</p>
<p>Strings may be surrounded by double quotes. As in C-like
languages, a few special characters may be represented using an
"escape" notation, using a backslash and another character to
represent the "special character:"</p>
<table border="1" summary="Escape Notation">
<colgroup>
<col width="100px">
<col width="200px">
</colgroup>
<tr>
<th align="left">Escape code</th>
<th align="left">Actual character</th>
<th align="left">Example</th>
</tr>
<tr>
<td>\n</td>
<td>newline character</td>
<td>(control-J)</td>
</tr>
<tr>
<td>\r</td>
<td>carriage return</td>
<td>(control-M)</td>
</tr>
<tr>
<td>\\</td>
<td>backslash</td>
<td>(itself: '\')</td>
</tr>
<tr>
<td>\b</td>
<td>backspace</td>
<td>(control-H)</td>
</tr>
<tr>
<td>\f</td>
<td>formfeed</td>
<td>(control-L)</td>
</tr>
<tr>
<td>\t</td>
<td>tab</td>
<td>(control-I)</td>
</tr>
<tr>
<td>\a</td>
<td>bell</td>
<td>(control-G)</td>
</tr>
<tr>
<td>\s</td>
<td>space</td>
<td>(ASCII SPACE)</td>
</tr>
<tr>
<td>\"</td>
<td>quote</td>
<td>(the '"' character)</td>
</tr>
<tr>
<td>\xNN</td>
<td>the character in hex (i.e. 0xNN)</td>
<td></td>
</tr>
<tr>
<td>\NNN</td>
<td>the character in octal (i.e. 0NNN)</td>
<td></td>
</tr>
<tr>
<td>\C</td>
<td>(any char)</td>
<td>itself</td>
</tr>
</table>
<p>It is permissible to omit the double quotes surrounding a
string if the parser will not confuse it with another element of
the macro language, and if it contains no whitespace, but it's
probably better practice to use the quotes all the time, to
reinforce the idea that all values are strings.</p>
<p>You may also use strings surrounded by single quotes. The
single quotes override double quotes and backslashes, making it
simpler to enter regular expressions. Double a single quote to
insert one into a string.</p>
<h2 id="variables-toc"><a name="variables" id=
"variables">Variables</a></h2>
<p>As noted above, variables hold strings. These strings may
represent words, text, numerical values, logical values, etc,
depending on the context in which they are used. There are
several distinct classes of variables, distinguished
syntactically by the character preceding their name.</p>
<table border="1" summary="Variable Classes">
<colgroup>
<col width="50%">
<col width="50%">
</colgroup>
<tr>
<th align="left">Class</th>
<th align="left">Example</th>
</tr>
<tr>
<td>Temporary variable</td>
<td>%foo</td>
</tr>
<tr>
<td>State variable</td>
<td>$curcol</td>
</tr>
<tr>
<td>Buffer variable</td>
<td><main.c</td>
</tr>
<tr>
<td>Interactive variable</td>
<td>@"Enter a filename: "</td>
</tr>
<tr>
<td>Mode variable</td>
<td>$autoindent</td>
</tr>
</table>
<p>All temporary variables, and some state variables, may be
assigned to, using the "set-variable" command, or "setv" for
short:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">$search</font> <font color=
"#800080">"new pattern to look for"</font><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%index</font> <font color=
"#800080">"1"</font><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%index2</font><strong><font color=
"#800000">=</font></strong><font color="#800080">"2"</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>An assignment may use either an equals (=) sign, or whitespace
to delimit the left/right sides of the assignment, as shown.</p>
<h2 id="tempvars-toc"><a name="tempvars" id="tempvars">Temporary
variables</a></h2>
<p>Temporary variables are used in macros to hold intermediate
values. They are only temporary in that they aren't a "fixed"
part of vile — but they _are_ persistent across invocations
of one or more macros. (That is, they have global scope.)
Temporary variables are prefixed with the % character, and their
names may be constructed from any printing character.</p>
<h2 id="statevars-toc"><a name="statevars" id="statevars">State
Variables</a></h2>
<p>State variables allow a macro to refer to and change some
aspects of vile's behavior. State variables are prefixed with a $
character, and are always referred to in lowercase. Not all state
variables are settable — some are read-only, and are so
marked in the table below.</p>
<dl>
<dt><a name="modevar-abufname" id=
"modevar-abufname">$abufname</a></dt>
<dd>[READ ONLY] Name of the "other" buffer, the one most
recently visited. This is what you would get if you typed '#'
at a prompt. (E.g. ":e #")</dd>
<dt><a name="modevar-autocolor-hook" id=
"modevar-autocolor-hook">$autocolor-hook</a></dt>
<dd>name of the hook to run when attempting to do automatic
syntax coloring.</dd>
<dt><a name="modevar-bchars" id=
"modevar-bchars">$bchars</a></dt>
<dd>[READ ONLY] Number of characters in current buffer.</dd>
<dt><a name="modevar-bchanged" id=
"modevar-bchanged">$bchanged</a></dt>
<dd>[READ ONLY] Number of characters in current buffer.</dd>
<dt><a name="modevar-bflags" id=
"modevar-bflags">$bflags</a></dt>
<dd>
[READ ONLY] Status flags for current buffer, as shown in
[Buffer List].
<table border="1" summary="$sres versus screen size">
<colgroup>
<col width="100px">
</colgroup>
<tr>
<th align="left">Flag</th>
<th align="left">Description</th>
</tr>
<tr>
<td>a</td>
<td>autobuffer caused this to be created</td>
</tr>
<tr>
<td>d</td>
<td>directory listing</td>
</tr>
<tr>
<td>i</td>
<td>invisible, e.g., tags</td>
</tr>
<tr>
<td>m</td>
<td>modified</td>
</tr>
<tr>
<td>s</td>
<td>scratch, will be removed when popped down</td>
</tr>
<tr>
<td>u</td>
<td>unread</td>
</tr>
</table>
</dd>
<dt><a name="modevar-blines" id=
"modevar-blines">$blines</a></dt>
<dd>[READ ONLY] Number of lines in current buffer.</dd>
<dt><a name="modevar-brightness" id=
"modevar-brightness">$brightness</a></dt>
<dd>RGB levels for gray, normal, bright in the 0-255 range
(winvile version only).</dd>
<dt><a name="modevar-buf-encoding" id=
"modevar-buf-encoding">$buf-encoding</a></dt>
<dd>[READ ONLY] Shows the character encoding for the current
buffer. The values are the same as for the <a href=
"vile-hlp.html#mode-file-encoding">file-encoding</a> mode, but
are always resolved, i.e., no "auto" or "locale".</dd>
<dt><a name="modevar-buf-fname-expr" id=
"modevar-buf-fname-expr">$buf-fname-expr</a></dt>
<dd>[READ ONLY] Combines bufname-expr and pathname-expr modes
for the current buffer.</dd>
<dt><a name="modevar-buffer-hook" id=
"modevar-buffer-hook">$buffer-hook</a></dt>
<dd>Name of procedure to run when switching to a buffer.</dd>
<dt><a name="modevar-bufname" id=
"modevar-bufname">$bufname</a></dt>
<dd>current buffer-name under the cursor. This is computed from
the bufname-expr and pathname-expr patterns.</dd>
<dt><a name="modevar-bwindows" id=
"modevar-bwindows">$bwindows</a></dt>
<dd>[READ ONLY] Number of windows open on current buffer.</dd>
<dt><a name="modevar-cbufname" id=
"modevar-cbufname">$cbufname</a></dt>
<dd>The current buffer's "buffername". (As opposed to the name
of the file it may contain.)</dd>
<dt><a name="modevar-cd-hook" id=
"modevar-cd-hook">$cd-hook</a></dt>
<dd>Name of procedure to run when changing directories.</dd>
<dt><a name="modevar-cdpath" id=
"modevar-cdpath">$cdpath</a></dt>
<dd>editor's copy of the $CDPATH env var (read/write)</dd>
<dt><a name="modevar-cfgopts" id=
"modevar-cfgopts">$cfgopts</a></dt>
<dd>
[READ ONLY] Comma-delimited list of "interesting" compiled
options. Currently tracked options include:
<table border="1" summary="Configure Options">
<colgroup>
<col width="100px">
</colgroup>
<tr>
<th align="left">Option</th>
<th align="left">Description</th>
</tr>
<tr>
<td>athena</td>
<td>xvile built with Athena widgets</td>
</tr>
<tr>
<td>curses</td>
<td>editor uses curses terminal driver</td>
</tr>
<tr>
<td>locale</td>
<td>editor uses system's LC_CTYPE locale</td>
</tr>
<tr>
<td>motif</td>
<td>xvile built with Motif libraries</td>
</tr>
<tr>
<td>nextaw</td>
<td>xvile built with Athena widgets (NeXtaw)</td>
</tr>
<tr>
<td>noshell</td>
<td>shell commands are disabled</td>
</tr>
<tr>
<td>oleauto</td>
<td>editor supports OLE automation.</td>
</tr>
<tr>
<td>openlook</td>
<td>xvile built with OpenLook libraries</td>
</tr>
<tr>
<td>perl</td>
<td>editor includes perl interpreter</td>
</tr>
<tr>
<td>termcap</td>
<td>editor reads TERMCAP db for screen info.</td>
</tr>
<tr>
<td>terminfo</td>
<td>editor reads TERMINFO db for screen info.</td>
</tr>
<tr>
<td>xaw</td>
<td>xvile built with Athena widgets (Xaw)</td>
</tr>
<tr>
<td>xaw3d</td>
<td>xvile built with Athena widgets (Xaw3D)</td>
</tr>
</table>
<p>If none of the above options are in effect, $cfgopts will
be empty ("").</p>
</dd>
<dt><a name="modevar-cfilname" id=
"modevar-cfilname">$cfilname</a></dt>
<dd>Full pathname of the current buffer, unless it is a special
vile buffer, in which case it will return the empty
string.</dd>
<dt><a name="modevar-char" id="modevar-char">$char</a></dt>
<dd>Decimal representation of the ASCII character at the cursor
location.</dd>
<dt><a name="modevar-cmd-count" id=
"modevar-cmd-count">$cmd-count</a></dt>
<dd>[READ ONLY] Counts repetition of the current macro, from 1
up to the given repeat count. If not in a macro, this is
zero.</dd>
<dt><a name="modevar-cmd-encoding" id=
"modevar-cmd-encoding">$cmd-encoding</a></dt>
<dd>Character set to use for the minibuffer, i.e., the buffer
used for commands and messages. The default (auto) tells vile
to set it to match the character set of the current
buffer.</dd>
<dt><a name="modevar-cmd-motion" id=
"modevar-cmd-motion">$cmd-motion</a></dt>
<dd>
[READ ONLY] Returns the motion (keyword) associated with the
current macro if it was defined using store-operator. Use
with $cmd-count to compose the complete motion, e.g.,
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">$search</font> <font color=
"#800080">"new pattern to look for"</font><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%index</font> <font color=
"#800080">"1"</font><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%index2</font><strong><font color=
"#800000">=</font></strong><font color=
"#800080">"2"</font><br>
<!--atr2html}}--></p>
</blockquote>
</dd>
<dt><a name="modevar-cryptkey" id=
"modevar-cryptkey">$cryptkey</a></dt>
<dd>[WRITE ONLY] encryption key.</dd>
<dt><a name="modevar-curchar" id=
"modevar-curchar">$curchar</a></dt>
<dd>The index of the cursor in the buffer, in characters
(counting from 1).</dd>
<dt><a name="modevar-curcol" id=
"modevar-curcol">$curcol</a></dt>
<dd>The cursor's column number (counting from 1).</dd>
<dt><a name="modevar-curline" id=
"modevar-curline">$curline</a></dt>
<dd>The cursor's line number (counting from 1).</dd>
<dt><a name="modevar-cwd" id="modevar-cwd">$cwd</a></dt>
<dd>Current working directory.</dd>
<dt><a name="modevar-cwline" id=
"modevar-cwline">$cwline</a></dt>
<dd>The relative line number of the cursor in the current
window.</dd>
<dt><a name="modevar-debug" id="modevar-debug">$debug</a></dt>
<dd>Boolean value which enables runtime tracing of macro
execution. This can be set in the ~trace command (described in
detail below) as well as via set-variable.</dd>
<dt><a name="modevar-directory" id=
"modevar-directory">$directory</a></dt>
<dd>Location of temp files. This is unused, but its initial
value is set from the user's TMP environment variable.</dd>
<dt><a name="modevar-discmd" id=
"modevar-discmd">$discmd</a></dt>
<dd>Boolean value which will prevent vile from printing some
status messages. It is automatically set to FALSE while
sourcing a file, or while executing a macro (after prompting
for missing parameters). Set it to TRUE to allow nested macros
to show a prompt-string for missing parameters.</dd>
<dt><a name="modevar-disinp" id=
"modevar-disinp">$disinp</a></dt>
<dd>Boolean value which will prevent vile from displaying
command line input characters.</dd>
<dt><a name="modevar-empty-lines" id=
"modevar-empty-lines">$empty-lines</a></dt>
<dd>The <code>force-empty-lines</code> command uses this value
to decide whether to add or delete blank lines to make all
line-gaps the same size.</dd>
<dt><a name="modevar-encoding" id=
"modevar-encoding">$encoding</a></dt>
<dd>[READ ONLY] The character encoding, e.g., ISO-8859-1.</dd>
<dt><a name="modevar-end-of-cmd" id=
"modevar-end-of-cmd">$end-of-cmd</a></dt>
<dd>Boolean which is true if user entered the cmd with a
carriage return (Some commands may expect to receive additional
arguments if their name is terminated with a space character
rather than a carriage return.)</dd>
<dt><a name="modevar-error-buffer" id=
"modevar-error-buffer">$error-buffer</a></dt>
<dd>Buffer name associated with vile's error-buffer feature.
This variable commonly appears in a ~local statement in macros
that temporarily reassign error-buffer (e.g., the ShowManpage
macro in macros/manpage.rc).</dd>
<dt><a name="modevar-error-expr" id=
"modevar-error-expr">$error-expr</a></dt>
<dd>Regular expression expanded from [Error Expressions] which
matched the most recent find-next-error command.</dd>
<dt><a name="modevar-error-match" id=
"modevar-error-match">$error-match</a></dt>
<dd>Text from the current buffer which which was matched in the
most recent find-next-error command.</dd>
<dt><a name="modevar-error-tabstop" id=
"modevar-error-tabstop">$error-tabstop</a></dt>
<dd>Tabstop value to use when computing the column that a "%C"
pattern will produce. If zero or negative, use the current
buffer's tabstop, otherwise use the given value. The default is
8.</dd>
<dt><a name="modevar-exec-path" id=
"modevar-exec-path">$exec-path</a></dt>
<dd>[READ ONLY] Where to find vile.</dd>
<dt><a name="modevar-exec-suffix" id=
"modevar-exec-suffix">$exec-suffix</a></dt>
<dd>[READ ONLY] suffix, if any, for execable programs. Use this
in portable macros, with &lookup, to get the actual program
path.</dd>
<dt><a name="modevar-exit-hook" id=
"modevar-exit-hook">$exit-hook</a></dt>
<dd>Name of procedure to run when quitting.</dd>
<dt><a name="modevar-favorites" id=
"modevar-favorites">$favorites</a></dt>
<dd>[READ ONLY] Path to favorites folder (win32 only)</dd>
<dt><a name="modevar-fchanged" id=
"modevar-fchanged">$fchanged</a></dt>
<dd>Boolean, true if file for current buffer is modified.</dd>
<dt><a name="modevar-fence-limit" id=
"modevar-fence-limit">$fence-limit</a></dt>
<dd>iteration limit for complex fences, in seconds.</dd>
<dt><a name="modevar-filename-expr" id=
"modevar-filename-expr">$filename-expr</a></dt>
<dd>actual pattern for %F in [Error Expressions]. Note that
vile wraps this in "\(" and "\+\)", so the 1-or-more applies to
the last subexpression in %F. We use this side-effect in the
win32 port, for example '\([a-zA-Z]:\)\?[^ \t:]' to make the
last range repeat 1-or-more times.</dd>
<dt><a name="modevar-filename-ic" id=
"modevar-filename-ic">$filename-ic</a></dt>
<dd>[READ ONLY] Boolean indicating if the host system's
filenames are matched ignoring their case.</dd>
<dt><a name="modevar-filter-list" id=
"modevar-filter-list">$filter-list</a></dt>
<dd>[READ ONLY] list of builtin-filters.</dd>
<dt><a name="modevar-findpath" id=
"modevar-findpath">$findpath</a></dt>
<dd>editor's copy of the $VILE_FINDPATH environment var
(read/write). Available on win32 and unix hosts. For more
details, refer to that section of the help file entitled
"Working in a project hierarchy".</dd>
<dt><a name="modevar-find-cmd" id=
"modevar-find-cmd">$find-cmd</a></dt>
<dd>[READ ONLY] last shell command spawned via the capture
command's builtin "find" interface. Available on win32 and unix
hosts.</dd>
<dt><a name="modevar-font" id="modevar-font">$font</a></dt>
<dd>Name of the current font (in xvile/winvile only).</dd>
<dt><a name="modevar-forward-search" id=
"modevar-forward-search">$forward-search</a></dt>
<dd>Boolean value indicating search direction.</dd>
<dt><a name="modevar-get-at-dot" id=
"modevar-get-at-dot">$get-at-dot</a></dt>
<dd>
Boolean value telling whether to ensure that state variables
which return a match for a regular expression match (such as
$bufname, $identifier, $pathname) or character type ($line,
$qidentifier, $word) must include the current editing
position "dot".
<p>The default (false) allows vile to search forward until it
gets a match which may not necessarily include "dot".</p>
</dd>
<dt><a name="modevar-get-it-all" id=
"modevar-get-it-all">$get-it-all</a></dt>
<dd>
Boolean value telling whether to set state variables which
return a match for a regular expression (such as $bufname,
$identifier, $pathname) or character type ($line,
$qidentifier, $word) to the complete match.
<p>The default (false) behavior in vile matches from the
current editing position onward.</p>
</dd>
<dt><a name="modevar-get-offset" id=
"modevar-get-offset">$get-offset</a></dt>
<dd>
This number is set as a side-effect of computing a state
variable which is a match for a regular expression (such as
$bufname, $identifier, $pathname) or character type ($line,
$qidentifier, $word).
<p>The number is the character offset (starting at zero) of
the match. It is set to -1 if there is no match.</p>
</dd>
<dt><a name="modevar-get-length" id=
"modevar-get-length">$get-length</a></dt>
<dd>
This number is set as a side-effect of computing a state
variable which is a match for a regular expression (such as
$bufname, $identifier, $pathname) or character type ($line,
$qidentifier, $word).
<p>The number is the character length of the match. It is set
to -1 if there is no match.</p>
</dd>
<dt><a name="modevar-helpfile" id=
"modevar-helpfile">$helpfile</a></dt>
<dd>Filename referred to when help is requested (usually
vile.hlp).</dd>
<dt><a name="modevar-iconname" id=
"modevar-iconname">$iconname</a></dt>
<dd>With xvile, contains current icon name.</dd>
<dt><a name="modevar-identifier" id=
"modevar-identifier">$identifier</a></dt>
<dd>The current "identifier-like" word under the cursor. This
is computed from the identifier-expr pattern. Also see the
"<a href="vile-hlp.html#mode-tagword">tagword</a>" mode.</dd>
<dt><a name="modevar-kbd-encoding" id=
"modevar-kbd-encoding">$kbd-encoding</a></dt>
<dd>This is the encoding used by the keyboard, which is
normally the same as <code>$term-encoding</code>.</dd>
<dt><a name="modevar-kbd-macro" id=
"modevar-kbd-macro">$kbd-macro</a></dt>
<dd>[READ ONLY] This is the contents of the keyboard macro
buffer.</dd>
<dt><a name="modevar-kill" id="modevar-kill">$kill</a></dt>
<dd>[READ ONLY] This is vile's "unnamed" yank register, which
contains the result of the last line-oriented yank or
delete.</dd>
<dt><a name="modevar-lastkey" id=
"modevar-lastkey">$lastkey</a></dt>
<dd>[READ ONLY] Character most recently entered at the
keyboard.</dd>
<dt><a name="modevar-latin1-expr" id=
"modevar-latin1-expr">$latin1-expr</a></dt>
<dd>pattern to match locales using ISO-8859-1 in case they are
not installed. Normally vile looks for a narrow locale to
correspond with the wide (UTF-8 encoding) locale. If locale
data is incomplete, vile can still support ISO-8859-1 encoding,
but checks to ensure that the locale is compatible. Some
systems lack a full set of locale data. This pattern helps it
decide if the (missing) narrow locale would use ISO-8859-1
encoding.</dd>
<dt><a name="modevar-lcols" id="modevar-lcols">$lcols</a></dt>
<dd>[READ ONLY] The length (in columns) of the current
line.</dd>
<dt><a name="modevar-libdir-path" id=
"modevar-libdir-path">$libdir-path</a></dt>
<dd>This value will be used to augment the user's PATH
environment variable when running filters, so that
vile-specific filters needn't clutter general purpose bin
directories.</dd>
<dt><a name="modevar-line" id="modevar-line">$line</a></dt>
<dd>Contains the text of the current line of the current buffer
starting with the cursor position.</dd>
<dt><a name="modevar-llength" id=
"modevar-llength">$llength</a></dt>
<dd>[READ ONLY] The length (in characters, not columns) of the
current line.</dd>
<dt><a name="modevar-locale" id=
"modevar-locale">$locale</a></dt>
<dd>[READ ONLY] The character locale, e.g., en_US.</dd>
<dt><a name="modevar-majormode" id=
"modevar-majormode">$majormode</a></dt>
<dd>[READ ONLY] Current majormode, if any.</dd>
<dt><a name="modevar-majormode-hook" id=
"modevar-majormode-hook">$majormode-hook</a></dt>
<dd>name of the hook to run when attempting to determine the
majormode for the current buffer. If this is not defined, vile
uses the prefixes and suffixes values to decide.</dd>
<dt><a name="modevar-match" id="modevar-match">$match</a></dt>
<dd>[READ ONLY] After a successful search, contains the text
that matched the search pattern.</dd>
<dt><a name="modevar-menu-file" id=
"modevar-menu-file">$menu-file</a></dt>
<dd>The name of the menu file (e.g. .vilemenu)</dd>
<dt><a name="modevar-mode" id="modevar-mode">$mode</a></dt>
<dd>[READ ONLY] "insert", "command", or "overwrite" mode.</dd>
<dt><a name="modevar-modeline-format" id=
"modevar-modeline-format">$modeline-format</a></dt>
<dd>Format of mode lines. See "<a href=
"vile-hlp.html#statusline">Mode line customization</a>" in the
vile help file.</dd>
<dt><a name="modevar-modified" id=
"modevar-modified">$modified</a></dt>
<dd>[READ ONLY] is current buffer modified or not?</dd>
<dt><a name="modevar-ncolors" id=
"modevar-ncolors">$ncolors</a></dt>
<dd>Number of displayed colors, must be power of two.</dd>
<dt><a name="modevar-ntildes" id=
"modevar-ntildes">$ntildes</a></dt>
<dd>Percent of window filled by ~ chars, at end of buffer.</dd>
<dt><a name="modevar-ocwd" id="modevar-ocwd">$ocwd</a></dt>
<dd>[READ ONLY] Previous current directory.</dd>
<dt><a name="modevar-os" id="modevar-os">$os</a></dt>
<dd>[READ ONLY] "Operating system" for which was vile was
built. Currently "unix" (if no more-specific name is derived
from the configure script), "dos", "os/2", "vms" and
"win32".</dd>
<dt><a name="modevar-pagelen" id=
"modevar-pagelen">$pagelen</a></dt>
<dd>Length of the vile screen.</dd>
<dt><a name="modevar-pagewid" id=
"modevar-pagewid">$pagewid</a></dt>
<dd>Width of the vile screen.</dd>
<dt><a name="modevar-palette" id=
"modevar-palette">$palette</a></dt>
<dd>Some versions of vile implement screen coloring. The
variable consists of digits which control the current color
set, usually one digit per color.</dd>
<dt><a name="modevar-patchlevel" id=
"modevar-patchlevel">$patchlevel</a></dt>
<dd>[READ ONLY] current patch-level (empty for release).</dd>
<dt><a name="modevar-pathlist-separator" id=
"modevar-pathlist-separator">$pathlist-separator</a></dt>
<dd>separates directory names in lists such as $PATH.</dd>
<dt><a name="modevar-pathname" id=
"modevar-pathname">$pathname</a></dt>
<dd>current "path-like" word, under the cursor. This is
computed from the pathname-expr pattern. If the current buffer
is a directory, use the entire line, overriding the regular
expression.</dd>
<dt><a name="modevar-pathname-separator" id=
"modevar-pathname-separator">$pathname-separator</a></dt>
<dd>separates levels of directory names in a path. Usually this
is '/', for Unix.</dd>
<dt><a name="modevar-pending" id=
"modevar-pending">$pending</a></dt>
<dd>[READ ONLY] Boolean which is true when the user has "typed
ahead", i.e. there are waiting keystrokes.</dd>
<dt><a name="modevar-pid" id="modevar-pid">$pid</a></dt>
<dd>[READ ONLY] vile's process-id.</dd>
<dt><a name="modevar-position-format" id=
"modevar-position-format">$position-format</a></dt>
<dd>Format of ^G command. See "<a href=
"vile-hlp.html#statusline">Mode line customization</a>" in the
vile help file.</dd>
<dt><a name="modevar-progname" id=
"modevar-progname">$progname</a></dt>
<dd>[READ ONLY] The string "vile", "xvile", or "winvile" as
appropriate.</dd>
<dt><a name="modevar-prompt" id=
"modevar-prompt">$prompt</a></dt>
<dd>The string ": ", used in command-line prompts.</dd>
<dt><a name="modevar-qidentifier" id=
"modevar-qidentifier">$qidentifier</a></dt>
<dd>the name of the current "qualified-identifier-like" word
under the cursor, useful for C++ programmers.</dd>
<dt><a name="modevar-read-hook" id=
"modevar-read-hook">$read-hook</a></dt>
<dd>Name of procedure to run after a file is read.</dd>
<dt><a name="modevar-replace" id=
"modevar-replace">$replace</a></dt>
<dd>The current replacement strings, used in
substitutions.</dd>
<dt><a name="modevar-search" id=
"modevar-search">$search</a></dt>
<dd>The current search pattern.</dd>
<dt><a name="modevar-seed" id="modevar-seed">$seed</a></dt>
<dd>The seed for the internal random number generator.</dd>
<dt><a name="modevar-shell" id="modevar-shell">$shell</a></dt>
<dd>Name of the shell program for spawned commands. For Unix,
this corresponds to $SHELL, while DOS, OS/2 and related systems
use $COMSPEC.</dd>
<dt><a name="modevar-sres" id="modevar-sres">$sres</a></dt>
<dd>
Current screen size on a DOS PC (meaningless on a Win32
host). Values:
<table border="1" summary="$sres versus screen size">
<colgroup>
<col width="200px">
</colgroup>
<tr>
<th align="left">$sres</th>
<th align="left">screen size</th>
</tr>
<tr>
<td>"2"</td>
<td>"25"</td>
</tr>
<tr>
<td>"4"</td>
<td>"43"</td>
</tr>
<tr>
<td>"5"</td>
<td>"50"</td>
</tr>
<tr>
<td>"6"</td>
<td>"60"</td>
</tr>
<tr>
<th align="left">Values for VMS:</th>
</tr>
<tr>
<td>"WIDE"</td>
<td>"NORMAL"</td>
</tr>
</table>Other drivers ignore the value.
</dd>
<dt><a name="modevar-startup-file" id=
"modevar-startup-file">$startup-file</a></dt>
<dd>The name of the startup file (e.g. .vilerc)</dd>
<dt><a name="modevar-startup-path" id=
"modevar-startup-path">$startup-path</a></dt>
<dd>Where to find the startup file</dd>
<dt><a name="modevar-status" id=
"modevar-status">$status</a></dt>
<dd>[READ ONLY] Boolean representing success of most recent
command. Since a failed command will usually cause an entire
macro to fail, the ~force directive is often used to suppress a
command's failure. $status preserves its exit status.</dd>
<dt><a name="modevar-term-encoding" id=
"modevar-term-encoding">$term-encoding</a></dt>
<dd>[READ ONLY] Shows the character encoding which the
terminal/display driver can handle. The values are the same as
for the <a href=
"vile-hlp.html#mode-file-encoding">file-encoding</a> mode. If
it can display UTF-8 (terminfo/termcap) or UTF-16 (winvile),
and the terminal is initialized to match, vile shows the
corresponding "utf-8" or "utf-16" value.</dd>
<dt><a name="modevar-title" id="modevar-title">$title</a></dt>
<dd>The current window title (X11, win32 versions only).</dd>
<dt><a name="modevar-title-encoding" id=
"modevar-title-encoding">$title-encoding</a></dt>
<dd>Tell whether to send title-change escape sequences to xterm
in ISO-8859-1 (8bit) or UTF-8 (utf-8). A "locale" setting is
provided, which tells vile to use UTF-8 if the locale encoding
uses UTF-8, and ISO-8859-1 otherwise. ISO-8859-1 is standard;
some terminal emulators require UTF-8. Even with this, other
programs such as GNU screen interfere with setting titles with
non-ASCII content.</dd>
<dt><a name="modevar-title-format" id=
"modevar-title-format">$title-format</a></dt>
<dd>The format for the window title (X11, win32 versions). If
this variable is not set, the title is the program name and the
current buffer, separated by a dash, e.g., %{$progname} -
%{$cbufname} Use the <a href=
"vile-hlp.html#mode-swap-title">swap-title</a> mode to control
the order of those strings. If $title-format is set, swap-title
has no effect. See "<a href="vile-hlp.html#statusline">Mode
line customization</a>" in the vile help file.</dd>
<dt><a name="modevar-version" id=
"modevar-version">$version</a></dt>
<dd>[READ ONLY] Contains vile's version string.</dd>
<dt><a name="modevar-with-prefix" id=
"modevar-with-prefix">$with-prefix</a></dt>
<dd>[READ ONLY] String which is set by "~with" directive in
macros. If no prefix was set, this returns ERROR.</dd>
<dt><a name="modevar-wlines" id=
"modevar-wlines">$wlines</a></dt>
<dd>Height of current window.</dd>
<dt><a name="modevar-word" id="modevar-word">$word</a></dt>
<dd>The "word" at the cursor location. The word is a contiguous
sequence of nonblank characters, rather than the vi-style
"word".</dd>
<dt><a name="modevar-write-hook" id=
"modevar-write-hook">$write-hook</a></dt>
<dd>Name of procedure to run before a file is written</dd>
<dt><a name="modevar-xdisplay" id=
"modevar-xdisplay">$xdisplay</a></dt>
<dd>The value to set $DISPLAY when running $xshell.</dd>
<dt><a name="modevar-xshell" id=
"modevar-xshell">$xshell</a></dt>
<dd>Name of the terminal program for spawned xvile commands.
The default is "xterm", but may also be set by the environment
variable $XSHELL.</dd>
<dt><a name="modevar-xshell-flags" id=
"modevar-xshell-flags">$xshell-flags</a></dt>
<dd>Command-line flags after $xshell, normally "-e" The
$XSHELLFLAGS environment variable determines the default
value.</dd>
</dl>
<h2 id="modevars-toc"><a name="modevars" id="modevars">Mode
variables</a></h2>
<p>You may set and use the values of the editor modes (i.e.,
universal modes, buffer-only modes or window-only modes) as if
they were state variables (e.g., "setv $errorbells=true"). The
global values of the editor modes are not visible to the
expression evaluator.</p>
<p>Realistically, this feature is little used, since vile's
set/setl commands, as well as the &global/&local
functions, serve the same purpose.</p>
<h2 id="bufvars-toc"><a name="bufvars" id="bufvars">Buffer
variables</a></h2>
<p>Buffer variables (a '<' followed by a buffer name) return
the current line of the specified buffer, automatically setting
the position to the next line.</p>
<h2 id="reponses-toc"><a name="reponses" id=
"reponses">Interactive variables</a></h2>Interactive variables
are not actually "variables" at all — they're really more
like functions that return a string, entered by the user in
response to a prompt. The prompt is the name of the "variable".
<p>They are so similar to a query function that there is function
which serves this exact purpose, and which should be used in
preference. Thus, one might have previously written:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%file</font> @<font color=
"#800080">"What file?"</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>Instead, one should now write:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%file</font> <font color=
"#008080">&query</font> <font color=
"#800080">"What file?"</font><br>
<!--atr2html}}--></p>
</blockquote>
<h2 id="functions-toc"><a name="functions" id=
"functions">Functions</a></h2>
<p>Functions always return strings. Functions can take 0, 1, 2,
or 3 arguments. Function names are always preceded by the &
character, and can usually be shortened to just three characters,
though there is little reason to do so.</p>
<p>Tasks that are usually implemented as "operators" in other
languages are implemented as functions in vile's macro language.
Thus, for example, arithmetic division which is usually written
as "6 / 2" is written as "&div 6 2". (I believe this is
sometimes called "prefix" notation, as opposed to the normal
operator "infix" notation, or the "postfix" notation used on a
stack-oriented calculator, i.e. "6 2 /".)</p>
<p>Depending on the function, arguments may be expected to
represent generic strings, numeric values, or logical (boolean)
values.</p>
<ul>
<li>Numeric arguments can be any of the following:
<ul>
<li>hexadecimal values (digits beginning with leading
"0x")</li>
<li>octal values (digits beginning with leading "0")</li>
<li>decimal values (other strings of digits)</li>
<li>character constants (single character in single quotes:
'C')</li>
<li>any other string will be interpreted as 0.</li>
</ul>
</li>
<li>Boolean (or "logical") arguments will be interpreted as
follows (without regard to upper/lowercase):
<ul>
<li>Logically "true" values:<br>
"true", "t", "yes", "y", "on", and non-zero numerics.</li>
<li>Logically "false" values:<br>
"false", "f", "no", "n", "off", and zero-valued
numerics</li>
</ul>
</li>
</ul>
<p>Arithmetic functions —</p>
<p>These all return numeric values:</p>
<dl>
<dt><a name="amp-add" id="amp-add">&add "N1" "N2"</a></dt>
<dd>Add "N1" and "N2".</dd>
<dt><a name="amp-sub" id="amp-sub">&sub "N1" "N2"</a></dt>
<dd>Subtract "N2" from "N1".</dd>
<dt><a name="amp-times" id="amp-times">&times "N1"
"N2"</a></dt>
<dd>Multiply "N1" by "N2".</dd>
<dt><a name="amp-divide" id="amp-divide">&divide "N1"
"N2"</a></dt>
<dd>Divide the "N1" by "N2"</dd>
<dt><a name="amp-mod" id="amp-mod">&mod "N1" "N2"</a></dt>
<dd>Divide the "N1" by "N2", return remainder.</dd>
<dt><a name="amp-negate" id="amp-negate">&negate
"N"</a></dt>
<dd>Return -(N).</dd>
<dt><a name="amp-ascii" id="amp-ascii">&ascii "S"</a></dt>
<dd>Return the ASCII code of the first character in "S"</dd>
<dt><a name="amp-random" id="amp-random">&random
"N"</a></dt>
<dt><a name="amp-rnd" id="amp-rnd">&rnd "N"</a></dt>
<dd>Random number between 1 and N</dd>
<dt><a name="amp-abs" id="amp-abs">&abs "N"</a></dt>
<dd>Absolute value of "N"</dd>
<dt><a name="amp-ftime" id="amp-ftime">&ftime "N"</a></dt>
<dd>The modification time of the file "N"</dd>
<dt><a name="amp-stime" id="amp-stime">&stime</a></dt>
<dd>The system time.</dd>
</dl>
<p>String manipulation functions —</p>
<p>These two return numeric values:</p>
<dl>
<dt><a name="amp-length" id="amp-length">&length
"S"</a></dt>
<dd>Returns length of string "S".</dd>
<dt><a name="amp-sindex" id="amp-sindex">&sindex "S1"
"S2"</a></dt>
<dd>Returns index of "S2" within "S1", or 0.</dd>
</dl>
<p>The rest return strings:</p>
<dl>
<dt><a name="amp-bind" id="amp-bind">&bind "S"</a></dt>
<dd>Return the function name bound to the key sequence
"S".</dd>
<dt><a name="amp-cat" id="amp-cat">&cat "S1" "S2"</a></dt>
<dd>Concatenate S1 and string "S".</dd>
<dt><a name="amp-chr" id="amp-chr">&chr "N"</a></dt>
<dd>Converts numeric "N" to an ASCII character.</dd>
<dt><a name="amp-cclass" id="amp-cclass">&cclass
"S"</a></dt>
<dd>Character class (see "<a href=
"vile-hlp.html#command-show-printable">show-printable</a>")</dd>
<dt><a name="amp-env" id="amp-env">&env "S"</a></dt>
<dd>Return the value of the user's environment variable named
"S".</dd>
<dt><a name="amp-get-key" id=
"amp-get-key">&get-key</a></dt>
<dd>(alias for &gtkey).</dd>
<dt><a name="amp-get-completion" id=
"amp-get-completion">&get-completion</a></dt>
<dd>
Prompt for and return name-completion. There are two
parameters:
<ol>
<li>category (any of "command", "buffer", "directory",
"filename", "tags")</li>
<li>value to complete, e.g., $identifier, $word or just a
string in quotes.</li>
</ol>
</dd>
<dt><a name="amp-get-motion" id=
"amp-get-motion">&get-motion</a></dt>
<dd>(alias for &gtmotion).</dd>
<dt><a name="amp-get-sequence" id=
"amp-get-sequence">&get-sequence</a></dt>
<dd>(alias for &gtsequence).</dd>
<dt><a name="amp-gtkey" id="amp-gtkey">&gtkey</a></dt>
<dd>Get a single raw keystroke from the user.</dd>
<dt><a name="amp-gtmotion" id="amp-gtmotion">&gtmotion
"N"</a></dt>
<dd>
Get a key sequence from user which must be bound to a motion.
The parameter is one of the binding names:
<ul>
<li>"command"</li>
<li>"default"</li>
<li>"insert"</li>
<li>"select"</li>
</ul>If successful, the name of the corresponding motion
function is returned.
</dd>
<dt><a name="amp-gtsequence" id=
"amp-gtsequence">&gtsequence</a></dt>
<dd>Get a complete vile key sequence from user.</dd>
<dt><a name="amp-left" id="amp-left">&left "S" "N"</a></dt>
<dd>Extract first "N" characters from "S"</dd>
<dt><a name="amp-lower" id="amp-lower">&lower "S"</a></dt>
<dd>Return lowercase version of "S".</dd>
<dt><a name="amp-right" id="amp-right">&right "S"
"N"</a></dt>
<dd>Extract chars from position "N" onward.</dd>
<dt><a name="amp-middle" id="amp-middle">&middle "S" "N1"
"N2"</a></dt>
<dd>Extract "N2" chars at position "N1".</dd>
<dt><a name="amp-upper" id="amp-upper">&upper "S"</a></dt>
<dd>Return uppercase version of "S".</dd>
<dt><a name="amp-trim" id="amp-trim">&trim "S"</a></dt>
<dd>Remove whitespace at either end of "S", reduce multiple
spaces within "S" to just one space each.</dd>
</dl>
<p>Boolean/logical functions —</p>
<p>These all return TRUE or FALSE:</p>
<dl>
<dt><a name="amp-not" id="amp-not">&not "B"</a></dt>
<dd>Return inverse of boolean "B".</dd>
<dt><a name="amp-and" id="amp-and">&and "B1" "B2"</a></dt>
<dd>Return logical AND of "B1" and "B2".</dd>
<dt><a name="amp-or" id="amp-or">&or "B1" "B2"</a></dt>
<dd>Return logical OR of "B1" and "B2".</dd>
<dt><a name="amp-equal" id="amp-equal">&equal "N1"
"N2"</a></dt>
<dd>Is "N1" numerically equal to "N2"?</dd>
<dt><a name="amp-geq" id="amp-geq">&geq "N1" "N2"</a></dt>
<dd>Is "N1" numerically not less than "N2"?</dd>
<dt><a name="amp-greater" id="amp-greater">&greater "N1"
"N2"</a></dt>
<dd>Is "N1" numerically greater than "N2"?</dd>
<dt><a name="amp-gt" id="amp-gt">&gt "N1" "N2"</a></dt>
<dd>(same as &greater)</dd>
<dt><a name="amp-isa" id="amp-isa">&isa "C" "N"</a></dt>
<dd>Is "N" a member of class "C". Classes include: buffer,
color, mode, submode, Majormode.</dd>
<dt><a name="amp-leq" id="amp-leq">&leq "N1" "N2"</a></dt>
<dd>Is "N1" numerically not greater than "N2"?</dd>
<dt><a name="amp-lessthan" id="amp-lessthan">&lessthan "N1"
"N2"</a></dt>
<dd>Is "N1" numerically less than "N2"?</dd>
<dt><a name="amp-lt" id="amp-lt">&lt "N1" "N2"</a></dt>
<dd>(same as &lessthan)</dd>
<dt><a name="amp-neq" id="amp-neq">&neq "N1" "N2"</a></dt>
<dd>Is "N1" numerically not equal to "N2"?</dd>
<dt><a name="amp-sequal" id="amp-sequal">&sequal "S1"
"S2"</a></dt>
<dd>Is "S1" the same string as "S2"?</dd>
<dt><a name="amp-sgeq" id="amp-sgeq">&sgeq "S1"
"S2"</a></dt>
<dd>Is "S1" lexically not less than "S2"?</dd>
<dt><a name="amp-sgreater" id="amp-sgreater">&sgreater "S1"
"S2"</a></dt>
<dd>Is "S1" lexically greater than "S2"?</dd>
<dt><a name="amp-sgt" id="amp-sgt">&sgt "S1" "S2"</a></dt>
<dd>(same as &slessthan)</dd>
<dt><a name="amp-sleq" id="amp-sleq">&sleq "S1"
"S2"</a></dt>
<dd>Is "S1" lexically not greater than "S2"?</dd>
<dt><a name="amp-slessthan" id="amp-slessthan">&slessthan
"S1" "S2"</a></dt>
<dd>Is "S1" lexically less than "S2"?</dd>
<dt><a name="amp-slt" id="amp-slt">&slt "S1" "S2"</a></dt>
<dd>(same as &slessthan)</dd>
<dt><a name="amp-sneq" id="amp-sneq">&sneq "S1"
"S2"</a></dt>
<dd>Is "S1" lexically not equal to "S2"?</dd>
<dt><a name="amp-readable" id="amp-readable">&readable
"S"</a></dt>
<dt><a name="amp-rd" id="amp-rd">&rd "S"</a></dt>
<dd>Is the named file "S" readable?</dd>
<dt><a name="amp-writable" id="amp-writable">&writable
"S"</a></dt>
<dd>Is the named file "S" writable?</dd>
<dt><a name="amp-execable" id="amp-execable">&execable
"S"</a></dt>
<dd>Is the named file "S" exec'able?</dd>
<dt><a name="amp-bchanged" id="amp-bchanged">&bchanged
"S"</a></dt>
<dd>Is given buffer "S" modified?</dd>
<dt><a name="amp-fchanged" id="amp-fchanged">&fchanged
"S"</a></dt>
<dd>Is file for given buffer "S" modified?</dd>
<dt><a name="amp-cmatch" id="amp-cmatch">&cmatch "R"
"V"</a></dt>
<dd>Does the given regular expression "R" match the value "V"
(ignoring case)?</dd>
<dt><a name="amp-error" id="amp-error">&error "S"</a></dt>
<dd>Was the string set with the ERROR token? For example, a
&query that is aborted will return an ERROR result.</dd>
<dt><a name="amp-match" id="amp-match">&match "R"
"V"</a></dt>
<dd>Does the given regular expression "R" match the value
"V"?</dd>
<dt><a name="amp-filter" id="amp-filter">&filter
"M"</a></dt>
<dd>Does the given majormode have a built-in highlighting
filter?</dd>
<dt><a name="amp-stoken" id="amp-stoken">&stoken "T" "D"
"S"</a></dt>
<dd>Is token "T" in string "S", given delimiters "D"?</dd>
</dl>
<p>Miscellaneous functions —</p>
<p>These all return string values:</p>
<dl>
<dt><a name="amp-classof" id="amp-classof">&classof
"N"</a></dt>
<dd>Retrieves the class(es) to which the given name may return.
Usually this is a single name, e.g., one of those checked by
&isa. If multiple matches are found, the result contains
each classname separated by a space.</dd>
<dt><a name="amp-default" id="amp-default">&default
"MODENAME"</a></dt>
<dd>Retrieves initial/default value for the given mode or state
variable.</dd>
<dt><a name="amp-global" id="amp-global">&global
"MODENAME"</a></dt>
<dd>Retrieves universal/global mode setting.</dd>
<dt><a name="amp-indirect" id="amp-indirect">&indirect
"S"</a></dt>
<dd>
Evaluate value of "S" as a macro language variable itself.
Thus if %foo has value "HOME", then
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008080">&env</font> <font color=
"#008080">&indirect</font> <font color=
"#008080">%foo</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>will return the home directory pathname.</p>
</dd>
<dt><a name="amp-local" id="amp-local">&local
"MODENAME"</a></dt>
<dd>Retrieves local mode setting (for current buffer).</dd>
<dt><a name="amp-lookup" id="amp-lookup">&lookup "N"
"P"</a></dt>
<dd>
The "N" keyword tells which field to use looking for the file
"P":
<p>bin – look in vile's directory<br>
current – look in the current directory<br>
home – look in user's $HOME directory<br>
libdir – look along $libdir-path<br>
path – look along user's $PATH<br>
startup – look along $startup-path</p>
<p>as well as associated access tests:</p>
<p>execable - test if file is exec'able<br>
readable - test if file is readable<br>
writable - test if file is writable</p>
<p>The search order is fixed: current, home, bin, startup,
path, libdir. Note that the directory lists may overlap.</p>
</dd>
<dt><a name="amp-mclass" id="amp-mclass">&mclass
"M"</a></dt>
<dd>Retrieve the class to which the given mode belongs. This is
different from &mclass since it distinguishes the modes
Return values include: universal buffer window submode
Majormode.</dd>
<dt><a name="amp-qpasswd" id="amp-qpasswd">&qpasswd
"S"</a></dt>
<dd>Present "S" to the user and return their response. Each
typed character is echoed as '*'. The response is not
recallable via the editor's history mechanism.</dd>
<dt><a name="amp-query" id="amp-query">&query "S"</a></dt>
<dd>Present "S" to the user, and return their typed
response.</dd>
<dt><a name="amp-date" id="amp-date">&date "F" "T"</a></dt>
<dd>If strftime() is found, format the time "T" using the "F"
format. Otherwise, use ctime() to format the time. Times are
numbers (see &ftime and &stime).</dd>
<dt><a name="amp-dquery" id="amp-dquery">&dquery "S"
"D"</a></dt>
<dd>Present "S" to the user, and return their typed response.
If "D" is given, use that as the default response. Otherwise
use the previous response as the default.</dd>
<dt><a name="amp-path" id="amp-path">&path "N" "P"</a></dt>
<dd>
The "N" keyword tells which field to extract from the
pathname "P":
<p>end – suffix of the filename<br>
full – absolute path<br>
head – directory<br>
root – filename without suffix<br>
short – relative path<br>
tail – filename</p>
</dd>
<dt><a name="amp-pcat" id="amp-pcat">&pcat "D" "F"</a></dt>
<dd>Concatenate directory and filename, handing syntax and
ensuring that if the filename is absolute, that the directory
is ignored.</dd>
<dt><a name="amp-pquote" id="amp-pquote">&pquote
"P"</a></dt>
<dd>Quote the pathname if it contains characters such as space
that cannot be passed to the shell without special
handling.</dd>
<dt><a name="amp-register" id="amp-register">&register
"S"</a></dt>
<dd>Return contents of register "S". Only the first character
of "S" is used for the name. Note that the contents may be more
than one line.</dd>
<dt><a name="amp-token" id="amp-token">&token "N" "D"
"S"</a></dt>
<dd>Select N'th token of string "S", given delimiters "D".</dd>
<dt><a name="amp-translate" id="amp-translate">&translate
"F" "T" "S"</a></dt>
<dd>Translate from "F" to "T" each character of string "S". The
"F" and "T" are strings of equal length; characters from "S"
found in "F" are translated to the character in "T" at the same
index.</dd>
<dt><a name="amp-word" id="amp-word">&word "N" "S"</a></dt>
<dd>Select N'th word of string "S", blank separated.</dd>
</dl>
<h2 id="directives-toc"><a name="directives" id=
"directives">Directives</a></h2>
<p>The macro language has the capability for controlling flow and
repetition through conditional, branching, and looping
instructions. Complex text processing or user input tasks can be
constructed in this way. The keywords that introduce this control
are called "directives". They are always prefixed with the ~
character, and they are always in all lowercase.</p>
<h3 id="endm-toc">~<a name="endm" id="endm">endm</a></h3>
<p>The "store-procedure" and "store-macro" commands both indicate
the start of the body of a macro routine. ~endm indicates the end
of that routine.</p>
<h3 id="force-toc">~<a name="force" id="force">force</a></h3>
<p>To prevent a failed command from terminating the macro which
invokes it, the ~force directive can be used to "hide" a bad
return code. For instance, the "up-line" command might fail if
executed at the top of a buffer. "~force up-line" will suppress
the failure. The $status variable can be used to determine
whether the command succeeded or not.</p>
<h3 id="hidden-toc">~<a name="hidden" id="hidden">hidden</a></h3>
<p>You can suppress not only the check for success or failure of
a macro as in ~force, but also the screen refresh, making macros
run more rapidly. For example</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#008080">30</font></strong> <strong><font color=
"#000080">store-macro</font></strong><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#800080">"[Attaching C/C++ attributes...]"</font><br>
<font color=
"#008000">~local</font> <font color=
"#008080">$curcol</font> <font color=
"#008080">$curline</font><br>
<font color=
"#008000">~hidden</font> <strong><font color=
"#000080">goto-beginning-of-file</font></strong><br>
<font color=
"#008000">~hidden</font> <strong><font color=
"#000080">attribute-from-filter</font></strong> <strong><font color="#000080">end-of-file</font></strong> <font color="#800080">"vile-c-filt"</font><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#800080">"[Attaching C/C++ attributes...done ]"</font><br>
<font color="#008000">~endm</font><br>
<strong><font color=
"#000080">bind-key</font></strong> <strong><font color=
"#000080">execute-macro-30</font></strong> <font color=
"#800080">^X-q</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>causes the screen updates from moving the current position to
the beginning of the file and then filtering (which moves the
position to the end-of-file) to be suppressed. The screen will be
updated after completion of the macro, after the current position
has been restored from the values saved with the ~local
directive.</p>
<h3 id="quiet-toc">~<a name="quiet" id="quiet">quiet</a></h3>
<p>Rather than suppress all screen updates, you may suppress any
messages that are written as the command progresses.</p>
<h3 id="conditionals-toc">~<a name="conditionals" id=
"conditionals">if, ~elseif, ~else, and ~endif</a></h3>
<p>These control execution of macro commands in the expected
manner. The ~if directive is followed by a string which is
evaluated for truth or falsehood according to the rules outlines
for boolean variables, above. The following fragment demonstrates
the use of this family of directives:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">beginning-of-line</font></strong><br>
<font color="#800000">; test for '#'</font><br>
<font color="#008000">~if</font> <font color=
"#008080">&equ</font> <font color=
"#008080">$char</font> <strong><font color=
"#008080">35</font></strong><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%comment-type</font> <font color=
"#800080">"shell comment"</font><br>
<font color="#800000">; test for ';'</font><br>
<font color="#008000">~elseif</font> <font color=
"#008080">&equ</font> <font color=
"#008080">$char</font> <strong><font color=
"#008080">59</font></strong><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%comment-type</font> <font color=
"#800080">"vile macro language comment"</font><br>
<font color="#008000">~else</font><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#800080">"Not an expected comment type"</font><br>
<font color=
"#008000">~return</font><br>
<font color="#008000">~endif</font><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#008080">&cat</font> <font color=
"#800080">"The current line is a "</font> <font color="#008080">%comment-type</font><br>
<!--atr2html}}--></p>
</blockquote>
<h3 id="goto-toc">~<a name="goto" id="goto">goto</a></h3>
<p>What would a decent programming language be without a "goto"?
The ~goto directive is followed by the name of a label. Labels
may appear anywhere in the current macro definition, and are
themselves preceded with a * character.</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color=
"#008000">~force</font> <strong><font color=
"#000080">up-line</font></strong><br>
if <font color=
"#008080">&not</font> <font color=
"#008080">$status</font><br>
<font color=
"#008000">~goto</font> foundtop<br>
...<br>
...<br>
<br>
*foundtop<br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#800080">"At top of buffer"</font><br>
<!--atr2html}}--></p>
</blockquote>
<h3 id="while-toc">~<a name="while" id="while">while and
~endwhile</a></h3>
<p>The block of statements bracketed by ~while and ~endwhile are
executed repeatedly, until the condition being tested by ~while
becomes false.</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color=
"#800000">; how many occurrences of a given pattern in a buffer?</font><br>
<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">nowrapscan</font></strong><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%lookfor</font> somepattern<br>
<font color=
"#800000">; we'll count one too many</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%howmany</font> <font color=
"#800080">"-1"</font><br>
<br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%continue</font> yes<br>
<font color="#008000">~while</font> <font color=
"#008080">%continue</font><br>
<font color=
"#008000">~force</font> <strong><font color=
"#000080">search-forward</font></strong> <font color=
"#008080">%lookfor</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%continue</font> <font color=
"#008080">$status</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%howmany</font> <font color=
"#008080">&add</font> <font color=
"#008080">%howmany</font> <font color=
"#800080">"1"</font><br>
<font color="#008000">~endwhile</font><br>
<br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#008080">&cat</font> <font color=
"#008080">&cat</font> <font color=
"#008080">%howmany</font> <font color=
"#800080">" appearances of "</font> <font color="#008080">%lookfor</font><br>
<!--atr2html}}--></p>
</blockquote>
<h3 id="break-toc">~<a name="break" id="break">break</a></h3>
<p>The ~break directive allows early termination of an enclosing
while-loop. Extending the above example:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color=
"#800000">; count the occurrences of a pattern in all buffers</font><br>
<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">nowrapscan</font></strong><br>
<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">noautobuffer</font></strong><br>
<strong><font color="#000080">rewind</font></strong><br>
<br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%lookfor</font> pgf<br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%howmany</font> <font color=
"#800080">"0"</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%buffers</font> <font color=
"#800080">"1"</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%cont</font> yes<br>
<br>
<font color="#008000">~while</font> true<br>
<strong><font color=
"#000080">goto-beginning-of-file</font></strong><br>
<font color=
"#008000">~while</font> true<br>
<font color=
"#008000">~force</font> <strong><font color=
"#000080">search-forward</font></strong> <font color=
"#008080">%lookfor</font><br>
<font color=
"#008000">~if</font> <font color=
"#008080">&not</font> <font color=
"#008080">$status</font><br>
<font color="#008000">~break</font><br>
<font color=
"#008000">~endif</font><br>
<strong><font color="#000080">set-variable</font></strong> <font color="#008080">%howmany</font> <font color="#008080">&add</font> <font color="#008080">%howmany</font> <font color="#800080">"1"</font><br>
<font color=
"#008000">~endwhile</font><br>
<font color=
"#008000">~force</font> <strong><font color=
"#000080">next-buffer</font></strong><br>
<font color=
"#008000">~if</font> <font color=
"#008080">&not</font> <font color=
"#008080">$status</font><br>
<font color=
"#008000">~break</font><br>
<font color="#008000">~endif</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%buffers</font> <font color=
"#008080">&add</font> <font color=
"#008080">%buffers</font> <font color=
"#800080">"1"</font><br>
<font color="#008000">~endwhile</font><br>
<br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%msg</font> <font color=
"#008080">%lookfor</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%msg</font> <font color=
"#008080">&cat</font> <font color=
"#800080">" appeared "</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%msg</font> <font color=
"#008080">&cat</font> <font color=
"#008080">%howmany</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%msg</font> <font color=
"#008080">&cat</font> <font color=
"#008080">%msg</font> <font color=
"#800080">" times in "</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%msg</font> <font color=
"#008080">&cat</font> <font color=
"#008080">%msg</font> <font color=
"#008080">%buffers</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">%msg</font> <font color=
"#008080">&cat</font> <font color=
"#008080">%msg</font> <font color=
"#800080">" buffers."</font><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#008080">%msg</font><br>
<!--atr2html}}--></p>
</blockquote>
<h3 id="return-toc">~<a name="return" id="return">return</a></h3>
<p>This causes immediate exit of the current macro, back to the
calling macro, or to user control, as appropriate.</p>
<h3 id="local-toc">~<a name="local" id="local">local</a></h3>
<p>The ~local directive causes the variables which are listed to
be saved at that point (once if the directive is within a loop),
and automatically restored at the end of the current macro. If
the directive specifies a temporary variable which was not
defined before, it will be deleted rather than restored.</p>
<p>For example:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008000">~local</font> <font color=
"#008080">$curcol</font> <font color=
"#008080">$curline</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>will restore the cursor position. The order is important in
this example, because vile restores the variables in the reverse
order of the ~local declaration. If $curline is set, $curcol will
be reset to the first column as a side effect. So we specify that
$curcol is restored last.</p>
<p>~local can save/restore the state of mode variables [1], user
variables and the state variables shown with show-variables. Note
that setting certain variables, such as the cursor position, will
have side effects, i.e., modifying the display. If these are
distracting, use ~hidden or ~quiet to suppress display updates
until the macro completes.</p>
<p>[1] Subject to the limitations described above for "<a href=
"#modevars">Mode variables</a>". Namely, "global values of the
editor modes are not visible to the expression evaluator."</p>
<h3 id="withblocks-toc">~<a name="withblocks" id=
"withblocks">with, ~elsewith and ~endwith</a></h3>
<p>Tokens following the ~with directive will be prepended to
succeeding lines of macro until the next ~endwith directive, or
the end of the current macro. This is useful for simplifying
majormode directives, which are repetitive. Use ~elsewith as a
convenience for fences; otherwise it functions just as ~with
does.</p>
<p>For example, use</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">define-mode</font></strong> <em>txt</em><br>
<font color="#008000">~with</font> <strong><font color=
"#000080">define-submode</font></strong> <em>txt</em><br>
<strong><font color="#000080">suf</font></strong> <font color="#800080">"\\.txt$"</font><br>
<strong><font color="#000080">comment-prefix</font></strong> <font color="#800080">"^\\s*/\\?--"</font><br>
<strong><font color="#000080">comments</font></strong> <font color="#800080">"^\\s*/\\?--\\s+/\\?\\s*$"</font><br>
<font color="#008000">~endwith</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>rather than</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">define-mode</font></strong> <em>txt</em><br>
<strong><font color=
"#000080">define-submode</font></strong> <em>txt</em> <strong><font color="#000080">suf</font></strong> <font color="#800080">"\\.txt$"</font><br>
<strong><font color=
"#000080">define-submode</font></strong> <em>txt</em> <strong><font color="#000080">comment-prefix</font></strong> <font color="#800080">"^\\s*/\\?--"</font><br>
<strong><font color=
"#000080">define-submode</font></strong> <em>txt</em> <strong><font color="#000080">comments</font></strong> <font color="#800080">"^\\s*/\\?--\\s+/\\?\\s*$"</font><br>
<!--atr2html}}--></p>
</blockquote>
<h3 id="tracing-toc">~<a name="tracing" id=
"tracing">trace</a></h3>No program is complete without a few
bugs. Use vile's builtin macro tracing to see what the macros
really do. The ~trace command sets the $debug variable, which
controls whether vile appends to the [Trace] buffer a copy of
each line executed, the local variables saved/restored and
intermediate states of expression evaluation.
<p>For example,</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008000">~trace</font> on<br>
<!--atr2html}}--></p>
</blockquote>
<p>activates tracing,</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008000">~trace</font> off<br>
<!--atr2html}}--></p>
</blockquote>
<p>deactivates it, and</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008000">~trace</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>prints a message telling if tracing is active.</p>
<h2 id="commands-toc"><a name="commands" id="commands">Editor
commands</a></h2>
<p>The "show-commands" command lists _all_ available editor
commands. This is, admittedly, a large list and generally grows
with successive releases of the editor. Fortunately, most editor
commands include short help strings that describe their purpose.
To winnow the list to a particular area of interest, use the
"apropos" command (e.g., "apropos append"). To determine the
command bound to a specific key, use "describe-key". The format
of the apropos, describe-key, and show-commands listing is as
follows:</p>
<blockquote>
<pre class="code-block">
command-name optional-key-binding(s)
optional-command-name-aliases
(help-string)
</pre>
</blockquote>
<p>Commands fall into three broad categories: simple, motion,
operator.</p>
<h3 id="simplecommands-toc"><a name="simplecommands" id=
"simplecommands">Simple commands</a></h3>A simple command neither
acts on a region nor does it explicitly move the cursor through a
region (the "region" concept is explained in the "Motion
commands" section below). An example of a simple command is
"find-tag", and here's the listing returned by show-commands:
<blockquote>
<pre class="code-block">
"find-tag" ^]
or "ta"
or "tag"
( look up the given (or under-cursor) name as a "tag" )
</pre>
</blockquote>
<p>From the perspective of writing a macro, it can be seen that
find-tag has two aliases, either of which may be substituted for
the "find-tag" name within a macro definition. Notice that the
help string mentions a "name" argument and sure enough, if you
type ":find-tag" within the editor, you'll be prompted for a "Tag
name". This gives us enough information to write a contrived
macro that finds a fixed tag name:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> tryit</font><br>
<strong><font color="#000080">tag</font></strong> <font color="#800080">"filterregion"</font><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>Note also that some help strings include a "CNT" keyword,
which indicates that the command name may be preceded by an
integer count that repeats the command action that many times
(default CNT value is 1). For example, here's the "join-lines"
listing:</p>
<pre>
"join-lines" J
( join CNT lines together with the current one )
</pre>And here's a macro that joins 4 lines:
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> join4</font><br>
<strong><font color="#008080">4</font></strong> <strong><font color="#000080">join-lines</font></strong><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<h3 id="motioncommands-toc"><a name="motioncommands" id=
"motioncommands">Motion commands</a></h3>Motions move the cursor
and, consequently, may be used to define a region. This latter
property is an important aspect of an "operator command". The
"show-motions" command lists the editor's motion commands.
<p>Within a macro, the following general syntax invokes a
motion:</p>
<blockquote>
<pre class="code-block">
[count] region-spec
</pre>
</blockquote>
<p>The optional "count" specifies the number of affected
region-specs (default value is 1). An example motion is
"back-line", and here is its show-commands listing:</p>
<blockquote>
<pre class="code-block">
"back-line" k #-A
or "previous-line"
or "up-arrow"
or "up-line"
(motion: move up CNT lines )
</pre>
</blockquote>
<p>Note that the help string is prefixed with the word "motion",
which unambiguously identifies the nature of this command. Given
the above information, we can write a contrived macro to move the
cursor up three lines:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> upthree</font><br>
<strong><font color="#008080">3</font></strong> <strong><font color="#000080">back-line</font></strong><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<h3 id="operatorcommands-toc"><a name="operatorcommands" id=
"operatorcommands">Operator commands</a></h3>
<p>Operators manipulate regions. The "show-operators" command
lists the editor's operator commands. By convention, most
operator names end with "-til" (short for "until").</p>
<p>Within a macro, the following general syntax invokes an
operator:</p>
<blockquote>
<pre class="code-block">
[count] operator-name region-spec [args...]
</pre>
</blockquote>
<p>where:</p>
<dl>
<dt>region-spec</dt>
<dd>may be replaced with any motion command or the special word
"lines" (the latter is a synonym for a single buffer
line).</dd>
<dt>count</dt>
<dd>optionally specifies the number of region-specs affected by
operator-name (default value is 1).</dd>
<dt>args</dt>
<dd>denotes optional string arguments(s) required by some
operators (e.g., "filter-til").</dd>
</dl>An example operator is "flip-til", and here's its
show-commands info:
<blockquote>
<pre class="code-block">
"flip-til" ^A-~
or "~"
(operator: exchange upper and lowercase on characters in the
region) (may follow global command)
</pre>
</blockquote>
<p>A salient point to note within the help string is the
"operator" keyword, which unambiguously identifies the purpose of
this command. Given the above information, we can write a macro
to flip the case of the current paragraph.</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> flippara</font><br>
<strong><font color="#000080">up-paragraph</font></strong> <font color="#800000">; move to beginning of para</font><br>
<strong><font color="#000080">flip-til</font></strong> <strong><font color="#000080">down-paragraph</font></strong> <font color="#800000">; flip case of entire para</font><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>One might be tempted to bind this macro to a key using this
syntax:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">bind-key</font></strong> flippara <strong><font color="#000080">g</font></strong><br>
<!--atr2html}}--></p>
</blockquote>
<p>and then attempt to use a numerical argument to control the
number of affected paragraphs. I.E., type "3g" to flip three
paragraphs. But this actually invokes "flippara" three times in a
row, which (due to the sequential up- and down-paragraph
motions), flips the case of the _same_ paragraph three times.
However, we can workaround that obstacle with the use of an
interactive variable:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> flippara</font><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%dflt</font> <strong><font color=
"#008080">1</font></strong><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%quest</font> @<font color=
"#008080">&cat</font> <font color=
"#008080">&cat</font> <font color=
"#800080">"Flip how many para ["</font> <font color="#008080">%dflt</font> <font color="#800080">"]? "</font><br>
<font color=
"#008000">~if</font> <font color=
"#008080">&sequal</font> <font color=
"#008080">%quest</font> <font color=
"#800080">""</font><br>
<strong><font color="#000080">setv</font></strong> <font color="#008080">%quest</font> <font color="#008080">%dflt</font><br>
<font color="#008000">~endif</font><br>
<strong><font color=
"#000080">up-paragraph</font></strong><br>
<font color=
"#008080">%quest</font> <strong><font color=
"#000080">flip-til</font></strong> <strong><font color=
"#000080">down-paragraph</font></strong><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<h2 id="debuggingmacros-toc"><a name="debuggingmacros" id=
"debuggingmacros">Debugging macros</a></h2>
<p>vile's popup-msgs mode pops up the [Messages] buffer to show
text written to the message line. Closing the [Messages] buffer
window clears its content until the next message is written. This
mode is most useful when debugging macros, since many messages
may appear, each overwriting a previous one.</p>
<p>Let's use this macro fragment for illustration:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008000">~if</font> <font color=
"#008080">&greater</font> <font color=
"#008080">$blines</font> <strong><font color=
"#008080">0</font></strong><br>
<font color=
"#800000">; buffer has at least one line of data, proceed</font><br>
<font color="#008000">~else</font><br>
<font color=
"#800000">; this is unexpected!</font><br>
<font color="#008000">~endif</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>Suppose the macro is taking the unexpected code path in one of
several buffers, but you don't know which. To trace the path,
modify the macro like so:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<font color="#008000">~if</font> <font color=
"#008080">&greater</font> <font color=
"#008080">$blines</font> <strong><font color=
"#008080">0</font></strong><br>
<font color=
"#800000">; buffer has at least one line of data, proceed</font><br>
<font color="#008000">~else</font><br>
<font color=
"#800000">; this is unexpected!</font><br>
<strong><font color="#000080">setv</font></strong> <font color="#008080">%msg</font> <font color="#008080">&cat</font> <font color="#800080">"Error: Buffer "</font> <font color="#008080">&cat</font> <font color="#008080">$cbufname</font> <font color="#800080">" empty"</font><br>
<strong><font color="#000080">write-message</font></strong> <font color="#008080">%msg</font><br>
<font color="#008000">~endif</font><br>
<!--atr2html}}--></p>
</blockquote>
<p>Next, enable popup-msgs (i.e., set popup-msgs) and then start
the macro. When the "write-message" command is executed, the
[Messages] buffer pops up and displays the string written by the
unexpected code path.</p>
<p>Disable popup-msgs using this command:</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
:<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">nopopup-msgs</font></strong><br>
<!--atr2html}}--></p>
</blockquote>
<h2 id="example-toc"><a name="example" id="example">Example
startup file</a></h2>
<p>The startup file included below illustrates several of the
language constructs described in this document. This example is
crafted for the win32 environment, but its syntax and usage are
applicable to any host OS supported by vile.</p>
<blockquote>
<!--{{atr2html-->
<p style="font-family: monospace;" class="code-block">
<strong><font color=
"#000080">set</font></strong> <strong><font color=
"#000080">ai</font></strong> <strong><font color=
"#000080">aw</font></strong> <strong><font color=
"#000080">ts</font></strong><strong><font color=
"#800000">=</font></strong><strong><font color=
"#008080">4</font></strong> <strong><font color=
"#000080">sw</font></strong><strong><font color=
"#800000">=</font></strong><strong><font color=
"#008080">4</font></strong> <strong><font color=
"#000080">flash</font></strong><br>
<strong><font color=
"#000080">bind-key</font></strong> <strong><font color=
"#000080">next-window</font></strong> <font color=
"#800080">^N</font><br>
<strong><font color=
"#000080">bind-key</font></strong> <strong><font color=
"#000080">previous-window</font></strong> <font color=
"#800080">^P</font><br>
<br>
<font color="#008000">~if</font> <font color=
"#008080">&sequal</font> <font color=
"#008080">$progname</font> <font color=
"#800080">"winvile"</font><br>
<strong><font color=
"#000080">set-variable</font></strong> <font color=
"#008080">$font</font> <font color=
"#800080">"r_ansi,8"</font><br>
<font color="#008000">~endif</font><br>
<font color="#008000">~if</font> <font color=
"#008080">&equal</font> <strong><font color=
"#008080">0</font></strong> <font color=
"#008080">&sindex</font> <font color=
"#008080">&lower</font> <font color=
"#008080">$shell</font> <font color=
"#800080">"command.com"</font><br>
<strong><font color=
"#000080">set</font></strong> w32pipes<br>
<font color="#008000">~else</font><br>
<strong><font color=
"#000080">set</font></strong> now32pipes<br>
<font color="#008000">~endif</font><br>
<br>
<font color="#008000">~if</font> <font color=
"#008080">&not</font> <font color=
"#008080">&equal</font> <strong><font color=
"#008080">0</font></strong> <font color=
"#008080">&sindex</font> <font color=
"#008080">$cfgopts</font> <font color=
"#800080">"perl"</font><br>
<strong><font color=
"#000080">perl</font></strong> <font color=
"#800080">"use hgrep"</font><br>
<strong><font color=
"#000080">perl</font></strong> <font color=
"#800080">"use dirlist"</font><br>
<font color="#008000">~endif</font><br>
<br>
<font color="#008000">~if</font> <font color=
"#008080">&not</font> <font color=
"#008080">&equal</font> <strong><font color=
"#008080">0</font></strong> <font color=
"#008080">&sindex</font> <font color=
"#008080">$cfgopts</font> <font color=
"#800080">"oleauto"</font><br>
<strong><font color=
"#000080">set</font></strong> redirect-keys<strong><font color="#800000">=</font></strong><font color="#008080">&cat</font> <font color="#008080">&global</font> redirect-keys <font color="#800080">",MULTIPLY:A:S"</font><br>
<font color="#008000">~endif</font><br>
<br>
<font color=
"#800000">; modify ^A-i and ^A-o so that they don't wrap inserted text.</font><br>
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> save-wrap-state</font><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%wm</font><strong><font color=
"#800000">=</font></strong><font color=
"#008080">$wrapmargin</font><br>
<strong><font color=
"#000080">setv</font></strong> <font color=
"#008080">%ww</font><strong><font color=
"#800000">=</font></strong><font color=
"#008080">$wrapwords</font><br>
<strong><font color=
"#000080">setl</font></strong> <strong><font color=
"#000080">nowrapwords</font></strong> <strong><font color=
"#000080">wm</font></strong><strong><font color=
"#800000">=</font></strong><strong><font color=
"#008080">0</font></strong><br>
<font color="#008000">~endm</font><br>
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> restore-wrap-state</font><br>
<strong><font color=
"#000080">setl</font></strong> <strong><font color=
"#000080">wrapmargin</font></strong><strong><font color=
"#800000">=</font></strong><font color="#008080">%wm</font><br>
<font color=
"#008000">~if</font> <font color="#008080">%ww</font><br>
<strong><font color="#000080">setl</font></strong> <strong><font color="#000080">wrapwords</font></strong><br>
<font color="#008000">~else</font><br>
<strong><font color="#000080">setl</font></strong> <strong><font color="#000080">nowrapwords</font></strong><br>
<font color="#008000">~endif</font><br>
<font color="#008000">~endm</font><br>
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> insert-chars-noai-nowrap</font><br>
save-wrap-state<br>
<strong><font color=
"#000080">insert-chars-no-autoindent</font></strong><br>
restore-wrap-state<br>
<font color="#008000">~endm</font><br>
<strong><font color=
"#000080">bind-key</font></strong> insert-chars-noai-nowrap <font color="#800080">^A-i</font><br>
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> open-line-below-noai-nowrap</font><br>
save-wrap-state<br>
<strong><font color=
"#000080">open-line-below-no-autoindent</font></strong><br>
restore-wrap-state<br>
<font color="#008000">~endm</font><br>
<strong><font color=
"#000080">bind-key</font></strong> open-line-below-noai-nowrap <font color="#800080">^A-o</font><br>
<br>
<font color=
"#800000">;Rather than composing documents in a word processor, it's much</font><br>
<font color=
"#800000">;more efficient to use vile. But pasting vile-formatted text into,</font><br>
<font color=
"#800000">;say, MS Word is a pain in the neck because each paragraph needs</font><br>
<font color=
"#800000">;to be reformatted. Example:</font><br>
<font color="#800000">;</font><br>
<font color=
"#800000">; vile txt</font><br>
<font color=
"#800000">; ========</font><br>
<font color=
"#800000">; para 1 line1,</font><br>
<font color=
"#800000">; line 2,</font><br>
<font color=
"#800000">; line 3,</font><br>
<font color=
"#800000">; line 4</font><br>
<font color="#800000">;</font><br>
<font color=
"#800000">; para 2 line 1,</font><br>
<font color=
"#800000">; line 2,</font><br>
<font color=
"#800000">; line 3,</font><br>
<font color=
"#800000">; line 4</font><br>
<font color="#800000">;</font><br>
<font color=
"#800000">;If "vile txt" is copied and pasted into Word, it looks awful because</font><br>
<font color=
"#800000">;the lines of the paragraphs do not flow together (i.e., the new lines</font><br>
<font color=
"#800000">;terminating each vile paragraph serve as a "hard" paragraph break).</font><br>
<font color="#800000">;</font><br>
<font color=
"#800000">;'Twould be nice if vile could join each paragraph so that "vile txt"</font><br>
<font color=
"#800000">;above looked like this:</font><br>
<font color="#800000">;</font><br>
<font color=
"#800000">; vile txt</font><br>
<font color=
"#800000">; ========</font><br>
<font color=
"#800000">; para 1 line1, line 2, line 3, line 4</font><br>
<font color="#800000">;</font><br>
<font color=
"#800000">; para 2 line 1, line 2, line 3, line 4</font><br>
<font color="#800000">;</font><br>
<font color=
"#800000">;Then, when this version is pasted into Word, all paragraphs are</font><br>
<font color=
"#800000">;automatically reformatted. Here's a macro that adds this feature:</font><br>
<strong><font color=
"#000080">store-procedure</font></strong><font color=
"#800080"> join-all-para</font><br>
<strong><font color=
"#000080">goto-beginning-of-file</font></strong><br>
<strong><font color=
"#000080">write-message</font></strong> <font color=
"#800080">"[joining all paragraphs...]"</font><br>
<font color=
"#008000">~while</font> true<br>
<font color=
"#008000">~force</font> <strong><font color=
"#000080">join-lines-til</font></strong> <strong><font color="#000080">down-paragraph</font></strong><br>
<font color=
"#008000">~if</font> <font color=
"#008080">&not</font> <font color=
"#008080">$status</font><br>
<font color="#008000">~break</font><br>
<font color=
"#008000">~endif</font><br>
<strong><font color="#000080">goto-bol</font></strong><br>
<font color=
"#008000">~force</font> <strong><font color=
"#008080">2</font></strong> <strong><font color=
"#000080">down-line</font></strong> <font color=
"#800000">;skip to next para</font><br>
<font color=
"#008000">~if</font> <font color=
"#008080">&not</font> <font color=
"#008080">$status</font><br>
<font color="#008000">~break</font><br>
<font color=
"#008000">~endif</font><br>
<font color=
"#008000">~endwhile</font><br>
<font color="#008000">~endm</font><br>
<!--atr2html}}--></p>
</blockquote>
<h2 id="credits-toc"><a name="credits" id=
"credits">Credits</a></h2>
<p>This document, and the macro language it describes, owes a
debt of thanks to Dan Lawrence and his MicroEMACS text editor.
Many of the features described herein first appeared in this form
in MicroEMACS.</p>
</body>
</html>
|