/usr/share/doc/vim-doc/html/starting.html is in vim-doc 2:7.4.1689-3ubuntu1.
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 | <HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: starting</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: starting</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>
<HR>
<PRE>
*<A NAME="starting.txt"></A><B>starting.txt</B>* For Vim version 7.4. Last change: 2016 Mar 26
VIM REFERENCE MANUAL by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>
Starting Vim *<A NAME="starting"></A><B>starting</B>*
1. Vim arguments |<A HREF="#vim-arguments">vim-arguments</A>|
2. Vim on the <A HREF="os_amiga.html#Amiga">Amiga</A> |<A HREF="#starting-amiga">starting-amiga</A>|
3. Running eVim |<A HREF="#evim-keys">evim-keys</A>|
4. Initialization |<A HREF="#initialization">initialization</A>|
5. $VIM and <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A> |<A HREF="#$VIM">$VIM</A>|
6. Suspending |<A HREF="#suspend">suspend</A>|
7. Exiting |<A HREF="#exiting">exiting</A>|
8. Saving settings |<A HREF="#save-settings">save-settings</A>|
9. Views and Sessions |<A HREF="#views-sessions">views-sessions</A>|
10. The viminfo file |<A HREF="#viminfo-file">viminfo-file</A>|
==============================================================================
1. Vim arguments *<A NAME="vim-arguments"></A><B>vim-arguments</B>*
Most often, Vim is started to edit a single file with the command
vim filename *<A NAME="-vim"></A><B>-vim</B>*
More generally, Vim is started with:
vim [option | filename] ..
Option arguments and file name arguments can be mixed, and any number of them
can be given. However, watch out for <A HREF="options.html#options">options</A> that take an argument.
For compatibility with various <A HREF="intro.html#Vi">Vi</A> versions, see |<A HREF="vi_diff.html#cmdline-arguments">cmdline-arguments</A>|.
Exactly one out of the following five items may be used to choose how to
start editing:
*<A NAME="-file"></A><B>-file</B>* *<A NAME="---"></A><B>---</B>*
filename One or more file names. The first one will be the current
file and read into the buffer. The cursor will be positioned
on the first line of the buffer.
To avoid a file name starting with a '<A HREF="motion.html#-">-</A>' being interpreted <A HREF="motion.html#as">as</A>
an option, precede the <A HREF="editing.html#arglist">arglist</A> with "<A HREF="#--">--</A>", e.g.:
<B> vim -- -filename</B>
All arguments after the "<A HREF="#--">--</A>" will be interpreted <A HREF="motion.html#as">as</A> file names,
no other <A HREF="options.html#options">options</A> or "+command" argument can follow.
For behavior of quotes on <A HREF="os_win32.html#MS-Windows">MS-Windows</A>, see |<A HREF="os_win32.html#win32-quotes">win32-quotes</A>|.
*<A NAME="--"></A><B>--</B>*
- This argument can mean two things, depending on whether <A HREF="intro.html#Ex">Ex</A>
mode is to be used.
Starting in <A HREF="intro.html#Normal">Normal</A> mode:
<B> vim -</B>
<B> ex -v -</B>
Start editing a new buffer, which is filled with text
that is read from stdin. The commands that would normally be
read from stdin will now be read from stderr. Example:
<B> find . -name "*.c" -print | vim -</B>
The buffer will be marked modified, because <A HREF="motion.html#it">it</A> contains text
that needs to be saved. Except when in readonly mode, then
the buffer is not marked modified. Example:
<B> ls | view -</B>
Starting in <A HREF="intro.html#Ex">Ex</A> mode:
<B> ex -</B>
<B> vim -e -</B>
<B> exim -</B>
<B> vim -E</B>
Start editing in silent mode. See |<A HREF="#-s-ex">-s-ex</A>|.
*<A NAME="-t"></A><B>-t</B>* *<A NAME="-tag"></A><B>-tag</B>*
<A HREF="#-t">-t</A> {tag} A <A HREF="tagsrch.html#tag">tag</A>. "<A HREF="tagsrch.html#tag">tag</A>" is looked up in the <A HREF="tagsrch.html#tags">tags</A> file, the associated
file becomes the current file, and the associated command is
executed. Mostly this is used for C programs, in which <A HREF="change.html#case">case</A>
"<A HREF="tagsrch.html#tag">tag</A>" often is a function name. The effect is that the file
containing that function becomes the current file and the
cursor is positioned on the start of the function (see
|<A HREF="tagsrch.html#tags">tags</A>|).
*<A NAME="-q"></A><B>-q</B>* *<A NAME="-qf"></A><B>-qf</B>*
<A HREF="#-q">-q</A> [errorfile] QuickFix mode. The file with the name [errorfile] is read
and the first error is displayed. See |<A HREF="quickfix.html#quickfix">quickfix</A>|.
If [errorfile] is not given, the <A HREF="options.html#'errorfile'">'errorfile'</A> option is used
for the file name. See <A HREF="options.html#'errorfile'">'errorfile'</A> for the default value.
{not in Vi}
(nothing) Without one of the four items above, Vim will start editing a
new buffer. It's empty and doesn't have a file name.
The <A HREF="#startup">startup</A> mode can be changed by using another name instead of "vim", which
is equal to giving <A HREF="options.html#options">options</A>:
<A HREF="#ex">ex</A> vim <A HREF="#-e">-e</A> Start in Ex mode (see |<A HREF="intro.html#Ex-mode">Ex-mode</A>|). *<A NAME="ex"></A><B>ex</B>*
<A HREF="#exim">exim</A> vim <A HREF="#-E">-E</A> Start in improved Ex mode (see |<A HREF="intro.html#Ex-mode">Ex-mode</A>|). *<A NAME="exim"></A><B>exim</B>*
(normally not installed)
<A HREF="#view">view</A> vim -R Start in read-only mode (see |<A HREF="#-R">-R</A>|). *<A NAME="view"></A><B>view</B>*
<A HREF="#gvim">gvim</A> vim <A HREF="#-g">-g</A> Start the <A HREF="gui.html#GUI">GUI</A> (see |<A HREF="gui.html#gui">gui</A>|). *<A NAME="gvim"></A><B>gvim</B>*
<A HREF="#gex">gex</A> vim -eg Start the <A HREF="gui.html#GUI">GUI</A> in <A HREF="intro.html#Ex">Ex</A> mode. *<A NAME="gex"></A><B>gex</B>*
<A HREF="#gview">gview</A> vim -Rg Start the <A HREF="gui.html#GUI">GUI</A> in read-only mode. *<A NAME="gview"></A><B>gview</B>*
<A HREF="#rvim">rvim</A> vim -Z Like "vim", but in restricted mode (see |<A HREF="#-Z">-Z</A>|) *<A NAME="rvim"></A><B>rvim</B>*
<A HREF="#rview">rview</A> vim -RZ Like "<A HREF="#view">view</A>", but in restricted mode. *<A NAME="rview"></A><B>rview</B>*
<A HREF="#rgvim">rgvim</A> vim -gZ Like "<A HREF="#gvim">gvim</A>", but in restricted mode. *<A NAME="rgvim"></A><B>rgvim</B>*
<A HREF="#rgview">rgview</A> vim -RgZ Like "<A HREF="#gview">gview</A>", but in restricted mode. *<A NAME="rgview"></A><B>rgview</B>*
<A HREF="#evim">evim</A> vim -y Easy Vim: set <A HREF="options.html#'insertmode'">'insertmode'</A> (see |<A HREF="#-y">-y</A>|) *<A NAME="evim"></A><B>evim</B>*
<A HREF="#eview">eview</A> vim -yR Like "<A HREF="#evim">evim</A>" in read-only mode *<A NAME="eview"></A><B>eview</B>*
<A HREF="diff.html#vimdiff">vimdiff</A> vim <A HREF="#-d">-d</A> Start in diff mode |<A HREF="diff.html#diff-mode">diff-mode</A>|
<A HREF="diff.html#gvimdiff">gvimdiff</A> vim -gd Start in diff mode |<A HREF="diff.html#diff-mode">diff-mode</A>|
Additional characters may follow, they are ignored. For example, you can have
"gvim-5" to start the <A HREF="gui.html#GUI">GUI</A>. You must have an executable by that name then, of
course.
On <A HREF="os_unix.html#Unix">Unix</A>, you would normally have one executable called Vim, and links from the
different startup-names to that executable. If your system does not support
links and you <A HREF="diff.html#do">do</A> not want to have several copies of the executable, you could
use an alias instead. For example:
<B> alias view vim -R</B>
<B> alias gvim vim -g</B>
*<A NAME="startup-options"></A><B>startup-options</B>*
The option arguments may be given in any order. Single-letter <A HREF="options.html#options">options</A> can be
combined after one dash. There can be no option arguments after the "<A HREF="#--">--</A>"
argument.
On <A HREF="os_vms.html#VMS">VMS</A> all option arguments are assumed to be <A HREF="change.html#lowercase">lowercase</A>, unless preceded with
a slash. Thus "<A HREF="#-R">-R</A>" means <A HREF="recover.html#recovery">recovery</A> and "-/R" readonly.
<A HREF="#--help">--help</A> *<A NAME="-h"></A><B>-h</B>* *<A NAME="--help"></A><B>--help</B>*
<A HREF="#-h">-h</A> Give usage (help) message and exit. {not in Vi}
See |<A HREF="#info-message">info-message</A>| about capturing the text.
*<A NAME="--version"></A><B>--version</B>*
<A HREF="#--version">--version</A> Print version information and exit. Same output <A HREF="motion.html#as">as</A> for
|<A HREF="various.html#:version">:version</A>| command. {not in Vi}
See |<A HREF="#info-message">info-message</A>| about capturing the text.
*<A NAME="--noplugin"></A><B>--noplugin</B>*
<A HREF="#--noplugin">--noplugin</A> Skip loading plugins. Resets the <A HREF="options.html#'loadplugins'">'loadplugins'</A> option.
{not in Vi}
Note that the |<A HREF="#-u">-u</A>| argument may also disable loading plugins:
<B><FONT COLOR="PURPLE"> argument load vimrc files load plugins </FONT></B>
(nothing) yes yes
<A HREF="#-u">-u</A> NONE no no
<A HREF="#-u">-u</A> NORC no yes
<A HREF="#--noplugin">--noplugin</A> yes no
<A HREF="#--startuptime">--startuptime</A> {fname} *<A NAME="--startuptime"></A><B>--startuptime</B>*
During <A HREF="#startup">startup</A> write timing <A HREF="message.html#messages">messages</A> to the file {fname}.
This can be used to find out where time is spent while loading
your <A HREF="#.vimrc">.vimrc</A>, plugins and opening the first file.
When {fname} already exists new <A HREF="message.html#messages">messages</A> are appended.
(Only available when compiled with the |<A HREF="various.html#+startuptime">+startuptime</A>|
feature).
*<A NAME="--literal"></A><B>--literal</B>*
<A HREF="#--literal">--literal</A> Take file names literally, don't expand <A HREF="editing.html#wildcards">wildcards</A>. Not needed
for <A HREF="os_unix.html#Unix">Unix</A>, because Vim always takes file names literally (the
shell expands <A HREF="editing.html#wildcards">wildcards</A>).
Applies to all the names, also the ones that come before this
argument.
*<A NAME="-+"></A><B>-+</B>*
+[num] The cursor will be positioned on line "num" for the first
file being edited. If "num" is missing, the cursor will be
positioned on the last line.
*<A NAME="-+/"></A><B>-+/</B>*
+/{pat} The cursor will be positioned on the first line containing
"pat" in the first file being edited (see |<A HREF="pattern.html#pattern">pattern</A>| for the
available search patterns). The search starts at the cursor
position, which can be the first line or the cursor position
last used from |<A HREF="#viminfo">viminfo</A>|. To force a search from the first
line use "+1 +/pat".
+{command} *<A NAME="-+c"></A><B>-+c</B>* *<A NAME="-c"></A><B>-c</B>*
<A HREF="#-c">-c</A> {command} {command} will be executed after the first file has been
read (and after autocommands and modelines for that file have
been processed). "command" is interpreted <A HREF="motion.html#as">as</A> an <A HREF="intro.html#Ex">Ex</A> command.
If the "command" contains spaces, <A HREF="motion.html#it">it</A> must be enclosed in
double <A HREF="quotes.html#quotes">quotes</A> (this depends on the shell that is used).
Example:
<B> vim "+set si" main.c</B>
<B> vim "+find stdio.h"</B>
<B> vim -c "set ff=dos" -c wq mine.mak</B>
Note: You can use up to 10 "<A HREF="motion.html#+">+</A>" or "<A HREF="#-c">-c</A>" arguments in a Vim
command. They are executed in the order given. A "<A HREF="#-S">-S</A>"
argument counts <A HREF="motion.html#as">as</A> a "<A HREF="#-c">-c</A>" argument <A HREF="motion.html#as">as</A> well.
{Vi only allows one command}
<A HREF="#--cmd">--cmd</A> {command} *<A NAME="--cmd"></A><B>--cmd</B>*
{command} will be executed before processing any <A HREF="#vimrc">vimrc</A> file.
Otherwise <A HREF="motion.html#it">it</A> acts like <A HREF="#-c">-c</A> {command}. You can use up to 10 of
these commands, independently from "<A HREF="#-c">-c</A>" commands.
{not in Vi}
*<A NAME="-S"></A><B>-S</B>*
<A HREF="#-S">-S</A> <A HREF="editing.html#{file}">{file}</A> The <A HREF="editing.html#{file}">{file}</A> will be sourced after the first file has been read.
This is an <A HREF="#easy">easy</A> way to <A HREF="diff.html#do">do</A> the equivalent of:
<B> -c "source {file}"</B>
It can be mixed with "<A HREF="#-c">-c</A>" arguments and repeated like "<A HREF="#-c">-c</A>".
The limit of 10 "<A HREF="#-c">-c</A>" arguments applies here <A HREF="motion.html#as">as</A> well.
<A HREF="editing.html#{file}">{file}</A> cannot start with a "<A HREF="motion.html#-">-</A>".
{not in Vi}
<A HREF="#-S">-S</A> Works like "<A HREF="#-S">-S</A> Session.vim". Only when used <A HREF="motion.html#as">as</A> the last
argument or when another "<A HREF="motion.html#-">-</A>" option follows.
*<A NAME="-r"></A><B>-r</B>*
<A HREF="#-r">-r</A> Recovery mode. Without a file name argument, a <A HREF="eval.html#list">list</A> of
existing swap files is given. With a file name, a swap file
is read to recover a crashed editing session. See
|<A HREF="recover.html#crash-recovery">crash-recovery</A>|.
*<A NAME="-L"></A><B>-L</B>*
<A HREF="#-L">-L</A> Same <A HREF="motion.html#as">as</A> <A HREF="#-r">-r</A>. {only in some versions of <A HREF="intro.html#Vi">Vi</A>: "<A HREF="eval.html#List">List</A> recoverable
edit sessions"}
*<A NAME="-R"></A><B>-R</B>*
<A HREF="#-R">-R</A> Readonly mode. The <A HREF="options.html#'readonly'">'readonly'</A> option will be set for all the
files being edited. You can still edit the buffer, but will
be prevented from accidentally overwriting a file. If you
forgot that you are in <A HREF="#View">View</A> mode and did make some changes,
you can overwrite a file by adding an exclamation <A HREF="motion.html#mark">mark</A> to
the <A HREF="intro.html#Ex">Ex</A> command, <A HREF="motion.html#as">as</A> in "<A HREF="editing.html#:w!">:w!</A>". The <A HREF="options.html#'readonly'">'readonly'</A> option can be
reset with "<A HREF="options.html#:set">:set</A> <A HREF="options.html#'noro'">noro</A>" (see the options chapter, |<A HREF="options.html#options">options</A>|).
Subsequent edits will not be done in readonly mode. Calling
the executable "<A HREF="#view">view</A>" has the same effect <A HREF="motion.html#as">as</A> the <A HREF="#-R">-R</A> argument.
The <A HREF="options.html#'updatecount'">'updatecount'</A> option will be set to 10000, meaning that
the swap file will not be updated automatically very often.
*<A NAME="-m"></A><B>-m</B>*
<A HREF="#-m">-m</A> Modifications not allowed to be written. The <A HREF="options.html#'write'">'write'</A> option
will be reset, so that <A HREF="editing.html#writing">writing</A> files is disabled. However,
the <A HREF="options.html#'write'">'write'</A> option can be set to enable <A HREF="editing.html#writing">writing</A> again.
{not in Vi}
*<A NAME="-M"></A><B>-M</B>*
<A HREF="#-M">-M</A> Modifications not allowed. The <A HREF="options.html#'modifiable'">'modifiable'</A> option will be
reset, so that changes are not allowed. The <A HREF="options.html#'write'">'write'</A> option
will be reset, so that <A HREF="editing.html#writing">writing</A> files is disabled. However,
the <A HREF="options.html#'modifiable'">'modifiable'</A> and <A HREF="options.html#'write'">'write'</A> <A HREF="options.html#options">options</A> can be set to enable
changes and <A HREF="editing.html#writing">writing</A>.
{not in Vi}
*<A NAME="-Z"></A><B>-Z</B>* *<A NAME="restricted-mode"></A><B>restricted-mode</B>* *<A NAME="E145"></A><B>E145</B>*
<A HREF="#-Z">-Z</A> Restricted mode. All commands that make use of an external
shell are disabled. This includes suspending with <A HREF="#CTRL-Z">CTRL-Z</A>,
"<A HREF="various.html#:sh">:sh</A>", filtering, the <A HREF="eval.html#system()">system()</A> function, backtick expansion,
<A HREF="eval.html#delete()">delete()</A>, <A HREF="eval.html#rename()">rename()</A>, <A HREF="eval.html#mkdir()">mkdir()</A>, <A HREF="eval.html#writefile()">writefile()</A>, <A HREF="eval.html#libcall()">libcall()</A>, etc.
{not in Vi}
*<A NAME="-g"></A><B>-g</B>*
<A HREF="#-g">-g</A> Start Vim in <A HREF="gui.html#GUI">GUI</A> mode. See |<A HREF="gui.html#gui">gui</A>|. For the opposite see |<A HREF="#-v">-v</A>|.
{not in Vi}
*<A NAME="-v"></A><B>-v</B>*
<A HREF="#-v">-v</A> Start <A HREF="intro.html#Ex">Ex</A> in <A HREF="intro.html#Vi">Vi</A> mode. Only makes a difference when the
executable is called "<A HREF="#ex">ex</A>" or "<A HREF="#gvim">gvim</A>". For <A HREF="#gvim">gvim</A> the <A HREF="gui.html#GUI">GUI</A> is not
started if possible.
*<A NAME="-e"></A><B>-e</B>*
<A HREF="#-e">-e</A> Start Vim in <A HREF="intro.html#Ex">Ex</A> mode |<A HREF="intro.html#Q">Q</A>|. Only makes a difference when the
executable is not called "<A HREF="#ex">ex</A>".
*<A NAME="-E"></A><B>-E</B>*
<A HREF="#-E">-E</A> Start Vim in improved <A HREF="intro.html#Ex">Ex</A> mode |<A HREF="intro.html#gQ">gQ</A>|. Only makes a difference
when the executable is not called "<A HREF="#exim">exim</A>".
{not in Vi}
*<A NAME="-s-ex"></A><B>-s-ex</B>*
<A HREF="#-s">-s</A> Silent or batch mode. Only when Vim was started <A HREF="motion.html#as">as</A> "<A HREF="#ex">ex</A>" or
when preceded with the "<A HREF="#-e">-e</A>" argument. Otherwise see |<A HREF="#-s">-s</A>|,
which does take an argument while this use of "<A HREF="#-s">-s</A>" doesn't.
To be used when Vim is used to execute <A HREF="intro.html#Ex">Ex</A> commands from a file
instead of a terminal. Switches off most prompts and
informative <A HREF="message.html#messages">messages</A>. Also warnings and error <A HREF="message.html#messages">messages</A>.
The output of these commands is displayed (to stdout):
<A HREF="various.html#:print">:print</A>
<A HREF="various.html#:list">:list</A>
<A HREF="various.html#:number">:number</A>
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'to'">to</A> display option values.
When <A HREF="options.html#'verbose'">'verbose'</A> is non-zero <A HREF="message.html#messages">messages</A> are printed (for
debugging, to stderr).
<A HREF="options.html#'term'">'term'</A> and $TERM are not used.
If Vim appears to be stuck try typing "qa!<Enter>". You don't
get a prompt thus you can't see Vim is waiting for you to type
something.
Initializations are skipped (except the ones given with the
"<A HREF="#-u">-u</A>" argument).
Example:
<B> vim -e -s < thefilter thefile</B>
*<A NAME="-b"></A><B>-b</B>*
<A HREF="#-b">-b</A> Binary mode. File I/O will only recognize <A HREF="motion.html#<NL>"><NL></A> to separate
lines. The <A HREF="options.html#'expandtab'">'expandtab'</A> option will be reset. The <A HREF="options.html#'textwidth'">'textwidth'</A>
option is set to 0. <A HREF="options.html#'modeline'">'modeline'</A> is reset. The <A HREF="options.html#'binary'">'binary'</A> option
is set. This is done after reading the vimrc/exrc files but
before reading any file in the <A HREF="editing.html#arglist">arglist</A>. See also
|<A HREF="editing.html#edit-binary">edit-binary</A>|. {not in Vi}
*<A NAME="-l"></A><B>-l</B>*
<A HREF="#-l">-l</A> Lisp mode. Sets the <A HREF="options.html#'lisp'">'lisp'</A> and <A HREF="options.html#'showmatch'">'showmatch'</A> <A HREF="options.html#options">options</A> on.
*<A NAME="-A"></A><B>-A</B>*
<A HREF="#-A">-A</A> <A HREF="arabic.html#Arabic">Arabic</A> mode. Sets the <A HREF="options.html#'arabic'">'arabic'</A> option on. (Only when
compiled with the |<A HREF="various.html#+arabic">+arabic</A>| features (which include
|<A HREF="various.html#+rightleft">+rightleft</A>|), otherwise Vim gives an error message
and exits.) {not in Vi}
*<A NAME="-F"></A><B>-F</B>*
<A HREF="#-F">-F</A> <A HREF="farsi.html#Farsi">Farsi</A> mode. Sets the <A HREF="options.html#'fkmap'">'fkmap'</A> and <A HREF="options.html#'rightleft'">'rightleft'</A> <A HREF="options.html#options">options</A> on.
(Only when compiled with |<A HREF="various.html#+rightleft">+rightleft</A>| and |<A HREF="various.html#+farsi">+farsi</A>| features,
otherwise Vim gives an error message and exits.) {not in Vi}
*<A NAME="-H"></A><B>-H</B>*
<A HREF="#-H">-H</A> Hebrew mode. Sets the <A HREF="options.html#'hkmap'">'hkmap'</A> and <A HREF="options.html#'rightleft'">'rightleft'</A> <A HREF="options.html#options">options</A> on.
(Only when compiled with the |<A HREF="various.html#+rightleft">+rightleft</A>| feature, otherwise
Vim gives an error message and exits.) {not in Vi}
*<A NAME="-V"></A><B>-V</B>* *<A NAME="verbose"></A><B>verbose</B>*
-V[N] Verbose. Sets the <A HREF="options.html#'verbose'">'verbose'</A> option to [N] (default: 10).
Messages will be given for each file that is "<A HREF="repeat.html#:source">:source</A>"d and
for reading or <A HREF="editing.html#writing">writing</A> a <A HREF="#viminfo">viminfo</A> file. Can be used to find
out what is happening upon <A HREF="#startup">startup</A> and exit. {not in Vi}
Example:
<B> vim -V8 foobar</B>
-V[N]{filename}
Like <A HREF="#-V">-V</A> and set <A HREF="options.html#'verbosefile'">'verbosefile'</A> to {filename}. The result is
that <A HREF="message.html#messages">messages</A> are not displayed but written to the file
{filename}. {filename} must not start with a digit.
Example:
<B> vim -V20vimlog foobar</B>
*<A NAME="-D"></A><B>-D</B>*
<A HREF="#-D">-D</A> Debugging. Go to debugging mode when executing the first
command from a <A HREF="usr_41.html#script">script</A>. |<A HREF="repeat.html#debug-mode">debug-mode</A>|
{not available when compiled without the |<A HREF="various.html#+eval">+eval</A>| feature}
{not in Vi}
*<A NAME="-C"></A><B>-C</B>*
<A HREF="#-C">-C</A> Compatible mode. Sets the <A HREF="options.html#'compatible'">'compatible'</A> option. You can use
this to get <A HREF="options.html#'compatible'">'compatible'</A>, even though a <A HREF="#.vimrc">.vimrc</A> file exists.
Keep in mind that the command "<A HREF="options.html#:set">:set</A> <A HREF="options.html#'nocompatible'">nocompatible</A>" in some
<A HREF="usr_05.html#plugin">plugin</A> or <A HREF="#startup">startup</A> <A HREF="usr_41.html#script">script</A> overrules this, so you may end up
with <A HREF="options.html#'nocompatible'">'nocompatible'</A> anyway. To find out, use:
<B> :verbose set compatible?</B>
Several plugins won't work with <A HREF="options.html#'compatible'">'compatible'</A> set. You may
want to set <A HREF="motion.html#it">it</A> after <A HREF="#startup">startup</A> this way:
<B> vim "+set cp" filename</B>
Also see |<A HREF="#compatible-default">compatible-default</A>|. {not in Vi}
*<A NAME="-N"></A><B>-N</B>*
<A HREF="#-N">-N</A> Not compatible mode. Resets the <A HREF="options.html#'compatible'">'compatible'</A> option. You can
use this to get <A HREF="options.html#'nocompatible'">'nocompatible'</A>, when there is no <A HREF="#.vimrc">.vimrc</A> file
or when using "<A HREF="#-u">-u</A> NONE".
Also see |<A HREF="#compatible-default">compatible-default</A>|. {not in Vi}
*<A NAME="-y"></A><B>-y</B>* *<A NAME="easy"></A><B>easy</B>*
<A HREF="#-y">-y</A> Easy mode. Implied for |<A HREF="#evim">evim</A>| and |<A HREF="#eview">eview</A>|. Starts with
<A HREF="options.html#'insertmode'">'insertmode'</A> set and behaves like a click-and-type editor.
This sources the <A HREF="usr_41.html#script">script</A> $VIMRUNTIME/evim.vim. Mappings are
set up to work like most click-and-type editors, see
|<A HREF="#evim-keys">evim-keys</A>|. The <A HREF="gui.html#GUI">GUI</A> is started when available.
{not in Vi}
*<A NAME="-n"></A><B>-n</B>*
<A HREF="#-n">-n</A> No swap file will be used. Recovery after a crash will be
impossible. Handy if you want to <A HREF="#view">view</A> or edit a file on a
very slow medium (e.g., a floppy).
Can also be done with "<A HREF="options.html#:set">:set</A> <A HREF="options.html#'updatecount'">updatecount</A>=0". You can switch <A HREF="motion.html#it">it</A>
on again by setting the <A HREF="options.html#'updatecount'">'updatecount'</A> option to some value,
e.g., "<A HREF="options.html#:set">:set</A> <A HREF="options.html#'uc'">uc</A>=100".
NOTE: Don't combine <A HREF="#-n">-n</A> with <A HREF="#-b">-b</A>, making <A HREF="#-nb">-nb</A>, because that has a
different meaning: |<A HREF="#-nb">-nb</A>|.
<A HREF="options.html#'updatecount'">'updatecount'</A> is set to 0 AFTER executing commands from a
<A HREF="#vimrc">vimrc</A> file, but before the <A HREF="gui.html#GUI">GUI</A> initializations. Thus <A HREF="motion.html#it">it</A>
overrides a setting for <A HREF="options.html#'updatecount'">'updatecount'</A> in a <A HREF="#vimrc">vimrc</A> file, but not
in a <A HREF="gui.html#gvimrc">gvimrc</A> file. See |<A HREF="#startup">startup</A>|.
When you want to reduce accesses to the disk (e.g., for a
laptop), don't use "<A HREF="#-n">-n</A>", but set <A HREF="options.html#'updatetime'">'updatetime'</A> and
<A HREF="options.html#'updatecount'">'updatecount'</A> to very big numbers, and type "<A HREF="recover.html#:preserve">:preserve</A>" when
you want to save your work. This way you keep the possibility
for crash <A HREF="recover.html#recovery">recovery</A>.
{not in Vi}
*<A NAME="-o"></A><B>-o</B>*
-o[N] Open N <A HREF="windows.html#windows">windows</A>, split horizontally. If [N] is not given,
one <A HREF="windows.html#window">window</A> is opened for every file given <A HREF="motion.html#as">as</A> argument. If
there is not enough room, only the first few files get a
<A HREF="windows.html#window">window</A>. If there are more <A HREF="windows.html#windows">windows</A> than arguments, the last
few <A HREF="windows.html#windows">windows</A> will be editing an empty file.
{not in Vi}
*<A NAME="-O"></A><B>-O</B>*
-O[N] Open N <A HREF="windows.html#windows">windows</A>, split vertically. Otherwise it's like <A HREF="#-o">-o</A>.
If both the <A HREF="#-o">-o</A> and the <A HREF="#-O">-O</A> option are given, the last one on
the command line determines how the <A HREF="windows.html#windows">windows</A> will be split.
{not in Vi}
*<A NAME="-p"></A><B>-p</B>*
-p[N] Open N <A HREF="intro.html#tab">tab</A> pages. If [N] is not given, one <A HREF="intro.html#tab">tab</A> page is opened
for every file given <A HREF="motion.html#as">as</A> argument. The maximum is set with
<A HREF="options.html#'tabpagemax'">'tabpagemax'</A> pages (default 10). If there are more <A HREF="intro.html#tab">tab</A> pages
than arguments, the last few <A HREF="intro.html#tab">tab</A> pages will be editing an
empty file. Also see |<A HREF="tabpage.html#tabpage">tabpage</A>|.
{not in Vi}
*<A NAME="-T"></A><B>-T</B>*
<A HREF="#-T">-T</A> {terminal} Set the terminal type to "terminal". This influences the
codes that Vim will send to your terminal. This is normally
not needed, because Vim will be able to find out what type
of terminal you are using. (See |<A HREF="term.html#terminal-info">terminal-info</A>|.) {not in Vi}
*<A NAME="--not-a-term"></A><B>--not-a-term</B>*
<A HREF="#--not-a-term">--not-a-term</A> Tells Vim that the user knows that the input and/or output is
not connected to a terminal. This will avoid the warning and
the two second delay that would happen. {not in Vi}
*<A NAME="-d"></A><B>-d</B>*
<A HREF="#-d">-d</A> Start in diff mode, like |<A HREF="diff.html#vimdiff">vimdiff</A>|.
{not in Vi} {not available when compiled without the |<A HREF="various.html#+diff">+diff</A>|
feature}
<A HREF="#-d">-d</A> {device} Only on the <A HREF="os_amiga.html#Amiga">Amiga</A> and when not compiled with the |<A HREF="various.html#+diff">+diff</A>|
feature. Works like "<A HREF="#-dev">-dev</A>".
*<A NAME="-dev"></A><B>-dev</B>*
<A HREF="#-dev">-dev</A> {device} Only on the <A HREF="os_amiga.html#Amiga">Amiga</A>: The {device} is opened to be used for
editing.
Normally you would use this to set the <A HREF="windows.html#window">window</A> position and
size: "<A HREF="#-d">-d</A> con:x/y/width/height", e.g.,
"<A HREF="#-d">-d</A> con:30/10/600/150". But you can also use <A HREF="motion.html#it">it</A> to start
editing on another device, e.g., AUX:. {not in Vi}
*<A NAME="-f"></A><B>-f</B>*
<A HREF="#-f">-f</A> <A HREF="gui.html#GUI">GUI</A>: Do not disconnect from the program that started Vim.
'<A HREF="motion.html#f">f</A>' stands for "foreground". If omitted, the <A HREF="gui.html#GUI">GUI</A> forks a new
process and exits the current one. "<A HREF="#-f">-f</A>" should be used when
<A HREF="#gvim">gvim</A> is started by a program that will wait for the edit
session to finish (e.g., mail or readnews). If you want <A HREF="#gvim">gvim</A>
never to <A HREF="os_unix.html#fork">fork</A>, include '<A HREF="motion.html#f">f</A>' in <A HREF="options.html#'guioptions'">'guioptions'</A> in your |<A HREF="gui.html#gvimrc">gvimrc</A>|.
Careful: You can use "-gf" to start the <A HREF="gui.html#GUI">GUI</A> in the foreground,
but "<A HREF="gui_x11.html#-fg">-fg</A>" is used to specify the foreground color. |<A HREF="gui_x11.html#gui-fork">gui-fork</A>|
<A HREF="os_amiga.html#Amiga">Amiga</A>: Do not restart Vim to open a new <A HREF="windows.html#window">window</A>. This
option should be used when Vim is started by a program that
will wait for the edit session to finish (e.g., mail or
readnews). See |<A HREF="#amiga-window">amiga-window</A>|.
<A HREF="os_win32.html#MS-Windows">MS-Windows</A>: This option is not supported. However, when
running Vim with an installed vim.bat or gvim.bat file <A HREF="motion.html#it">it</A>
works.
{not in Vi}
*<A NAME="--nofork"></A><B>--nofork</B>*
<A HREF="#--nofork">--nofork</A> <A HREF="gui.html#GUI">GUI</A>: Do not <A HREF="os_unix.html#fork">fork</A>. Same <A HREF="motion.html#as">as</A> |<A HREF="#-f">-f</A>|.
*<A NAME="-u"></A><B>-u</B>* *<A NAME="E282"></A><B>E282</B>*
<A HREF="#-u">-u</A> {vimrc} The file {vimrc} is read for initializations. Most other
initializations are skipped; see |<A HREF="#initialization">initialization</A>|. This can
be used to start Vim in a special mode, with special
mappings and settings. A shell alias can be used to make
this <A HREF="#easy">easy</A> to use. For example:
<B> alias vimc vim -u ~/.c_vimrc !*</B>
Also consider using autocommands; see |<A HREF="autocmd.html#autocommand">autocommand</A>|.
When {vimrc} is equal to "NONE" (all uppercase), all
initializations from files and environment <A HREF="eval.html#variables">variables</A> are
skipped, including reading the |<A HREF="gui.html#gvimrc">gvimrc</A>| file when the <A HREF="gui.html#GUI">GUI</A>
starts. Loading plugins is also skipped.
When {vimrc} is equal to "NORC" (all uppercase), this has the
same effect <A HREF="motion.html#as">as</A> "NONE", but loading plugins is not skipped.
Using the "<A HREF="#-u">-u</A>" argument has the side effect that the
<A HREF="options.html#'compatible'">'compatible'</A> option will be on by default. This can have
unexpected effects. See |<A HREF="options.html#'compatible'">'compatible'</A>|.
{not in Vi}
*<A NAME="-U"></A><B>-U</B>* *<A NAME="E230"></A><B>E230</B>*
<A HREF="#-U">-U</A> {gvimrc} The file {gvimrc} is read for initializations when the <A HREF="gui.html#GUI">GUI</A>
starts. Other <A HREF="gui.html#GUI">GUI</A> initializations are skipped. When {gvimrc}
is equal to "NONE", no file is read for <A HREF="gui.html#GUI">GUI</A> initializations at
all. |<A HREF="gui.html#gui-init">gui-init</A>|
Exception: Reading the system-wide menu file is always done.
{not in Vi}
*<A NAME="-i"></A><B>-i</B>*
<A HREF="#-i">-i</A> {viminfo} The file "<A HREF="#viminfo">viminfo</A>" is used instead of the default <A HREF="#viminfo">viminfo</A>
file. If the name "NONE" is used (all uppercase), no <A HREF="#viminfo">viminfo</A>
file is read or written, even if <A HREF="options.html#'viminfo'">'viminfo'</A> is set or when
"<A HREF="#:rv">:rv</A>" or "<A HREF="#:wv">:wv</A>" are used. See also |<A HREF="#viminfo-file">viminfo-file</A>|.
{not in Vi}
*<A NAME="-x"></A><B>-x</B>*
<A HREF="#-x">-x</A> Use <A HREF="editing.html#encryption">encryption</A> to read/write files. Will prompt for a key,
which is then stored in the <A HREF="options.html#'key'">'key'</A> option. All writes will
then use this key to encrypt the text. The '<A HREF="#-x">-x</A>' argument is
not needed when reading a file, because there is a check if
the file that is being read has been encrypted, and Vim asks
for a key automatically. |<A HREF="editing.html#encryption">encryption</A>|
*<A NAME="-X"></A><B>-X</B>*
<A HREF="#-X">-X</A> Do not try connecting to the X server to get the current
<A HREF="windows.html#window">window</A> title and copy/paste using the X <A HREF="gui.html#clipboard">clipboard</A>. This
avoids a long <A HREF="#startup">startup</A> time when running Vim in a terminal
emulator and the connection to the X server is slow.
See |<A HREF="#--startuptime">--startuptime</A>| to find out if affects you.
Only makes a difference on <A HREF="os_unix.html#Unix">Unix</A> or <A HREF="os_vms.html#VMS">VMS</A>, when compiled with the
|<A HREF="various.html#+X11">+X11</A>| feature. Otherwise it's ignored.
To disable the connection only for specific terminals, see the
<A HREF="options.html#'clipboard'">'clipboard'</A> option.
When the <A HREF="options.html#X11">X11</A> <A HREF="#Session">Session</A> Management Protocol (XSMP) handler has
been built in, the <A HREF="#-X">-X</A> option also disables that connection <A HREF="motion.html#as">as</A>
<A HREF="motion.html#it">it</A>, too, may have undesirable delays.
When the connection is desired later anyway (e.g., for
<A HREF="remote.html#client-server">client-server</A> messages), call the |<A HREF="eval.html#serverlist()">serverlist()</A>| function.
This does not enable the XSMP handler though.
{not in Vi}
*<A NAME="-s"></A><B>-s</B>*
<A HREF="#-s">-s</A> {scriptin} The <A HREF="usr_41.html#script">script</A> file "scriptin" is read. The characters in the
file are interpreted <A HREF="motion.html#as">as</A> if you had typed them. The same can
be done with the command ":source! {scriptin}". If the end
of the file is reached before the editor exits, further
characters are read from the keyboard. Only works when not
started in <A HREF="intro.html#Ex">Ex</A> mode, see |<A HREF="#-s-ex">-s-ex</A>|. See also |<A HREF="repeat.html#complex-repeat">complex-repeat</A>|.
{not in Vi}
*<A NAME="-w_nr"></A><B>-w_nr</B>*
<A HREF="#-w">-w</A> {number}
-w{number} Set the <A HREF="options.html#'window'">'window'</A> option to {number}.
*<A NAME="-w"></A><B>-w</B>*
<A HREF="#-w">-w</A> {scriptout} All the characters that you type are recorded in the file
"scriptout", until you exit Vim. This is useful if you want
to create a <A HREF="usr_41.html#script">script</A> file to be used with "vim -s" or
":source!". When the "scriptout" file already exists, new
characters are appended. See also |<A HREF="repeat.html#complex-repeat">complex-repeat</A>|.
{scriptout} cannot start with a digit.
{not in Vi}
*<A NAME="-W"></A><B>-W</B>*
<A HREF="#-W">-W</A> {scriptout} Like <A HREF="#-w">-w</A>, but <A HREF="diff.html#do">do</A> not append, overwrite an existing file.
{not in Vi}
<A HREF="remote.html#--remote">--remote</A> [+{cmd}] <A HREF="editing.html#{file}">{file}</A> <A HREF="eval.html#...">...</A>
Open the <A HREF="editing.html#{file}">{file}</A> in another Vim that <A HREF="eval.html#functions">functions</A> <A HREF="motion.html#as">as</A> a server.
Any non-file arguments must come before this.
See |<A HREF="remote.html#--remote">--remote</A>|. {not in Vi}
<A HREF="remote.html#--remote-silent">--remote-silent</A> [+{cmd}] <A HREF="editing.html#{file}">{file}</A> <A HREF="eval.html#...">...</A>
Like <A HREF="remote.html#--remote">--remote</A>, but don't complain if there is no server.
See |<A HREF="remote.html#--remote-silent">--remote-silent</A>|. {not in Vi}
<A HREF="remote.html#--remote-wait">--remote-wait</A> [+{cmd}] <A HREF="editing.html#{file}">{file}</A> <A HREF="eval.html#...">...</A>
Like <A HREF="remote.html#--remote">--remote</A>, but wait for the server to finish editing the
file(s).
See |<A HREF="remote.html#--remote-wait">--remote-wait</A>|. {not in Vi}
<A HREF="remote.html#--remote-wait-silent">--remote-wait-silent</A> [+{cmd}] <A HREF="editing.html#{file}">{file}</A> <A HREF="eval.html#...">...</A>
Like <A HREF="remote.html#--remote-wait">--remote-wait</A>, but don't complain if there is no server.
See |<A HREF="remote.html#--remote-wait-silent">--remote-wait-silent</A>|. {not in Vi}
<A HREF="remote.html#--servername">--servername</A> {name}
Specify the name of the Vim server to send to or to become.
See |<A HREF="remote.html#--servername">--servername</A>|. {not in Vi}
<A HREF="remote.html#--remote-send">--remote-send</A> {keys}
Send {keys} to a Vim server and exit.
See |<A HREF="remote.html#--remote-send">--remote-send</A>|. {not in Vi}
<A HREF="remote.html#--remote-expr">--remote-expr</A> {expr}
Evaluate {expr} in another Vim that <A HREF="eval.html#functions">functions</A> <A HREF="motion.html#as">as</A> a server.
The result is printed on stdout.
See |<A HREF="remote.html#--remote-expr">--remote-expr</A>|. {not in Vi}
<A HREF="remote.html#--serverlist">--serverlist</A> Output a <A HREF="eval.html#list">list</A> of Vim server names and exit. See
|<A HREF="remote.html#--serverlist">--serverlist</A>|. {not in Vi}
<A HREF="#--socketid">--socketid</A> {id} *<A NAME="--socketid"></A><B>--socketid</B>*
<A HREF="gui_x11.html#GTK+">GTK+</A> <A HREF="gui.html#GUI">GUI</A> Vim only. Make <A HREF="#gvim">gvim</A> try to use GtkPlug mechanism, so
that <A HREF="motion.html#it">it</A> runs inside another <A HREF="windows.html#window">window</A>. See |<A HREF="gui_x11.html#gui-gtk-socketid">gui-gtk-socketid</A>|
for details. {not in Vi}
<A HREF="#--windowid">--windowid</A> {id} *<A NAME="--windowid"></A><B>--windowid</B>*
<A HREF="os_win32.html#Win32">Win32</A> <A HREF="gui.html#GUI">GUI</A> Vim only. Make <A HREF="#gvim">gvim</A> try to use the <A HREF="windows.html#window">window</A> {id} <A HREF="motion.html#as">as</A> a
parent, so that <A HREF="motion.html#it">it</A> runs inside that <A HREF="windows.html#window">window</A>. See
|<A HREF="gui_w32.html#gui-w32-windowid">gui-w32-windowid</A>| for details. {not in Vi}
<A HREF="#--echo-wid">--echo-wid</A> *<A NAME="--echo-wid"></A><B>--echo-wid</B>*
<A HREF="gui_x11.html#GTK+">GTK+</A> <A HREF="gui.html#GUI">GUI</A> Vim only. Make <A HREF="#gvim">gvim</A> echo the Window ID on stdout,
which can be used to run <A HREF="#gvim">gvim</A> in a kpart widget. The format
of the output is:
<B> WID: 12345\n</B>
{not in Vi}
<A HREF="#--role">--role</A> {role} *<A NAME="--role"></A><B>--role</B>*
<A HREF="gui_x11.html#GTK+">GTK+</A> 2 <A HREF="gui.html#GUI">GUI</A> only. Set the role of the main <A HREF="windows.html#window">window</A> to {role}.
The <A HREF="windows.html#window">window</A> role can be used by a <A HREF="windows.html#window">window</A> manager to uniquely
identify a <A HREF="windows.html#window">window</A>, in order to restore <A HREF="windows.html#window">window</A> placement and
such. The <A HREF="#--role">--role</A> argument is passed automatically when
restoring the session on login. See |<A HREF="gui_x11.html#gui-gnome-session">gui-gnome-session</A>|
{not in Vi}
<A HREF="#-P">-P</A> {parent-title} *<A NAME="-P"></A><B>-P</B>* *<A NAME="MDI"></A><B>MDI</B>* *<A NAME="E671"></A><B>E671</B>* *<A NAME="E672"></A><B>E672</B>*
<A HREF="os_win32.html#Win32">Win32</A> only: Specify the title of the parent application. When
possible, Vim will run in an <A HREF="#MDI">MDI</A> <A HREF="windows.html#window">window</A> inside the
application.
{parent-title} must appear in the <A HREF="windows.html#window">window</A> title of the parent
application. Make sure that <A HREF="motion.html#it">it</A> is specific enough.
Note that the implementation is still primitive. It won't
work with all applications and the menu doesn't work.
<A HREF="#-nb">-nb</A> *<A NAME="-nb"></A><B>-nb</B>*
-nb={fname}
-nb:{hostname}:{addr}:{password}
Attempt connecting to Netbeans and become an editor server for
<A HREF="motion.html#it">it</A>. The second form specifies a file to read connection info
from. The third form specifies the hostname, address and
password for connecting to Netbeans. |<A HREF="netbeans.html#netbeans-run">netbeans-run</A>|
{only available when compiled with the |<A HREF="various.html#+netbeans_intg">+netbeans_intg</A>|
feature; if not then <A HREF="#-nb">-nb</A> will make Vim exit}
If the executable is called "<A HREF="#view">view</A>", Vim will start in Readonly mode. This is
useful if you can make a hard or symbolic link from "<A HREF="#view">view</A>" to "vim".
Starting in Readonly mode can also be done with "vim -R".
If the executable is called "<A HREF="#ex">ex</A>", Vim will start in "<A HREF="intro.html#Ex">Ex</A>" mode. This means <A HREF="motion.html#it">it</A>
will accept only "<A HREF="cmdline.html#:">:</A>" commands. But when the "<A HREF="#-v">-v</A>" argument is given, Vim will
start in <A HREF="intro.html#Normal">Normal</A> mode anyway.
Additional arguments are available on <A HREF="os_unix.html#unix">unix</A> like systems when compiled with
<A HREF="options.html#X11">X11</A> <A HREF="gui.html#GUI">GUI</A> support. See |<A HREF="gui_x11.html#gui-resources">gui-resources</A>|.
==============================================================================
2. Vim on the <A HREF="os_amiga.html#Amiga">Amiga</A> *<A NAME="starting-amiga"></A><B>starting-amiga</B>*
Starting Vim from the Workbench *<A NAME="workbench"></A><B>workbench</B>*
Vim can be started from the Workbench by clicking on its icon <A HREF="if_cscop.html#twice">twice</A>. It will
then start with an empty buffer.
Vim can be started to edit one or more files by using a "Project" icon. The
"Default Tool" of the icon must be the full pathname of the Vim executable.
The name of the ".info" file must be the same <A HREF="motion.html#as">as</A> the name of the text file.
By clicking on this icon <A HREF="if_cscop.html#twice">twice</A>, Vim will be started with the file name <A HREF="motion.html#as">as</A>
current file name, which will be read into the buffer (if <A HREF="motion.html#it">it</A> exists). You can
edit multiple files by pressing the <A HREF="intro.html#shift">shift</A> key while clicking on icons, and
clicking <A HREF="if_cscop.html#twice">twice</A> on the last one. The "Default Tool" for all these icons must
be the same.
It is not possible to give arguments to Vim, other than file names, from the
<A HREF="#workbench">workbench</A>.
Vim <A HREF="windows.html#window">window</A> *<A NAME="amiga-window"></A><B>amiga-window</B>*
Vim will run in the CLI <A HREF="windows.html#window">window</A> where <A HREF="motion.html#it">it</A> was started. If Vim was started with
the "run" or "runback" command, or if Vim was started from the <A HREF="#workbench">workbench</A>, <A HREF="motion.html#it">it</A>
will open a <A HREF="windows.html#window">window</A> of its own.
Technical detail:
To open the new <A HREF="windows.html#window">window</A> a little trick is used. As soon <A HREF="motion.html#as">as</A> Vim
recognizes that <A HREF="motion.html#it">it</A> does not run in a normal CLI <A HREF="windows.html#window">window</A>, <A HREF="motion.html#it">it</A> will
create a <A HREF="usr_41.html#script">script</A> file in "<A HREF="eval.html#t:">t:</A>". This <A HREF="usr_41.html#script">script</A> file contains the same
command <A HREF="motion.html#as">as</A> the one Vim was started with, and an "endcli" command.
This <A HREF="usr_41.html#script">script</A> file is then executed with a "newcli" command (the "c:run"
and "c:newcli" commands are required for this to work). The <A HREF="usr_41.html#script">script</A>
file will hang around until reboot, or until you delete <A HREF="motion.html#it">it</A>. This
method is required to get the "<A HREF="various.html#:sh">:sh</A>" and "<A HREF="various.html#:!">:!</A>" commands to work
correctly. But when Vim was started with the <A HREF="#-f">-f</A> option (foreground
mode), this method is not used. The reason for this is that
when a program starts Vim with the <A HREF="#-f">-f</A> option <A HREF="motion.html#it">it</A> will wait for Vim to
exit. With the <A HREF="usr_41.html#script">script</A> trick, the calling program does not know when
Vim exits. The <A HREF="#-f">-f</A> option can be used when Vim is started by a mail
program which also waits for the edit session to finish. As a
consequence, the "<A HREF="various.html#:sh">:sh</A>" and "<A HREF="various.html#:!">:!</A>" commands are not available when the
<A HREF="#-f">-f</A> option is used.
Vim will automatically recognize the <A HREF="windows.html#window">window</A> size and react to <A HREF="windows.html#window">window</A>
resizing. Under <A HREF="os_amiga.html#Amiga">Amiga</A> <A HREF="os_dos.html#DOS">DOS</A> 1.3, <A HREF="motion.html#it">it</A> is advised to use the fastfonts program,
"FF", to speed up display redrawing.
==============================================================================
3. Running eVim *<A NAME="evim-keys"></A><B>evim-keys</B>*
EVim runs Vim <A HREF="motion.html#as">as</A> click-and-type editor. This is very unlike the original <A HREF="intro.html#Vi">Vi</A>
idea. But <A HREF="motion.html#it">it</A> helps for people that don't use Vim often enough to learn the
commands. Hopefully they will find out that learning to use <A HREF="intro.html#Normal">Normal</A> mode
commands will make their editing much more effective.
In Evim these <A HREF="options.html#options">options</A> are changed from their default value:
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'nocompatible'">nocompatible</A> Use Vim improvements
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'insertmode'">insertmode</A> Remain in <A HREF="insert.html#Insert">Insert</A> mode most of the time
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'hidden'">hidden</A> Keep invisible <A HREF="windows.html#buffers">buffers</A> loaded
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'backup'">backup</A> Keep <A HREF="editing.html#backup">backup</A> files (not for <A HREF="os_vms.html#VMS">VMS</A>)
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'backspace'">backspace</A>=2 Backspace over everything
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'autoindent'">autoindent</A> auto-indent new lines
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'history'">history</A>=50 keep 50 lines of <A HREF="intro.html#Ex">Ex</A> commands
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'ruler'">ruler</A> show the cursor position
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'incsearch'">incsearch</A> show matches halfway typing a <A HREF="pattern.html#pattern">pattern</A>
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'mouse'">mouse</A>=a use the mouse in all modes
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'hlsearch'">hlsearch</A> highlight all matches for a search <A HREF="pattern.html#pattern">pattern</A>
<A HREF="options.html#:set">:set</A> whichwrap+=<,>,[,] <A HREF="motion.html#<Left>"><Left></A> and <A HREF="motion.html#<Right>"><Right></A> wrap around line breaks
<A HREF="options.html#:set">:set</A> guioptions-=a non-Unix only: don't <A HREF="diff.html#do">do</A> auto-select
Key mappings:
<A HREF="motion.html#<Down>"><Down></A> moves by screen lines rather than file lines
<A HREF="motion.html#<Up>"><Up></A> idem
<A HREF="intro.html#Q">Q</A> does "<A HREF="change.html#gq">gq</A>", <A HREF="change.html#formatting">formatting</A>, instead of <A HREF="intro.html#Ex">Ex</A> mode
<A HREF="motion.html#<BS>"><BS></A> in <A HREF="visual.html#Visual">Visual</A> mode: deletes the selection
<A HREF="change.html#CTRL-X">CTRL-X</A> in <A HREF="visual.html#Visual">Visual</A> mode: Cut to <A HREF="gui.html#clipboard">clipboard</A>
<A HREF="os_dos.html#<S-Del>"><S-Del></A> idem
<A HREF="pattern.html#CTRL-C">CTRL-C</A> in <A HREF="visual.html#Visual">Visual</A> mode: Copy to <A HREF="gui.html#clipboard">clipboard</A>
<A HREF="os_dos.html#<C-Insert>"><C-Insert></A> idem
<A HREF="visual.html#CTRL-V">CTRL-V</A> Pastes from the <A HREF="gui.html#clipboard">clipboard</A> (in any mode)
<A HREF="os_dos.html#<S-Insert>"><S-Insert></A> idem
<A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A> <A HREF="diff.html#do">do</A> what <A HREF="visual.html#CTRL-V">CTRL-V</A> used to <A HREF="diff.html#do">do</A>
<A HREF="#CTRL-Z">CTRL-Z</A> <A HREF="undo.html#undo">undo</A>
<A HREF="scroll.html#CTRL-Y">CTRL-Y</A> <A HREF="undo.html#redo">redo</A>
<M-Space> system menu
<A HREF="change.html#CTRL-A">CTRL-A</A> select all
<C-Tab> next <A HREF="windows.html#window">window</A>, <A HREF="index.html#CTRL-W">CTRL-W</A> <A HREF="motion.html#w">w</A>
<C-F4> close <A HREF="windows.html#window">window</A>, <A HREF="index.html#CTRL-W">CTRL-W</A> <A HREF="change.html#c">c</A>
Additionally:
- ":behave mswin" is used |<A HREF="gui.html#:behave">:behave</A>|
- <A HREF="syntax.html#syntax">syntax</A> highlighting is enabled
- <A HREF="filetype.html#filetype">filetype</A> detection is enabled, <A HREF="filetype.html#filetype">filetype</A> plugins and indenting is enabled
- in a text file <A HREF="options.html#'textwidth'">'textwidth'</A> is set to 78
One hint: If you want to go to <A HREF="intro.html#Normal">Normal</A> mode to be able to type a sequence of
commands, use CTRL-L. |<A HREF="insert.html#i_CTRL-L">i_CTRL-L</A>|
==============================================================================
4. Initialization *<A NAME="initialization"></A><B>initialization</B>* *<A NAME="startup"></A><B>startup</B>*
This section is about the non-GUI version of Vim. See |<A HREF="gui_x11.html#gui-fork">gui-fork</A>| for
additional <A HREF="#initialization">initialization</A> when starting the <A HREF="gui.html#GUI">GUI</A>.
At <A HREF="#startup">startup</A>, Vim checks environment <A HREF="eval.html#variables">variables</A> and files and sets values
accordingly. Vim proceeds in this order:
1. Set the <A HREF="options.html#'shell'">'shell'</A> and <A HREF="options.html#'term'">'term'</A> option *<A NAME="SHELL"></A><B>SHELL</B>* *<A NAME="COMSPEC"></A><B>COMSPEC</B>* *<A NAME="TERM"></A><B>TERM</B>*
The environment variable <A HREF="#SHELL">SHELL</A>, if <A HREF="motion.html#it">it</A> exists, is used to set the
<A HREF="options.html#'shell'">'shell'</A> option. On <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>, the <A HREF="#COMSPEC">COMSPEC</A> variable is used
if <A HREF="#SHELL">SHELL</A> is not set.
The environment variable <A HREF="#TERM">TERM</A>, if <A HREF="motion.html#it">it</A> exists, is used to set the <A HREF="options.html#'term'">'term'</A>
option. However, <A HREF="options.html#'term'">'term'</A> will change later when starting the <A HREF="gui.html#GUI">GUI</A> (step
8 below).
2. Process the arguments
The <A HREF="options.html#options">options</A> and file names from the command that start Vim are
inspected. Buffers are created for all files (but not loaded yet).
The |<A HREF="#-V">-V</A>| argument can be used to display or log what happens next,
useful for debugging the initializations.
3. Execute <A HREF="intro.html#Ex">Ex</A> commands, from environment <A HREF="eval.html#variables">variables</A> and/or files
An environment variable is read <A HREF="motion.html#as">as</A> one <A HREF="intro.html#Ex">Ex</A> command line, where multiple
commands must be separated with '|' or "<A HREF="motion.html#<NL>"><NL></A>".
*<A NAME="vimrc"></A><B>vimrc</B>* *<A NAME="exrc"></A><B>exrc</B>*
A file that contains <A HREF="#initialization">initialization</A> commands is called a "<A HREF="#vimrc">vimrc</A>" file.
Each line in a <A HREF="#vimrc">vimrc</A> file is executed <A HREF="motion.html#as">as</A> an <A HREF="intro.html#Ex">Ex</A> command line. It is
sometimes also referred to <A HREF="motion.html#as">as</A> "<A HREF="#exrc">exrc</A>" file. They are the same type of
file, but "<A HREF="#exrc">exrc</A>" is what <A HREF="intro.html#Vi">Vi</A> always used, "<A HREF="#vimrc">vimrc</A>" is a Vim specific
name. Also see |<A HREF="usr_05.html#vimrc-intro">vimrc-intro</A>|.
Places for your personal initializations:
<A HREF="os_unix.html#Unix">Unix</A> $HOME/.vimrc or $HOME/.vim/vimrc
<A HREF="os_os2.html#OS/2">OS/2</A> $HOME/.vimrc, $HOME/vimfiles/vimrc
or $VIM/.vimrc (or <A HREF="#_vimrc">_vimrc</A>)
<A HREF="os_win32.html#MS-Windows">MS-Windows</A> $HOME/_vimrc, $HOME/vimfiles/vimrc
or $VIM/_vimrc
<A HREF="os_amiga.html#Amiga">Amiga</A> s:.vimrc, home:.vimrc, home:vimfiles:vimrc
or $VIM/.vimrc
The files are searched in the order specified above and only the first
one that is found is read.
RECOMMENDATION: Put all your Vim configuration stuff in the
$HOME/.vim/ directory ($HOME/vimfiles/ for <A HREF="os_win32.html#MS-Windows">MS-Windows</A>). That makes <A HREF="motion.html#it">it</A>
<A HREF="#easy">easy</A> to copy <A HREF="motion.html#it">it</A> to another system.
If Vim was started with "<A HREF="#-u">-u</A> filename", the file "filename" is used.
All following initializations until 4. are skipped. <A HREF="#$MYVIMRC">$MYVIMRC</A> is not
set.
"vim <A HREF="#-u">-u</A> NORC" can be used to skip these initializations without
reading a file. "vim -u NONE" also skips loading plugins. |<A HREF="#-u">-u</A>|
If Vim was started in <A HREF="intro.html#Ex">Ex</A> mode with the "<A HREF="#-s">-s</A>" argument, all following
initializations until 4. are skipped. Only the "<A HREF="#-u">-u</A>" option is
interpreted.
*<A NAME="evim.vim"></A><B>evim.vim</B>*
a. If vim was started <A HREF="motion.html#as">as</A> |<A HREF="#evim">evim</A>| or |<A HREF="#eview">eview</A>| or with the |<A HREF="#-y">-y</A>| argument, the
<A HREF="usr_41.html#script">script</A> $VIMRUNTIME/evim.vim will be loaded.
*<A NAME="system-vimrc"></A><B>system-vimrc</B>*
<A HREF="motion.html#b">b</A>. For <A HREF="os_unix.html#Unix">Unix</A>, <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>, <A HREF="os_win32.html#MS-Windows">MS-Windows</A>, <A HREF="os_os2.html#OS/2">OS/2</A>, <A HREF="os_vms.html#VMS">VMS</A>, <A HREF="os_mac.html#Macintosh">Macintosh</A>, <A HREF="os_risc.html#RISC-OS">RISC-OS</A> and <A HREF="os_amiga.html#Amiga">Amiga</A>
the system <A HREF="#vimrc">vimrc</A> file is read for initializations. The path of this
file is shown with the "<A HREF="various.html#:version">:version</A>" command. Mostly it's "$VIM/vimrc".
Note that this file is ALWAYS read in <A HREF="options.html#'compatible'">'compatible'</A> mode, since the
automatic resetting of <A HREF="options.html#'compatible'">'compatible'</A> is only done later. Add a "<A HREF="options.html#:set">:set</A>
nocp" command if you like.
For the <A HREF="os_mac.html#Macintosh">Macintosh</A> the $VIMRUNTIME/macmap.vim is read.
*<A NAME="VIMINIT"></A><B>VIMINIT</B>* *<A NAME=".vimrc"></A><B>.vimrc</B>* *<A NAME="_vimrc"></A><B>_vimrc</B>* *<A NAME="EXINIT"></A><B>EXINIT</B>* *<A NAME=".exrc"></A><B>.exrc</B>* *<A NAME="_exrc"></A><B>_exrc</B>* *<A NAME="$MYVIMRC"></A><B>$MYVIMRC</B>*
<A HREF="change.html#c">c</A>. Four places are searched for initializations. The first that exists
is used, the others are ignored. The <A HREF="#$MYVIMRC">$MYVIMRC</A> environment variable is
set to the file that was first found, unless <A HREF="#$MYVIMRC">$MYVIMRC</A> was already set
and when using <A HREF="#VIMINIT">VIMINIT</A>.
- The environment variable <A HREF="#VIMINIT">VIMINIT</A> (see also |<A HREF="#compatible-default">compatible-default</A>|) (*)
The value of $VIMINIT is used <A HREF="motion.html#as">as</A> an <A HREF="intro.html#Ex">Ex</A> command line.
- The user <A HREF="#vimrc">vimrc</A> file(s):
"$HOME/.vimrc" (for <A HREF="os_unix.html#Unix">Unix</A> and <A HREF="os_os2.html#OS/2">OS/2</A>) (*)
"$HOME/.vim/vimrc" (for <A HREF="os_unix.html#Unix">Unix</A> and <A HREF="os_os2.html#OS/2">OS/2</A>) (*)
"s:.vimrc" (for <A HREF="os_amiga.html#Amiga">Amiga</A>) (*)
"home:.vimrc" (for <A HREF="os_amiga.html#Amiga">Amiga</A>) (*)
"home:vimfiles:vimrc" (for <A HREF="os_amiga.html#Amiga">Amiga</A>) (*)
"$VIM/.vimrc" (for <A HREF="os_os2.html#OS/2">OS/2</A> and <A HREF="os_amiga.html#Amiga">Amiga</A>) (*)
"$HOME/_vimrc" (for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>) (*)
"$HOME/vimfiles/vimrc" (for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>) (*)
"$VIM/_vimrc" (for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>) (*)
Note: For <A HREF="os_unix.html#Unix">Unix</A>, <A HREF="os_os2.html#OS/2">OS/2</A> and <A HREF="os_amiga.html#Amiga">Amiga</A>, when "<A HREF="#.vimrc">.vimrc</A>" does not exist,
"<A HREF="#_vimrc">_vimrc</A>" is also tried, in <A HREF="change.html#case">case</A> an <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> compatible file
system is used. For <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A> "<A HREF="#.vimrc">.vimrc</A>" is checked
after "<A HREF="#_vimrc">_vimrc</A>", in <A HREF="change.html#case">case</A> long file names are used.
Note: For <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>, "<A HREF="options.html#$HOME">$HOME</A>" is checked first. If no
"<A HREF="#_vimrc">_vimrc</A>" or "<A HREF="#.vimrc">.vimrc</A>" is found there, "<A HREF="#$VIM">$VIM</A>" is tried.
See |<A HREF="#$VIM">$VIM</A>| for when $VIM is not set.
- The environment variable <A HREF="#EXINIT">EXINIT</A>.
The value of $EXINIT is used <A HREF="motion.html#as">as</A> an <A HREF="intro.html#Ex">Ex</A> command line.
- The user <A HREF="#exrc">exrc</A> file(s). Same <A HREF="motion.html#as">as</A> for the user <A HREF="#vimrc">vimrc</A> file, but with
"<A HREF="#vimrc">vimrc</A>" replaced by "<A HREF="#exrc">exrc</A>". But only one of "<A HREF="#.exrc">.exrc</A>" and "<A HREF="#_exrc">_exrc</A>" is
used, depending on the system. And without the (*)!
- You would usually have "<A HREF="syntax.html#syntax">syntax</A> on" and/or "<A HREF="filetype.html#filetype">filetype</A> on" commands,
which trigger initializing <A HREF="filetype.html#filetype">filetype</A> detection, see |<A HREF="syntax.html#syntax-loading">syntax-loading</A>|.
<A HREF="change.html#d">d</A>. If the <A HREF="options.html#'exrc'">'exrc'</A> option is on (which is not the default), the current
directory is searched for three files. The first that exists is used,
the others are ignored.
- The file "<A HREF="#.vimrc">.vimrc</A>" (for <A HREF="os_unix.html#Unix">Unix</A>, <A HREF="os_amiga.html#Amiga">Amiga</A> and <A HREF="os_os2.html#OS/2">OS/2</A>) (*)
"<A HREF="#_vimrc">_vimrc</A>" (for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>) (*)
- The file "<A HREF="#_vimrc">_vimrc</A>" (for <A HREF="os_unix.html#Unix">Unix</A>, <A HREF="os_amiga.html#Amiga">Amiga</A> and <A HREF="os_os2.html#OS/2">OS/2</A>) (*)
"<A HREF="#.vimrc">.vimrc</A>" (for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>) (*)
- The file "<A HREF="#.exrc">.exrc</A>" (for <A HREF="os_unix.html#Unix">Unix</A>, <A HREF="os_amiga.html#Amiga">Amiga</A> and <A HREF="os_os2.html#OS/2">OS/2</A>)
"<A HREF="#_exrc">_exrc</A>" (for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>)
(*) Using this file or environment variable will cause <A HREF="options.html#'compatible'">'compatible'</A> to be
off by default. See |<A HREF="#compatible-default">compatible-default</A>|.
4. Load the <A HREF="usr_05.html#plugin">plugin</A> scripts. *<A NAME="load-plugins"></A><B>load-plugins</B>*
This does the same <A HREF="motion.html#as">as</A> the command:
<B> :runtime! plugin/**/*.vim</B>
The result is that all directories in the <A HREF="options.html#'runtimepath'">'runtimepath'</A> option will be
searched for the "<A HREF="usr_05.html#plugin">plugin</A>" sub-directory and all files ending in ".vim"
will be sourced (in alphabetical order per directory), also in
subdirectories.
Loading plugins won't be done when:
- The <A HREF="options.html#'loadplugins'">'loadplugins'</A> option was reset in a <A HREF="#vimrc">vimrc</A> file.
- The |<A HREF="#--noplugin">--noplugin</A>| command line argument is used.
- The "-u NONE" command line argument is used |<A HREF="#-u">-u</A>|.
- When Vim was compiled without the |<A HREF="various.html#+eval">+eval</A>| feature.
Note that using "<A HREF="#-c">-c</A> 'set noloadplugins'"' doesn't work, because the
commands from the command line have not been executed yet. You can
use "--cmd 'set noloadplugins'"' |<A HREF="#--cmd">--cmd</A>|.
Plugin packs are loaded. These are plugins, <A HREF="motion.html#as">as</A> above, but found in
<A HREF="options.html#'packpath'">'packpath'</A> "start" directories. Every <A HREF="usr_05.html#plugin">plugin</A> directory found is added
in <A HREF="options.html#'runtimepath'">'runtimepath'</A>. See |<A HREF="repeat.html#packages">packages</A>|.
5. Set <A HREF="options.html#'shellpipe'">'shellpipe'</A> and <A HREF="options.html#'shellredir'">'shellredir'</A>
The <A HREF="options.html#'shellpipe'">'shellpipe'</A> and <A HREF="options.html#'shellredir'">'shellredir'</A> <A HREF="options.html#options">options</A> are set according to the
value of the <A HREF="options.html#'shell'">'shell'</A> option, unless they have been set before.
This means that Vim will figure out the values of <A HREF="options.html#'shellpipe'">'shellpipe'</A> and
<A HREF="options.html#'shellredir'">'shellredir'</A> for you, unless you have set them yourself.
6. Set <A HREF="options.html#'updatecount'">'updatecount'</A> to zero, if "<A HREF="#-n">-n</A>" command argument used
7. Set binary <A HREF="options.html#options">options</A>
If the "<A HREF="#-b">-b</A>" flag was given to Vim, the <A HREF="options.html#options">options</A> for binary editing will
be set now. See |<A HREF="#-b">-b</A>|.
8. Perform <A HREF="gui.html#GUI">GUI</A> initializations
Only when starting "<A HREF="#gvim">gvim</A>", the <A HREF="gui.html#GUI">GUI</A> initializations will be done. See
|<A HREF="gui.html#gui-init">gui-init</A>|.
9. Read the <A HREF="#viminfo">viminfo</A> file
If the <A HREF="options.html#'viminfo'">'viminfo'</A> option is not empty, the <A HREF="#viminfo">viminfo</A> file is read. See
|<A HREF="#viminfo-file">viminfo-file</A>|.
10. Read the <A HREF="quickfix.html#quickfix">quickfix</A> file
If the "<A HREF="#-q">-q</A>" flag was given to Vim, the <A HREF="quickfix.html#quickfix">quickfix</A> file is read. If this
fails, Vim exits.
11. Open all <A HREF="windows.html#windows">windows</A>
When the |<A HREF="#-o">-o</A>| flag was given, <A HREF="windows.html#windows">windows</A> will be opened (but not
displayed yet).
When the |<A HREF="#-p">-p</A>| flag was given, <A HREF="intro.html#tab">tab</A> pages will be created (but not
displayed yet).
When switching screens, <A HREF="motion.html#it">it</A> happens now. Redrawing starts.
If the "<A HREF="#-q">-q</A>" flag was given to Vim, the first error is jumped to.
Buffers for all <A HREF="windows.html#windows">windows</A> will be loaded.
12. Execute <A HREF="#startup">startup</A> commands
If a "<A HREF="#-t">-t</A>" flag was given to Vim, the <A HREF="tagsrch.html#tag">tag</A> is jumped to.
The commands given with the |<A HREF="#-c">-c</A>| and |<A HREF="editing.html#+cmd">+cmd</A>| arguments are executed.
If the <A HREF="options.html#'insertmode'">'insertmode'</A> option is set, <A HREF="insert.html#Insert">Insert</A> mode is entered.
The starting flag is reset, has("vim_starting") will now return zero.
The |<A HREF="eval.html#v:vim_did_enter">v:vim_did_enter</A>| variable is set to 1.
The |<A HREF="autocmd.html#VimEnter">VimEnter</A>| autocommands are executed.
Some hints on using initializations:
Standard setup:
Create a <A HREF="#vimrc">vimrc</A> file to set the default settings and mappings for all your edit
sessions. Put <A HREF="motion.html#it">it</A> in a place so that <A HREF="motion.html#it">it</A> will be found by 3b:
~/.vimrc (Unix and <A HREF="os_os2.html#OS/2">OS/2</A>)
s:.vimrc (Amiga)
$VIM\_vimrc (MS-DOS and <A HREF="os_win32.html#Win32">Win32</A>)
Note that creating a <A HREF="#vimrc">vimrc</A> file will cause the <A HREF="options.html#'compatible'">'compatible'</A> option to be off
by default. See |<A HREF="#compatible-default">compatible-default</A>|.
Local setup:
Put all commands that you need for editing a specific directory only into a
<A HREF="#vimrc">vimrc</A> file and place <A HREF="motion.html#it">it</A> in that directory under the name "<A HREF="#.vimrc">.vimrc</A>" ("_vimrc"
for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>). NOTE: To make Vim look for these special files you
have to turn on the option <A HREF="options.html#'exrc'">'exrc'</A>. See |<A HREF="#trojan-horse">trojan-horse</A>| too.
System setup:
This only applies if you are managing a <A HREF="os_unix.html#Unix">Unix</A> system with several users and
want to set the defaults for all users. Create a <A HREF="#vimrc">vimrc</A> file with commands
for default settings and mappings and put <A HREF="motion.html#it">it</A> in the place that is given with
the "<A HREF="various.html#:version">:version</A>" command.
Saving the current state of Vim to a file:
Whenever you have changed values of <A HREF="options.html#options">options</A> or when you have created a
<A HREF="map.html#mapping">mapping</A>, then you may want to save them in a <A HREF="#vimrc">vimrc</A> file for later use. See
|<A HREF="#save-settings">save-settings</A>| about saving the current state of settings to a file.
Avoiding setup problems for <A HREF="intro.html#Vi">Vi</A> users:
<A HREF="intro.html#Vi">Vi</A> uses the variable <A HREF="#EXINIT">EXINIT</A> and the file "~/.exrc". So if you <A HREF="diff.html#do">do</A> not want to
interfere with <A HREF="intro.html#Vi">Vi</A>, then use the variable <A HREF="#VIMINIT">VIMINIT</A> and the file "<A HREF="#vimrc">vimrc</A>" instead.
<A HREF="os_amiga.html#Amiga">Amiga</A> environment <A HREF="eval.html#variables">variables</A>:
On the <A HREF="os_amiga.html#Amiga">Amiga</A>, two types of environment <A HREF="eval.html#variables">variables</A> exist. The ones set with the
<A HREF="os_dos.html#DOS">DOS</A> 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3
manual. The environment <A HREF="eval.html#variables">variables</A> set with the old Manx Set command (before
version 5.0) are not recognized.
<A HREF="os_msdos.html#MS-DOS">MS-DOS</A> line separators:
On MS-DOS-like systems (MS-DOS itself, <A HREF="os_win32.html#Win32">Win32</A>, and OS/2), Vim assumes that all
the <A HREF="#vimrc">vimrc</A> files have <A HREF="motion.html#<CR>"><CR></A> <A HREF="motion.html#<NL>"><NL></A> pairs <A HREF="motion.html#as">as</A> line separators. This will give
problems if you have a file with only <NL>s and have a line like
"<A HREF="map.html#:map">:map</A> xx yy^M". The trailing ^M will be ignored.
*<A NAME="compatible-default"></A><B>compatible-default</B>*
When Vim starts, the <A HREF="options.html#'compatible'">'compatible'</A> option is on. This will be used when Vim
starts its initializations. But <A HREF="motion.html#as">as</A> soon <A HREF="motion.html#as">as</A> a user <A HREF="#vimrc">vimrc</A> file is found, or a
<A HREF="#vimrc">vimrc</A> file in the current directory, or the "<A HREF="#VIMINIT">VIMINIT</A>" environment variable is
set, <A HREF="motion.html#it">it</A> will be set to <A HREF="options.html#'nocompatible'">'nocompatible'</A>. This has the side effect of setting or
resetting other <A HREF="options.html#options">options</A> (see <A HREF="options.html#'compatible'">'compatible'</A>). But only the <A HREF="options.html#options">options</A> that have
not been set or reset will be changed. This has the same effect like the
value of <A HREF="options.html#'compatible'">'compatible'</A> had this value when starting Vim. Note that this
doesn't happen for the system-wide <A HREF="#vimrc">vimrc</A> file nor when Vim was started with
the |<A HREF="#-u">-u</A>| command line argument. It does also happen for <A HREF="gui.html#gvimrc">gvimrc</A> files. The
<A HREF="#$MYVIMRC">$MYVIMRC</A> or <A HREF="gui.html#$MYGVIMRC">$MYGVIMRC</A> file will be set to the first found <A HREF="#vimrc">vimrc</A> and/or <A HREF="gui.html#gvimrc">gvimrc</A>
file.
But there is a side effect of setting or resetting <A HREF="options.html#'compatible'">'compatible'</A> at the moment
a <A HREF="#.vimrc">.vimrc</A> file is found: Mappings are interpreted the moment they are
encountered. This makes a difference when using things like "<A HREF="motion.html#<CR>"><CR></A>". If the
mappings depend on a certain value of <A HREF="options.html#'compatible'">'compatible'</A>, set or reset <A HREF="motion.html#it">it</A> before
giving the <A HREF="map.html#mapping">mapping</A>.
The above behavior can be overridden in these ways:
- If the "<A HREF="#-N">-N</A>" command line argument is given, <A HREF="options.html#'nocompatible'">'nocompatible'</A> will be used,
even when no <A HREF="#vimrc">vimrc</A> file exists.
- If the "<A HREF="#-C">-C</A>" command line argument is given, <A HREF="options.html#'compatible'">'compatible'</A> will be used, even
when a <A HREF="#vimrc">vimrc</A> file exists.
- If the "<A HREF="#-u">-u</A> {vimrc}" argument is used, <A HREF="options.html#'compatible'">'compatible'</A> will be used.
- When the name of the executable ends in "<A HREF="#ex">ex</A>", then this works like the "<A HREF="#-C">-C</A>"
argument was given: <A HREF="options.html#'compatible'">'compatible'</A> will be used, even when a <A HREF="#vimrc">vimrc</A> file
exists. This has been done to make Vim behave like "<A HREF="#ex">ex</A>", when <A HREF="motion.html#it">it</A> is started
<A HREF="motion.html#as">as</A> "<A HREF="#ex">ex</A>".
Avoiding trojan horses: *<A NAME="trojan-horse"></A><B>trojan-horse</B>*
While reading the "<A HREF="#vimrc">vimrc</A>" or the "<A HREF="#exrc">exrc</A>" file in the current directory, some
commands can be disabled for security reasons by setting the <A HREF="options.html#'secure'">'secure'</A> option.
This is always done when executing the command from a <A HREF="tagsrch.html#tags">tags</A> file. Otherwise <A HREF="motion.html#it">it</A>
would be possible that you accidentally use a <A HREF="#vimrc">vimrc</A> or <A HREF="tagsrch.html#tags">tags</A> file that somebody
else created and contains nasty commands. The disabled commands are the ones
that start a shell, the ones that write to a file, and "<A HREF="autocmd.html#:autocmd">:autocmd</A>". The "<A HREF="map.html#:map">:map</A>"
commands are echoed, so you can see which keys are being mapped.
If you want Vim to execute all commands in a local <A HREF="#vimrc">vimrc</A> file, you
can reset the <A HREF="options.html#'secure'">'secure'</A> option in the <A HREF="#EXINIT">EXINIT</A> or <A HREF="#VIMINIT">VIMINIT</A> environment variable or
in the global "<A HREF="#exrc">exrc</A>" or "<A HREF="#vimrc">vimrc</A>" file. This is not possible in "<A HREF="#vimrc">vimrc</A>" or
"<A HREF="#exrc">exrc</A>" in the current directory, for obvious reasons.
On <A HREF="os_unix.html#Unix">Unix</A> systems, this only happens if you are not the owner of the
<A HREF="#vimrc">vimrc</A> file. Warning: If you unpack an archive that contains a <A HREF="#vimrc">vimrc</A> or <A HREF="#exrc">exrc</A>
file, <A HREF="motion.html#it">it</A> will be owned by you. You won't have the security protection. Check
the <A HREF="#vimrc">vimrc</A> file before you start Vim in that directory, or reset the <A HREF="options.html#'exrc'">'exrc'</A>
option. Some <A HREF="os_unix.html#Unix">Unix</A> systems allow a user to <A HREF="diff.html#do">do</A> "chown" on a file. This makes
<A HREF="motion.html#it">it</A> possible for another user to create a nasty <A HREF="#vimrc">vimrc</A> and make you the owner.
Be careful!
When using <A HREF="tagsrch.html#tag">tag</A> search commands, executing the search command (the last
part of the line in the <A HREF="tagsrch.html#tags">tags</A> file) is always done in secure mode. This works
just like executing a command from a vimrc/exrc in the current directory.
*<A NAME="slow-start"></A><B>slow-start</B>*
If Vim takes a long time to start up, use the |<A HREF="#--startuptime">--startuptime</A>| argument to find
out what happens. There are a few common causes:
- If the <A HREF="os_unix.html#Unix">Unix</A> version was compiled with the <A HREF="gui.html#GUI">GUI</A> and/or <A HREF="options.html#X11">X11</A> (check the output
of "<A HREF="various.html#:version">:version</A>" for "+GUI" and "+X11"), <A HREF="motion.html#it">it</A> may need to load shared libraries
and connect to the <A HREF="options.html#X11">X11</A> server. Try compiling a version with <A HREF="gui.html#GUI">GUI</A> and <A HREF="options.html#X11">X11</A>
disabled. This also should make the executable smaller.
Use the |<A HREF="#-X">-X</A>| command line argument to avoid connecting to the X server when
running in a terminal.
- If you have "<A HREF="#viminfo">viminfo</A>" enabled, the loading of the <A HREF="#viminfo">viminfo</A> file may take a
while. You can find out if this is the problem by disabling <A HREF="#viminfo">viminfo</A> for a
moment (use the Vim argument "-i NONE", |<A HREF="#-i">-i</A>|). Try reducing the number of
lines stored in a <A HREF="sponsor.html#register">register</A> with "<A HREF="options.html#:set">:set</A> <A HREF="options.html#'viminfo'">viminfo</A>='20,<50,s10". |<A HREF="#viminfo-file">viminfo-file</A>|.
*<A NAME=":intro"></A><B>:intro</B>*
When Vim starts without a file name, an introductory message is displayed (for
those who don't know what Vim is). It is removed <A HREF="motion.html#as">as</A> soon <A HREF="motion.html#as">as</A> the display is
redrawn in any way. To see the message again, use the "<A HREF="#:intro">:intro</A>" command (if
there is not enough room, you will see only part of <A HREF="motion.html#it">it</A>).
To avoid the <A HREF="intro.html#intro">intro</A> message on <A HREF="#startup">startup</A>, add the '<A HREF="insert.html#I">I</A>' flag to <A HREF="options.html#'shortmess'">'shortmess'</A>.
*<A NAME="info-message"></A><B>info-message</B>*
The |<A HREF="#--help">--help</A>| and |<A HREF="#--version">--version</A>| arguments cause Vim to print a message and then
exit. Normally the message is sent to stdout, thus can be redirected to a
file with:
<B> vim --help >file</B>
From inside Vim:
<B> :read !vim --help</B>
When using <A HREF="#gvim">gvim</A>, <A HREF="motion.html#it">it</A> detects that <A HREF="motion.html#it">it</A> might have been started from the desktop,
without a terminal to show <A HREF="message.html#messages">messages</A> on. This is detected when both stdout and
stderr are not a tty. This breaks the "<A HREF="insert.html#:read">:read</A>" command, <A HREF="motion.html#as">as</A> used in the example
above. To make <A HREF="motion.html#it">it</A> work again, set <A HREF="options.html#'shellredir'">'shellredir'</A> to "<A HREF="change.html#>">></A>" instead of the default
">&":
<B> :set shellredir=></B>
<B> :read !gvim --help</B>
This still won't work for systems where <A HREF="#gvim">gvim</A> does not use stdout at all
though.
==============================================================================
5. <A HREF="#$VIM">$VIM</A> and <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A>
*<A NAME="$VIM"></A><B>$VIM</B>*
The environment variable "<A HREF="#$VIM">$VIM</A>" is used to locate various user files for Vim,
such <A HREF="motion.html#as">as</A> the user <A HREF="#startup">startup</A> <A HREF="usr_41.html#script">script</A> "<A HREF="#.vimrc">.vimrc</A>". This depends on the system, see
|<A HREF="#startup">startup</A>|.
To avoid the need for every user to set the <A HREF="#$VIM">$VIM</A> environment variable, Vim
will try to get the value for <A HREF="#$VIM">$VIM</A> in this order:
1. The value defined by the <A HREF="#$VIM">$VIM</A> environment variable. You can use this to
make Vim look in a specific directory for its support files. Example:
<B> setenv VIM /home/paul/vim</B>
2. The path from <A HREF="options.html#'helpfile'">'helpfile'</A> is used, unless <A HREF="motion.html#it">it</A> contains some environment
variable too (the default is "$VIMRUNTIME/doc/help.txt": chicken-egg
problem). The file name ("help.txt" or any other) is removed. Then
trailing directory names are removed, in this order: "doc", "runtime" and
"vim{version}" (e.g., "vim54").
3. For <A HREF="os_msdos.html#MSDOS">MSDOS</A>, <A HREF="os_win32.html#Win32">Win32</A> and <A HREF="os_os2.html#OS/2">OS/2</A> Vim tries to use the directory name of the
executable. If <A HREF="motion.html#it">it</A> ends in "/src", this is removed. This is useful if you
unpacked the .zip file in some directory, and adjusted the search path to
find the vim executable. Trailing directory names are removed, in this
order: "runtime" and "vim{version}" (e.g., "vim54").
4. For <A HREF="os_unix.html#Unix">Unix</A> the compile-time defined installation directory is used (see the
output of ":version").
Once Vim has done this once, <A HREF="motion.html#it">it</A> will set the <A HREF="#$VIM">$VIM</A> environment variable. To
change <A HREF="motion.html#it">it</A> later, use a "<A HREF="eval.html#:let">:let</A>" command like this:
<B> :let $VIM = "/home/paul/vim/"</B>
*<A NAME="$VIMRUNTIME"></A><B>$VIMRUNTIME</B>*
The environment variable "<A HREF="#$VIMRUNTIME">$VIMRUNTIME</A>" is used to locate various support
files, such <A HREF="motion.html#as">as</A> the on-line documentation and files used for <A HREF="syntax.html#syntax">syntax</A>
highlighting. For example, the main help file is normally
"$VIMRUNTIME/doc/help.txt".
You don't normally set <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A> yourself, but let Vim figure <A HREF="motion.html#it">it</A> out. This
is the order used to find the value of <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A>:
1. If the environment variable <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A> is set, <A HREF="motion.html#it">it</A> is used. You can use
this when the runtime files are in an unusual location.
2. If "$VIM/vim{version}" exists, <A HREF="motion.html#it">it</A> is used. {version} is the version
number of Vim, without any '<A HREF="motion.html#-">-</A>' or '<A HREF="repeat.html#.">.</A>'. For example: "$VIM/vim54". This is
the normal value for <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A>.
3. If "$VIM/runtime" exists, <A HREF="motion.html#it">it</A> is used.
4. The value of <A HREF="#$VIM">$VIM</A> is used. This is for backwards compatibility with older
versions.
5. When the <A HREF="options.html#'helpfile'">'helpfile'</A> option is set and doesn't contain a '<A HREF="motion.html#$">$</A>', its value is
used, with "doc/help.txt" removed from the end.
For <A HREF="os_unix.html#Unix">Unix</A>, when there is a compiled-in default for <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A> (check the
output of ":version"), steps 2, 3 and 4 are skipped, and the compiled-in
default is used after step 5. This means that the compiled-in default
overrules the value of <A HREF="#$VIM">$VIM</A>. This is useful if <A HREF="#$VIM">$VIM</A> is "/etc" and the runtime
files are in "/usr/share/vim/vim54".
Once Vim has done this once, <A HREF="motion.html#it">it</A> will set the <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A> environment variable.
To change <A HREF="motion.html#it">it</A> later, use a "<A HREF="eval.html#:let">:let</A>" command like this:
<B> :let $VIMRUNTIME = "/home/piet/vim/vim54"</B>
In <A HREF="change.html#case">case</A> you need the value of <A HREF="#$VIMRUNTIME">$VIMRUNTIME</A> in a shell (e.g., for a <A HREF="usr_41.html#script">script</A> that
greps in the help files) you might be able to use this:
<B> VIMRUNTIME=`vim -e -T dumb --cmd 'exe "set t_cm=\<C-M>"|echo $VIMRUNTIME|quit' | tr -d '\015' `</B>
==============================================================================
6. Suspending *<A NAME="suspend"></A><B>suspend</B>*
*<A NAME="iconize"></A><B>iconize</B>* *<A NAME="iconise"></A><B>iconise</B>* *<A NAME="CTRL-Z"></A><B>CTRL-Z</B>* *<A NAME="v_CTRL-Z"></A><B>v_CTRL-Z</B>*
<A HREF="#CTRL-Z">CTRL-Z</A> Suspend Vim, like "<A HREF="#:stop">:stop</A>".
Works in <A HREF="intro.html#Normal">Normal</A> and in <A HREF="visual.html#Visual">Visual</A> mode. In <A HREF="insert.html#Insert">Insert</A> and
<A HREF="cmdline.html#Command-line">Command-line</A> mode, the <A HREF="#CTRL-Z">CTRL-Z</A> is inserted <A HREF="motion.html#as">as</A> a normal
character. In <A HREF="visual.html#Visual">Visual</A> mode Vim goes back to <A HREF="intro.html#Normal">Normal</A>
mode.
Note: if <A HREF="#CTRL-Z">CTRL-Z</A> undoes a change see |<A HREF="mswin.html">mswin.vim</A>|.
:sus[pend][!] or *<A NAME=":sus"></A><B>:sus</B>* *<A NAME=":suspend"></A><B>:suspend</B>* *<A NAME=":st"></A><B>:st</B>* *<A NAME=":stop"></A><B>:stop</B>*
:st[op][!] Suspend Vim.
If the '<A HREF="change.html#!">!</A>' is not given and <A HREF="options.html#'autowrite'">'autowrite'</A> is set, every
buffer with changes and a file name is written out.
If the '<A HREF="change.html#!">!</A>' is given or <A HREF="options.html#'autowrite'">'autowrite'</A> is not set, changed
<A HREF="windows.html#buffers">buffers</A> are not written, don't forget to bring Vim
back to the foreground later!
In the <A HREF="gui.html#GUI">GUI</A>, suspending is implemented <A HREF="motion.html#as">as</A> iconising <A HREF="#gvim">gvim</A>. In Windows 95/NT,
<A HREF="#gvim">gvim</A> is minimized.
On many <A HREF="os_unix.html#Unix">Unix</A> systems, <A HREF="motion.html#it">it</A> is possible to <A HREF="#suspend">suspend</A> Vim with <A HREF="#CTRL-Z">CTRL-Z</A>. This is only
possible in <A HREF="intro.html#Normal">Normal</A> and <A HREF="visual.html#Visual">Visual</A> mode (see next chapter, |<A HREF="intro.html#vim-modes">vim-modes</A>|). Vim will
continue if you make <A HREF="motion.html#it">it</A> the foreground <A HREF="channel.html#job">job</A> again. On other systems, <A HREF="#CTRL-Z">CTRL-Z</A>
will start a new shell. This is the same <A HREF="motion.html#as">as</A> the "<A HREF="various.html#:sh">:sh</A>" command. Vim will
continue if you exit from the shell.
In X-windows the selection is disowned when Vim suspends. this means you
can't paste <A HREF="motion.html#it">it</A> in another application (since Vim is going to sleep an attempt
to get the selection would make the program hang).
==============================================================================
7. Exiting *<A NAME="exiting"></A><B>exiting</B>*
There are several ways to exit Vim:
- Close the last <A HREF="windows.html#window">window</A> with `:quit`. Only when there are no changes.
- Close the last <A HREF="windows.html#window">window</A> with `:quit!`. Also when there are changes.
- Close all <A HREF="windows.html#windows">windows</A> with `:qall`. Only when there are no changes.
- Close all <A HREF="windows.html#windows">windows</A> with `:qall!`. Also when there are changes.
- Use `:cquit`. Also when there are changes.
When using `:cquit` or when there was an error message Vim exits with exit
code 1. Errors can be avoided by using `:silent!`.
==============================================================================
8. Saving settings *<A NAME="save-settings"></A><B>save-settings</B>*
Mostly you will edit your <A HREF="#vimrc">vimrc</A> files manually. This gives you the greatest
flexibility. There are a few commands to generate a <A HREF="#vimrc">vimrc</A> file automatically.
You can use these files <A HREF="motion.html#as">as</A> they are, or copy/paste lines to include in another
<A HREF="#vimrc">vimrc</A> file.
*<A NAME=":mk"></A><B>:mk</B>* *<A NAME=":mkexrc"></A><B>:mkexrc</B>*
:mk[exrc] [file] Write current key mappings and changed <A HREF="options.html#options">options</A> to
[file] (default "<A HREF="#.exrc">.exrc</A>" in the current directory),
unless <A HREF="motion.html#it">it</A> already exists. {not in Vi}
:mk[exrc]! [file] Always write current key mappings and changed
<A HREF="options.html#options">options</A> to [file] (default "<A HREF="#.exrc">.exrc</A>" in the current
directory). {not in Vi}
*<A NAME=":mkv"></A><B>:mkv</B>* *<A NAME=":mkvimrc"></A><B>:mkvimrc</B>*
:mkv[imrc][!] [file] Like "<A HREF="#:mkexrc">:mkexrc</A>", but the default is "<A HREF="#.vimrc">.vimrc</A>" in the
current directory. The "<A HREF="various.html#:version">:version</A>" command is also
written to the file. {not in Vi}
These commands will write "<A HREF="map.html#:map">:map</A>" and "<A HREF="options.html#:set">:set</A>" commands to a file, in such a way
that when these commands are executed, the current key mappings and <A HREF="options.html#options">options</A>
will be set to the same values. The <A HREF="options.html#options">options</A> <A HREF="options.html#'columns'">'columns'</A>, <A HREF="options.html#'endofline'">'endofline'</A>,
<A HREF="options.html#'fileformat'">'fileformat'</A>, <A HREF="options.html#'key'">'key'</A>, <A HREF="options.html#'lines'">'lines'</A>, <A HREF="options.html#'modified'">'modified'</A>, <A HREF="options.html#'scroll'">'scroll'</A>, <A HREF="options.html#'term'">'term'</A>, <A HREF="options.html#'textmode'">'textmode'</A>,
<A HREF="options.html#'ttyfast'">'ttyfast'</A> and <A HREF="options.html#'ttymouse'">'ttymouse'</A> are not included, because these are terminal or file
dependent. Note that the <A HREF="options.html#options">options</A> <A HREF="options.html#'binary'">'binary'</A>, <A HREF="options.html#'paste'">'paste'</A> and <A HREF="options.html#'readonly'">'readonly'</A> are
included, this might not always be what you want.
When special keys are used in mappings, The <A HREF="options.html#'cpoptions'">'cpoptions'</A> option will be
temporarily set to its Vim default, to avoid the mappings to be
misinterpreted. This makes the file incompatible with <A HREF="intro.html#Vi">Vi</A>, but makes sure <A HREF="motion.html#it">it</A>
can be used with different terminals.
Only global mappings are stored, not mappings local to a buffer.
A common method is to use a default "<A HREF="#.vimrc">.vimrc</A>" file, make some modifications
with "<A HREF="map.html#:map">:map</A>" and "<A HREF="options.html#:set">:set</A>" commands and write the modified file. First read the
default "<A HREF="#.vimrc">.vimrc</A>" in with a command like "<A HREF="repeat.html#:source">:source</A> ~piet/.vimrc.Cprogs", change
the settings and then save them in the current directory with ":mkvimrc!". If
you want to make this file your default <A HREF="#.vimrc">.vimrc</A>, move <A HREF="motion.html#it">it</A> to your home directory
(on Unix), <A HREF="change.html#s">s</A>: (Amiga) or <A HREF="#$VIM">$VIM</A> directory (MS-DOS). You could also use
autocommands |<A HREF="autocmd.html#autocommand">autocommand</A>| and/or modelines |<A HREF="options.html#modeline">modeline</A>|.
*<A NAME="vimrc-option-example"></A><B>vimrc-option-example</B>*
If you only want to add a single option setting to your <A HREF="#vimrc">vimrc</A>, you can use
these steps:
1. Edit your <A HREF="#vimrc">vimrc</A> file with Vim.
2. Play with the option until it's right. E.g., try out different values for
<A HREF="options.html#'guifont'">'guifont'</A>.
3. Append a line to set the value of the option, using the <A HREF="eval.html#expression">expression</A> <A HREF="sponsor.html#register">register</A>
'<A HREF="change.html#=">=</A>' to enter the value. E.g., for the <A HREF="options.html#'guifont'">'guifont'</A> option:
<B> o:set guifont=<C-R>=&guifont<CR><Esc></B>
[<C-R> is a <A HREF="undo.html#CTRL-R">CTRL-R</A>, <A HREF="motion.html#<CR>"><CR></A> is a return, <A HREF="intro.html#<Esc>"><Esc></A> is the <A HREF="intro.html#escape">escape</A> key]
You need to <A HREF="intro.html#escape">escape</A> special characters, esp. spaces.
Note that when you create a <A HREF="#.vimrc">.vimrc</A> file, this can influence the <A HREF="options.html#'compatible'">'compatible'</A>
option, which has several side effects. See |<A HREF="options.html#'compatible'">'compatible'</A>|.
"<A HREF="#:mkvimrc">:mkvimrc</A>", "<A HREF="#:mkexrc">:mkexrc</A>" and "<A HREF="#:mksession">:mksession</A>" write the command to set or reset the
<A HREF="options.html#'compatible'">'compatible'</A> option to the output file first, because of these side effects.
==============================================================================
9. Views and Sessions *<A NAME="views-sessions"></A><B>views-sessions</B>*
This is introduced in sections |<A HREF="usr_21.html#21.4">21.4</A>| and |<A HREF="usr_21.html#21.5">21.5</A>| of the user manual.
*<A NAME="View"></A><B>View</B>* *<A NAME="view-file"></A><B>view-file</B>*
A <A HREF="#View">View</A> is a collection of settings that apply to one <A HREF="windows.html#window">window</A>. You can save a
<A HREF="#View">View</A> and when you restore <A HREF="motion.html#it">it</A> later, the text is displayed in the same way.
The <A HREF="options.html#options">options</A> and mappings in this <A HREF="windows.html#window">window</A> will also be restored, so that you can
continue editing like when the <A HREF="#View">View</A> was saved.
*<A NAME="Session"></A><B>Session</B>* *<A NAME="session-file"></A><B>session-file</B>*
A <A HREF="#Session">Session</A> keeps the Views for all <A HREF="windows.html#windows">windows</A>, plus the global settings. You can
save a <A HREF="#Session">Session</A> and when you restore <A HREF="motion.html#it">it</A> later the <A HREF="windows.html#window">window</A> layout looks the same.
You can use a <A HREF="#Session">Session</A> to quickly switch between different projects,
automatically loading the files you were last working on in that project.
Views and Sessions are a <A HREF="todo.html#nice">nice</A> addition to viminfo-files, which are used to
remember information for all Views and Sessions together |<A HREF="#viminfo-file">viminfo-file</A>|.
You can quickly start editing with a previously saved <A HREF="#View">View</A> or <A HREF="#Session">Session</A> with the
|<A HREF="#-S">-S</A>| argument:
<B> vim -S Session.vim</B>
All this is {not in Vi} and {not available when compiled without the
|<A HREF="various.html#+mksession">+mksession</A>| feature}.
*<A NAME=":mks"></A><B>:mks</B>* *<A NAME=":mksession"></A><B>:mksession</B>*
:mks[ession][!] [file] Write a Vim <A HREF="usr_41.html#script">script</A> that restores the current editing
session.
When [!] is included an existing file is overwritten.
When [file] is omitted "Session.vim" is used.
The output of "<A HREF="#:mksession">:mksession</A>" is like "<A HREF="#:mkvimrc">:mkvimrc</A>", but additional commands are
added to the file. Which ones depends on the <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> option. The
resulting file, when executed with a "<A HREF="repeat.html#:source">:source</A>" command:
1. Restores global mappings and <A HREF="options.html#options">options</A>, if <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains
"<A HREF="options.html#options">options</A>". Script-local mappings will not be written.
2. Restores global <A HREF="eval.html#variables">variables</A> that start with an <A HREF="change.html#uppercase">uppercase</A> <A HREF="print.html#letter">letter</A> and contain
at least one <A HREF="change.html#lowercase">lowercase</A> <A HREF="print.html#letter">letter</A>, if <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains "globals".
3. Unloads all currently loaded <A HREF="windows.html#buffers">buffers</A>.
4. Restores the current directory if <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains "curdir", or
sets the current directory to where the <A HREF="#Session">Session</A> file is if <A HREF="options.html#'sessionoptions'">'sessionoptions'</A>
contains "sesdir".
5. Restores <A HREF="gui.html#GUI">GUI</A> Vim <A HREF="windows.html#window">window</A> position, if <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains "winpos".
6. Restores screen size, if <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains "resize".
7. Reloads the buffer <A HREF="eval.html#list">list</A>, with the last cursor positions. If
<A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains "<A HREF="windows.html#buffers">buffers</A>" then all <A HREF="windows.html#buffers">buffers</A> are restored,
including hidden and unloaded <A HREF="windows.html#buffers">buffers</A>. Otherwise only <A HREF="windows.html#buffers">buffers</A> in <A HREF="windows.html#windows">windows</A>
are restored.
8. Restores all <A HREF="windows.html#windows">windows</A> with the same layout. If <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains
"help", help <A HREF="windows.html#windows">windows</A> are restored. If <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains "blank",
<A HREF="windows.html#windows">windows</A> editing a buffer without a name will be restored.
If <A HREF="options.html#'sessionoptions'">'sessionoptions'</A> contains "winsize" and no (help/blank) <A HREF="windows.html#windows">windows</A> were
left out, the <A HREF="windows.html#window">window</A> sizes are restored (relative to the screen size).
Otherwise, the <A HREF="windows.html#windows">windows</A> are just given sensible sizes.
9. Restores the Views for all the <A HREF="windows.html#windows">windows</A>, <A HREF="motion.html#as">as</A> with |<A HREF="#:mkview">:mkview</A>|. But
<A HREF="options.html#'sessionoptions'">'sessionoptions'</A> is used instead of <A HREF="options.html#'viewoptions'">'viewoptions'</A>.
10. If a file exists with the same name <A HREF="motion.html#as">as</A> the <A HREF="#Session">Session</A> file, but ending in
"x.vim" (for eXtra), executes that <A HREF="motion.html#as">as</A> well. You can use *x.vim files to
specify additional settings and actions associated with a given <A HREF="#Session">Session</A>,
such <A HREF="motion.html#as">as</A> creating menu items in the <A HREF="gui.html#GUI">GUI</A> version.
After restoring the <A HREF="#Session">Session</A>, the full filename of your current <A HREF="#Session">Session</A> is
available in the internal variable "<A HREF="eval.html#v:this_session">v:this_session</A>" |<A HREF="eval.html#this_session-variable">this_session-variable</A>|.
An example <A HREF="map.html#mapping">mapping</A>:
<B> :nmap <F2> :wa<Bar>exe "mksession! " . v:this_session<CR>:so ~/sessions/</B>
This saves the current <A HREF="#Session">Session</A>, and starts off the command to load another.
A session includes all <A HREF="intro.html#tab">tab</A> pages, unless "tabpages" was removed from
<A HREF="options.html#'sessionoptions'">'sessionoptions'</A>. |<A HREF="tabpage.html#tab-page">tab-page</A>|
The |<A HREF="autocmd.html#SessionLoadPost">SessionLoadPost</A>| autocmd event is triggered after a session file is
loaded/sourced.
*<A NAME="SessionLoad-variable"></A><B>SessionLoad-variable</B>*
While the session file is loading the SessionLoad global variable is set to 1.
Plugins can use this to postpone some work until the <A HREF="autocmd.html#SessionLoadPost">SessionLoadPost</A> event is
triggered.
*<A NAME=":mkvie"></A><B>:mkvie</B>* *<A NAME=":mkview"></A><B>:mkview</B>*
:mkvie[w][!] [file] Write a Vim <A HREF="usr_41.html#script">script</A> that restores the contents of the
current <A HREF="windows.html#window">window</A>.
When [!] is included an existing file is overwritten.
When [file] is omitted or is a number from 1 to 9, a
name is generated and <A HREF="options.html#'viewdir'">'viewdir'</A> prepended. When the
last path part of <A HREF="options.html#'viewdir'">'viewdir'</A> does not exist, this
directory is created. E.g., when <A HREF="options.html#'viewdir'">'viewdir'</A> is
"$VIM/vimfiles/view" then "<A HREF="#view">view</A>" is created in
"$VIM/vimfiles".
An existing file is always overwritten then. Use
|<A HREF="#:loadview">:loadview</A>| to load this view again.
When [file] is the name of a file ('viewdir' is not
used), a command to edit the file is added to the
generated file.
The output of "<A HREF="#:mkview">:mkview</A>" contains these items:
1. The argument <A HREF="eval.html#list">list</A> used in the <A HREF="windows.html#window">window</A>. When the global argument <A HREF="eval.html#list">list</A> is
used <A HREF="motion.html#it">it</A> is reset to the global <A HREF="eval.html#list">list</A>.
The index in the argument <A HREF="eval.html#list">list</A> is also restored.
2. The file being edited in the <A HREF="windows.html#window">window</A>. If there is no file, the <A HREF="windows.html#window">window</A> is
made empty.
3. Restore mappings, <A HREF="map.html#abbreviations">abbreviations</A> and <A HREF="options.html#options">options</A> local to the <A HREF="windows.html#window">window</A> if
<A HREF="options.html#'viewoptions'">'viewoptions'</A> contains "<A HREF="options.html#options">options</A>" or "localoptions". For the <A HREF="options.html#options">options</A> <A HREF="motion.html#it">it</A>
restores only values that are local to the current buffer and values local
to the <A HREF="windows.html#window">window</A>.
When storing the <A HREF="#view">view</A> <A HREF="motion.html#as">as</A> part of a session and "<A HREF="options.html#options">options</A>" is in
<A HREF="options.html#'sessionoptions'">'sessionoptions'</A>, global values for local <A HREF="options.html#options">options</A> will be stored too.
4. Restore <A HREF="fold.html#folds">folds</A> when using manual <A HREF="fold.html#folding">folding</A> and <A HREF="options.html#'viewoptions'">'viewoptions'</A> contains
"<A HREF="fold.html#folds">folds</A>". Restore manually opened and closed <A HREF="fold.html#folds">folds</A>.
5. The scroll position and the cursor position in the file. Doesn't work very
well when there are closed <A HREF="fold.html#folds">folds</A>.
6. The local current directory, if <A HREF="motion.html#it">it</A> is different from the global current
directory.
Note that Views and Sessions are not perfect:
- They don't restore everything. For example, defined <A HREF="eval.html#functions">functions</A>, autocommands
and "<A HREF="syntax.html#:syntax">:syntax</A> on" are not included. Things like <A HREF="sponsor.html#register">register</A> contents and
command line <A HREF="cmdline.html#history">history</A> are in <A HREF="#viminfo">viminfo</A>, not in Sessions or Views.
- Global option values are only set when they differ from the default value.
When the current value is not the default value, loading a <A HREF="#Session">Session</A> will not
set <A HREF="motion.html#it">it</A> back to the default value. Local <A HREF="options.html#options">options</A> will be set back to the
default value though.
- Existing mappings will be overwritten without warning. An existing <A HREF="map.html#mapping">mapping</A>
may cause an error for ambiguity.
- When storing manual <A HREF="fold.html#folds">folds</A> and when storing manually opened/closed <A HREF="fold.html#folds">folds</A>,
changes in the file between saving and loading the <A HREF="#view">view</A> will mess <A HREF="motion.html#it">it</A> up.
- The Vim <A HREF="usr_41.html#script">script</A> is not very efficient. But still faster than typing the
commands yourself!
*<A NAME=":lo"></A><B>:lo</B>* *<A NAME=":loadview"></A><B>:loadview</B>*
:lo[adview] [nr] Load the <A HREF="#view">view</A> for the current file. When [nr] is
omitted, the <A HREF="#view">view</A> stored with "<A HREF="#:mkview">:mkview</A>" is loaded.
When [nr] is specified, the <A HREF="#view">view</A> stored with "<A HREF="#:mkview">:mkview</A>
[nr]" is loaded.
The combination of "<A HREF="#:mkview">:mkview</A>" and "<A HREF="#:loadview">:loadview</A>" can be used to store up to ten
different views of a file. These are remembered in the directory specified
with the <A HREF="options.html#'viewdir'">'viewdir'</A> option. The views are stored using the file name. If a
file is renamed or accessed through a (symbolic) link the <A HREF="#view">view</A> will not be
found.
You might want to clean up your <A HREF="options.html#'viewdir'">'viewdir'</A> directory now and then.
To automatically save and restore views for *.c files:
<B> au BufWinLeave *.c mkview</B>
<B> au BufWinEnter *.c silent loadview</B>
==============================================================================
10. The <A HREF="#viminfo">viminfo</A> file *<A NAME="viminfo"></A><B>viminfo</B>* *<A NAME="viminfo-file"></A><B>viminfo-file</B>* *<A NAME="E136"></A><B>E136</B>*
*<A NAME="E575"></A><B>E575</B>* *<A NAME="E576"></A><B>E576</B>* *<A NAME="E577"></A><B>E577</B>*
If you exit Vim and later start <A HREF="motion.html#it">it</A> again, you would normally lose a lot of
information. The <A HREF="#viminfo">viminfo</A> file can be used to remember that information, which
enables you to continue where you left off.
This is introduced in section |<A HREF="usr_21.html#21.3">21.3</A>| of the user manual.
The <A HREF="#viminfo">viminfo</A> file is used to store:
- The command line <A HREF="cmdline.html#history">history</A>.
- The search <A HREF="eval.html#string">string</A> <A HREF="cmdline.html#history">history</A>.
- The input-line <A HREF="cmdline.html#history">history</A>.
- <A HREF="quickref.html#Contents">Contents</A> of non-empty <A HREF="change.html#registers">registers</A>.
- Marks for several files.
- File marks, pointing to locations in files.
- Last search/substitute <A HREF="pattern.html#pattern">pattern</A> (for '<A HREF="pattern.html#n">n</A>' and '&').
- The buffer <A HREF="eval.html#list">list</A>.
- Global <A HREF="eval.html#variables">variables</A>.
The viminfo file is not supported when the |<A HREF="various.html#+viminfo">+viminfo</A>| feature has been
disabled at compile time.
You could also use a <A HREF="#Session">Session</A> file. The difference is that the <A HREF="#viminfo">viminfo</A> file
does not depend on what you are working on. There normally is only one
<A HREF="#viminfo">viminfo</A> file. <A HREF="#Session">Session</A> files are used to save the state of a specific editing
<A HREF="#Session">Session</A>. You could have several <A HREF="#Session">Session</A> files, one for each project you are
working on. Viminfo and <A HREF="#Session">Session</A> files together can be used to effectively
enter Vim and directly start working in your desired setup. |<A HREF="#session-file">session-file</A>|
*<A NAME="viminfo-read"></A><B>viminfo-read</B>*
When Vim is started and the <A HREF="options.html#'viminfo'">'viminfo'</A> option is non-empty, the contents of
the <A HREF="#viminfo">viminfo</A> file are read and the info can be used in the appropriate places.
The |<A HREF="eval.html#v:oldfiles">v:oldfiles</A>| variable is filled. The marks are not read in at <A HREF="#startup">startup</A>
(but file marks are). See |<A HREF="#initialization">initialization</A>| for how to set the <A HREF="options.html#'viminfo'">'viminfo'</A>
option upon <A HREF="#startup">startup</A>.
*<A NAME="viminfo-write"></A><B>viminfo-write</B>*
When Vim exits and <A HREF="options.html#'viminfo'">'viminfo'</A> is non-empty, the info is stored in the <A HREF="#viminfo">viminfo</A>
file (it's actually merged with the existing one, if one exists). The
<A HREF="options.html#'viminfo'">'viminfo'</A> option is a <A HREF="eval.html#string">string</A> containing information about what info should be
stored, and contains <A HREF="vi_diff.html#limits">limits</A> on how much should be stored (see <A HREF="options.html#'viminfo'">'viminfo'</A>).
Notes for <A HREF="os_unix.html#Unix">Unix</A>:
- The file protection for the <A HREF="#viminfo">viminfo</A> file will be set to prevent other users
from being able to read <A HREF="motion.html#it">it</A>, because <A HREF="motion.html#it">it</A> may contain any text or commands that
you have worked with.
- If you want to share the <A HREF="#viminfo">viminfo</A> file with other users (e.g. when you "su"
to another user), you can make the file writable for the group or everybody.
Vim will preserve this when <A HREF="editing.html#writing">writing</A> new <A HREF="#viminfo">viminfo</A> files. Be careful, don't
allow just anybody to read and write your <A HREF="#viminfo">viminfo</A> file!
- Vim will not overwrite a <A HREF="#viminfo">viminfo</A> file that is not writable by the current
"real" user. This helps for when you did "su" to become root, but your
<A HREF="options.html#$HOME">$HOME</A> is still set to a normal user's home directory. Otherwise Vim would
create a <A HREF="#viminfo">viminfo</A> file owned by root that nobody else can read.
- The <A HREF="#viminfo">viminfo</A> file cannot be a symbolic link. This is to avoid security
issues.
Marks are stored for each file separately. When a file is read and <A HREF="options.html#'viminfo'">'viminfo'</A>
is non-empty, the marks for that file are read from the <A HREF="#viminfo">viminfo</A> file. NOTE:
The marks are only written when <A HREF="#exiting">exiting</A> Vim, which is fine because marks are
remembered for all the files you have opened in the current editing session,
unless "<A HREF="windows.html#:bdel">:bdel</A>" is used. If you want to save the marks for a file that you are
about to <A HREF="editing.html#abandon">abandon</A> with "<A HREF="windows.html#:bdel">:bdel</A>", use "<A HREF="#:wv">:wv</A>". The '<A HREF="index.html#[">[</A>' and '<A HREF="index.html#]">]</A>' marks are not
stored, but the '"'' <A HREF="motion.html#mark">mark</A> is. The '"'' <A HREF="motion.html#mark">mark</A> is very useful for jumping to the
cursor position when the file was last exited. No marks are saved for files
that start with any <A HREF="eval.html#string">string</A> given with the "<A HREF="change.html#r">r</A>" flag in <A HREF="options.html#'viminfo'">'viminfo'</A>. This can be
used to avoid saving marks for files on removable media (for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> you would
use "ra:,rb:", for <A HREF="os_amiga.html#Amiga">Amiga</A> "rdf0:,rdf1:,rdf2:").
The |<A HREF="eval.html#v:oldfiles">v:oldfiles</A>| variable is filled with the file names that the <A HREF="#viminfo">viminfo</A> file
has marks for.
*<A NAME="viminfo-file-marks"></A><B>viminfo-file-marks</B>*
Uppercase marks ('A to 'Z) are stored when <A HREF="editing.html#writing">writing</A> the <A HREF="#viminfo">viminfo</A> file. The
numbered marks ('0 to '9) are a bit special. When the <A HREF="#viminfo">viminfo</A> file is written
(when <A HREF="#exiting">exiting</A> or with the "<A HREF="#:wviminfo">:wviminfo</A>" command), <A HREF="motion.html#'0">'0</A> is set to the current cursor
position and file. The old <A HREF="motion.html#'0">'0</A> is moved to '1, '1 to '2, etc. This
resembles what happens with the "1 to "9 delete <A HREF="change.html#registers">registers</A>. If the current
cursor position is already present in <A HREF="motion.html#'0">'0</A> to '9, <A HREF="motion.html#it">it</A> is moved to <A HREF="motion.html#'0">'0</A>, to avoid
having the same position <A HREF="if_cscop.html#twice">twice</A>. The result is that with "<A HREF="motion.html#'0">'0</A>", you can jump
back to the file and line where you exited Vim. To <A HREF="diff.html#do">do</A> that right away, try
using this command:
<B> vim -c "normal '0"</B>
In a csh compatible shell you could make an alias for <A HREF="motion.html#it">it</A>:
<B> alias lvim vim -c '"'normal "'"0'"'</B>
For a bash-like shell:
<B> alias lvim='vim -c "normal '\''0"'</B>
Use the "<A HREF="change.html#r">r</A>" flag in <A HREF="options.html#'viminfo'">'viminfo'</A> to specify for which files no marks should be
remembered.
VIMINFO FILE NAME *<A NAME="viminfo-file-name"></A><B>viminfo-file-name</B>*
- The default name of the <A HREF="#viminfo">viminfo</A> file is "$HOME/.viminfo" for <A HREF="os_unix.html#Unix">Unix</A> and <A HREF="os_os2.html#OS/2">OS/2</A>,
"s:.viminfo" for <A HREF="os_amiga.html#Amiga">Amiga</A>, "$HOME\_viminfo" for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#Win32">Win32</A>. For the last
two, when <A HREF="options.html#$HOME">$HOME</A> is not set, "$VIM\_viminfo" is used. When <A HREF="#$VIM">$VIM</A> is also not
set, "c:\_viminfo" is used. For <A HREF="os_os2.html#OS/2">OS/2</A> "$VIM/.viminfo" is used when <A HREF="options.html#$HOME">$HOME</A> is
not set and <A HREF="#$VIM">$VIM</A> is set.
- The '<A HREF="pattern.html#n">n</A>' flag in the <A HREF="options.html#'viminfo'">'viminfo'</A> option can be used to specify another <A HREF="#viminfo">viminfo</A>
file name |<A HREF="options.html#'viminfo'">'viminfo'</A>|.
- The "-i" Vim argument can be used to set another file name, |<A HREF="#-i">-i</A>|. When the
file name given is "NONE" (all uppercase), no <A HREF="#viminfo">viminfo</A> file is ever read or
written. Also not for the commands below!
- For the commands below, another file name can be given, overriding the
default and the name given with <A HREF="options.html#'viminfo'">'viminfo'</A> or "<A HREF="#-i">-i</A>" (unless it's NONE).
CHARACTER ENCODING *<A NAME="viminfo-encoding"></A><B>viminfo-encoding</B>*
The text in the <A HREF="#viminfo">viminfo</A> file is encoded <A HREF="motion.html#as">as</A> specified with the <A HREF="options.html#'encoding'">'encoding'</A>
option. Normally you will always work with the same <A HREF="options.html#'encoding'">'encoding'</A> value, and
this works just fine. However, if you read the <A HREF="#viminfo">viminfo</A> file with another
value for <A HREF="options.html#'encoding'">'encoding'</A> than what <A HREF="motion.html#it">it</A> was written with, some of the text
(non-ASCII characters) may be invalid. If this is unacceptable, add the '<A HREF="change.html#c">c</A>'
flag to the <A HREF="options.html#'viminfo'">'viminfo'</A> option:
<B> :set viminfo+=c</B>
Vim will then attempt to convert the text in the <A HREF="#viminfo">viminfo</A> file from the
<A HREF="options.html#'encoding'">'encoding'</A> value <A HREF="motion.html#it">it</A> was written with to the current <A HREF="options.html#'encoding'">'encoding'</A> value. This
requires Vim to be compiled with the |<A HREF="various.html#+iconv">+iconv</A>| feature. Filenames are not
converted.
MANUALLY READING AND WRITING *<A NAME="viminfo-read-write"></A><B>viminfo-read-write</B>*
Two commands can be used to read and write the <A HREF="#viminfo">viminfo</A> file manually. This
can be used to exchange <A HREF="change.html#registers">registers</A> between two running Vim programs: First
type "<A HREF="#:wv">:wv</A>" in one and then "<A HREF="#:rv">:rv</A>" in the other. Note that if the <A HREF="sponsor.html#register">register</A>
already contained something, then ":rv!" would be required. Also note
however that this means everything will be overwritten with information from
the first Vim, including the command line <A HREF="cmdline.html#history">history</A>, etc.
The <A HREF="#viminfo">viminfo</A> file itself can be edited by hand too, although we suggest you
start with an existing one to get the format right. It is reasonably
self-explanatory once you're in there. This can be useful in order to
create a second file, say "~/.my_viminfo" which could contain certain
settings that you always want when you first start Vim. For example, you
can preload <A HREF="change.html#registers">registers</A> with particular data, or put certain commands in the
command line <A HREF="cmdline.html#history">history</A>. A line in your <A HREF="#.vimrc">.vimrc</A> file like
<B> :rviminfo! ~/.my_viminfo</B>
can be used to load this information. You could even have different viminfos
for different types of files (e.g., C code) and load them based on the file
name, using the ":autocmd" command (see |<A HREF="autocmd.html#:autocmd">:autocmd</A>|).
*<A NAME="viminfo-errors"></A><B>viminfo-errors</B>*
When Vim detects an error while reading a <A HREF="#viminfo">viminfo</A> file, <A HREF="motion.html#it">it</A> will not overwrite
that file. If there are more than 10 <A HREF="message.html#errors">errors</A>, Vim stops reading the <A HREF="#viminfo">viminfo</A>
file. This was done to avoid accidentally destroying a file when the file
name of the <A HREF="#viminfo">viminfo</A> file is wrong. This could happen when accidentally typing
"vim <A HREF="#-i">-i</A> file" when you wanted "vim <A HREF="#-R">-R</A> file" (yes, somebody accidentally did
that!). If you want to overwrite a <A HREF="#viminfo">viminfo</A> file with an error in <A HREF="motion.html#it">it</A>, you will
either have to fix the error, or delete the file (while Vim is running, so
most of the information will be restored).
*<A NAME=":rv"></A><B>:rv</B>* *<A NAME=":rviminfo"></A><B>:rviminfo</B>* *<A NAME="E195"></A><B>E195</B>*
:rv[iminfo][!] [file] Read from <A HREF="#viminfo">viminfo</A> file [file] (default: see above).
If [!] is given, then any information that is
already set (registers, marks, |<A HREF="eval.html#v:oldfiles">v:oldfiles</A>|, etc.)
will be overwritten {not in Vi}
*<A NAME=":wv"></A><B>:wv</B>* *<A NAME=":wviminfo"></A><B>:wviminfo</B>* *<A NAME="E137"></A><B>E137</B>* *<A NAME="E138"></A><B>E138</B>* *<A NAME="E574"></A><B>E574</B>* *<A NAME="E886"></A><B>E886</B>*
:wv[iminfo][!] [file] Write to <A HREF="#viminfo">viminfo</A> file [file] (default: see above).
The information in the file is first read in to make
a <A HREF="diff.html#merge">merge</A> between old and new info. When [!] is used,
the old information is not read first, only the
internal info is written. If <A HREF="options.html#'viminfo'">'viminfo'</A> is empty, marks
for up to 100 files will be written.
When you get error "E138: Can't write <A HREF="#viminfo">viminfo</A> file"
check that no old temp files were left behind (e.g.
~/.viminf*) and that you can write in the directory of
the .viminfo file.
{not in Vi}
*<A NAME=":ol"></A><B>:ol</B>* *<A NAME=":oldfiles"></A><B>:oldfiles</B>*
:ol[dfiles] <A HREF="eval.html#List">List</A> the files that have marks stored in the <A HREF="#viminfo">viminfo</A>
file. This <A HREF="eval.html#list">list</A> is read on <A HREF="#startup">startup</A> and only changes
afterwards with ":rviminfo!". Also see |<A HREF="eval.html#v:oldfiles">v:oldfiles</A>|.
The number can be used with |<A HREF="cmdline.html#c_#<">c_#<</A>|.
{not in <A HREF="intro.html#Vi">Vi</A>, only when compiled with the |<A HREF="various.html#+eval">+eval</A>|
feature}
:bro[wse] ol[dfiles][!]
<A HREF="eval.html#List">List</A> file names <A HREF="motion.html#as">as</A> with |<A HREF="#:oldfiles">:oldfiles</A>|, and then prompt
for a number. When the number is valid that file from
the <A HREF="eval.html#list">list</A> is edited.
If you get the |<A HREF="message.html#press-enter">press-enter</A>| prompt you can press "<A HREF="repeat.html#q">q</A>"
and still get the prompt to enter a file number.
Use ! to abandon a modified buffer. |<A HREF="editing.html#abandon">abandon</A>|
{not when compiled with tiny or small features}
<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>
</HTML>
|