/usr/share/doc/vim/html/editing.html is in vim-doc 2:8.0.1453-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 | <HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: editing</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: editing</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>
<HR>
<PRE>
*<A NAME="editing.txt"></A><B>editing.txt</B>* For Vim version 8.0. Last change: 2017 Nov 16
VIM REFERENCE MANUAL by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>
Editing files *<A NAME="edit-files"></A><B>edit-files</B>*
1. Introduction |<A HREF="#edit-intro">edit-intro</A>|
2. Editing a file |<A HREF="#edit-a-file">edit-a-file</A>|
3. The argument list |<A HREF="#argument-list">argument-list</A>|
4. Writing |<A HREF="#writing">writing</A>|
5. Writing and quitting |<A HREF="#write-quit">write-quit</A>|
6. Dialogs |<A HREF="#edit-dialogs">edit-dialogs</A>|
7. The current directory |<A HREF="#current-directory">current-directory</A>|
8. Editing binary files |<A HREF="#edit-binary">edit-binary</A>|
9. Encryption |<A HREF="#encryption">encryption</A>|
10. Timestamps |<A HREF="#timestamps">timestamps</A>|
11. File Searching |<A HREF="#file-searching">file-searching</A>|
==============================================================================
1. Introduction *<A NAME="edit-intro"></A><B>edit-intro</B>*
Editing a file with Vim means:
1. reading the file into a buffer
2. <A HREF="change.html#changing">changing</A> the buffer with editor commands
3. <A HREF="#writing">writing</A> the buffer into a file
*<A NAME="current-file"></A><B>current-file</B>*
As long <A HREF="motion.html#as">as</A> you don't write the buffer, the original file remains unchanged.
If you start editing a file (read a file into the buffer), the file name is
remembered <A HREF="motion.html#as">as</A> the "current file name". This is also known <A HREF="motion.html#as">as</A> the name of the
current buffer. It can be used with "%" on the command line |<A HREF="cmdline.html#:_%">:_%</A>|.
*<A NAME="alternate-file"></A><B>alternate-file</B>*
If there already was a current file name, then that one becomes the alternate
file name. It can be used with "#" on the command line |<A HREF="cmdline.html#:_#">:_#</A>| and you can use
the |<A HREF="#CTRL-^">CTRL-^</A>| command to toggle between the current and the alternate file.
However, the alternate file name is not changed when |<A HREF="#:keepalt">:keepalt</A>| is used.
An alternate file name is remembered for each <A HREF="windows.html#window">window</A>.
*<A NAME=":keepalt"></A><B>:keepalt</B>* *<A NAME=":keepa"></A><B>:keepa</B>*
<A HREF="#:keepalt">:keepalt</A> {cmd} Execute {cmd} while keeping the current alternate file
name. Note that commands invoked indirectly (e.g.,
with a function) may still set the alternate file
name. {not in Vi}
All file names are remembered in the buffer <A HREF="eval.html#list">list</A>. When you enter a file name,
for editing (e.g., with "<A HREF="#:e">:e</A> filename") or <A HREF="#writing">writing</A> (e.g., with "<A HREF="#:w">:w</A> filename"),
the file name is added to the <A HREF="eval.html#list">list</A>. You can use the buffer <A HREF="eval.html#list">list</A> to remember
which files you edited and to quickly switch from one file to another (e.g.,
to copy text) with the |<A HREF="#CTRL-^">CTRL-^</A>| command. First type the number of the file
and then hit <A HREF="#CTRL-^">CTRL-^</A>. {Vi: only one alternate file name is remembered}
<A HREF="#CTRL-G">CTRL-G</A> or *<A NAME="CTRL-G"></A><B>CTRL-G</B>* *<A NAME=":f"></A><B>:f</B>* *<A NAME=":fi"></A><B>:fi</B>* *<A NAME=":file"></A><B>:file</B>*
:f[ile] Prints the current file name (as typed, unless "<A HREF="#:cd">:cd</A>"
was used), the cursor position (unless the <A HREF="options.html#'ruler'">'ruler'</A>
option is set), and the file status (readonly,
modified, read <A HREF="message.html#errors">errors</A>, new file). See the <A HREF="options.html#'shortmess'">'shortmess'</A>
option about how to make this message shorter.
{Vi does not include column number}
:f[ile]! like |<A HREF="#:file">:file</A>|, but don't truncate the name even when
<A HREF="options.html#'shortmess'">'shortmess'</A> indicates this.
{count}CTRL-G Like <A HREF="#CTRL-G">CTRL-G</A>, but prints the current file name with
full path. If the <A HREF="intro.html#count">count</A> is higher than 1 the current
buffer number is also given. {not in Vi}
*<A NAME="g_CTRL-G"></A><B>g_CTRL-G</B>* *<A NAME="word-count"></A><B>word-count</B>* *<A NAME="byte-count"></A><B>byte-count</B>*
<A HREF="index.html#g">g</A> <A HREF="#CTRL-G">CTRL-G</A> Prints the current position of the cursor in five
ways: Column, Line, Word, Character and Byte. If the
number of Characters and Bytes is the same then the
Character position is omitted.
If there are characters in the line that take more
than one position on the screen (<Tab> or special
character), both the "real" column and the screen
column are shown, separated with a dash.
Also see the <A HREF="options.html#'ruler'">'ruler'</A> option and the |<A HREF="eval.html#wordcount()">wordcount()</A>|
function.
{not in Vi}
*<A NAME="v_g_CTRL-G"></A><B>v_g_CTRL-G</B>*
{Visual}g <A HREF="#CTRL-G">CTRL-G</A> Similar to "g CTRL-G", but Word, Character, Line, and
Byte counts for the visually selected region are
displayed.
In Blockwise mode, Column <A HREF="intro.html#count">count</A> is also shown. (For
<A HREF="intro.html#{Visual}">{Visual}</A> see |<A HREF="visual.html#Visual-mode">Visual-mode</A>|.)
{not in VI}
*<A NAME=":file_f"></A><B>:file_f</B>*
:f[ile][!] {name} Sets the current file name to {name}. The optional !
avoids truncating the message, <A HREF="motion.html#as">as</A> with |<A HREF="#:file">:file</A>|.
If the buffer did have a name, that name becomes the
|<A HREF="#alternate-file">alternate-file</A>| name. An unlisted buffer is created
to hold the old name.
*<A NAME=":0file"></A><B>:0file</B>*
:0f[ile][!] Remove the name of the current buffer. The optional !
avoids truncating the message, <A HREF="motion.html#as">as</A> with |<A HREF="#:file">:file</A>|. {not
in Vi}
<A HREF="windows.html#:buffers">:buffers</A>
<A HREF="windows.html#:files">:files</A>
<A HREF="windows.html#:ls">:ls</A> <A HREF="eval.html#List">List</A> all the currently known file names. See
'<A HREF="windows.html#windows.txt">windows.txt</A>' |<A HREF="windows.html#:files">:files</A>| |<A HREF="windows.html#:buffers">:buffers</A>| |<A HREF="windows.html#:ls">:ls</A>|. {not in
Vi}
Vim will remember the full path name of a file name that you enter. In most
cases when the file name is displayed only the name you typed is shown, but
the full path name is being used if you used the ":cd" command |<A HREF="#:cd">:cd</A>|.
*<A NAME="home-replace"></A><B>home-replace</B>*
If the environment variable <A HREF="options.html#$HOME">$HOME</A> is set, and the file name starts with that
<A HREF="eval.html#string">string</A>, <A HREF="motion.html#it">it</A> is often displayed with HOME replaced with "<A HREF="change.html#~">~</A>". This was done to
keep file names short. When reading or <A HREF="#writing">writing</A> files the full name is still
used, the "<A HREF="change.html#~">~</A>" is only used when displaying file names. When <A HREF="change.html#replacing">replacing</A> the
file name would result in just "<A HREF="change.html#~">~</A>", "~/" is used instead (to avoid confusion
between <A HREF="options.html#options">options</A> set to <A HREF="options.html#$HOME">$HOME</A> with <A HREF="options.html#'backupext'">'backupext'</A> set to "~").
When <A HREF="#writing">writing</A> the buffer, the default is to use the current file name. Thus
when you give the "<A HREF="#ZZ">ZZ</A>" or "<A HREF="#:wq">:wq</A>" command, the original file will be
overwritten. If you <A HREF="diff.html#do">do</A> not want this, the buffer can be written into another
file by giving a file name argument to the "<A HREF="#:write">:write</A>" command. For example:
<B> vim testfile</B>
<B> [change the buffer with editor commands]</B>
<B> :w newfile</B>
<B> :q</B>
This will create a file "newfile", that is a modified copy of "testfile".
The file "testfile" will remain unchanged. Anyway, if the <A HREF="options.html#'backup'">'backup'</A> option is
set, Vim renames or copies the original file before <A HREF="motion.html#it">it</A> will be overwritten.
You can use this file if you discover that you need the original file. See
also the <A HREF="options.html#'patchmode'">'patchmode'</A> option. The name of the <A HREF="#backup">backup</A> file is normally the same
<A HREF="motion.html#as">as</A> the original file with <A HREF="options.html#'backupext'">'backupext'</A> appended. The default "<A HREF="change.html#~">~</A>" is a bit
strange to avoid accidentally overwriting existing files. If you prefer ".bak"
change the <A HREF="options.html#'backupext'">'backupext'</A> option. Extra dots are replaced with '<A HREF="motion.html#_">_</A>' on <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>
machines, when Vim has detected that an MS-DOS-like filesystem is being used
(e.g., messydos or crossdos) or when the <A HREF="options.html#'shortname'">'shortname'</A> option is on. The
<A HREF="#backup">backup</A> file can be placed in another directory by setting <A HREF="options.html#'backupdir'">'backupdir'</A>.
*<A NAME="auto-shortname"></A><B>auto-shortname</B>*
Technical: On the <A HREF="os_amiga.html#Amiga">Amiga</A> you can use 30 characters for a file name. But on an
MS-DOS-compatible filesystem only 8 plus 3 characters are
available. Vim tries to detect the type of filesystem when <A HREF="motion.html#it">it</A> is
creating the .swp file. If an MS-DOS-like filesystem is suspected,
a flag is set that has the same effect <A HREF="motion.html#as">as</A> setting the <A HREF="options.html#'shortname'">'shortname'</A>
option. This flag will be reset <A HREF="motion.html#as">as</A> soon <A HREF="motion.html#as">as</A> you start editing a
new file. The flag will be used when making the file name for the
".swp" and ".~" files for the current file. But when you are
editing a file in a normal filesystem and write to an MS-DOS-like
filesystem the flag will not have been set. In that <A HREF="change.html#case">case</A> the
creation of the ".~" file may fail and you will get an error
message. Use the <A HREF="options.html#'shortname'">'shortname'</A> option in this <A HREF="change.html#case">case</A>.
When you started editing without giving a file name, "No File" is displayed in
<A HREF="message.html#messages">messages</A>. If the "<A HREF="#:write">:write</A>" command is used with a file name argument, the file
name for the current file is set to that file name. This only happens when
the 'F' flag is included in <A HREF="options.html#'cpoptions'">'cpoptions'</A> (by default <A HREF="motion.html#it">it</A> is included) |<A HREF="options.html#cpo-F">cpo-F</A>|.
This is useful when entering text in an empty buffer and then <A HREF="#writing">writing</A> <A HREF="motion.html#it">it</A> to a
file. If <A HREF="options.html#'cpoptions'">'cpoptions'</A> contains the '<A HREF="motion.html#f">f</A>' flag (by default <A HREF="motion.html#it">it</A> is NOT included)
|<A HREF="options.html#cpo-f">cpo-f</A>| the file name is set for the "<A HREF="insert.html#:read">:read</A> file" command. This is useful
when starting Vim without an argument and then doing "<A HREF="insert.html#:read">:read</A> file" to start
editing a file.
When the file name was set and <A HREF="options.html#'filetype'">'filetype'</A> is empty the <A HREF="filetype.html#filetype">filetype</A> detection
autocommands will be triggered.
*<A NAME="not-edited"></A><B>not-edited</B>*
Because the file name was set without really starting to edit that file, you
are protected from overwriting that file. This is done by setting the
"notedited" flag. You can see if this flag is set with the <A HREF="#CTRL-G">CTRL-G</A> or "<A HREF="#:file">:file</A>"
command. It will include "[Not edited]" when the "notedited" flag is set.
When <A HREF="#writing">writing</A> the buffer to the current file name (with ":w!"), the "notedited"
flag is reset.
*<A NAME="abandon"></A><B>abandon</B>*
Vim remembers whether you have changed the buffer. You are protected from
losing the changes you made. If you try to quit without <A HREF="#writing">writing</A>, or want to
start editing another file, Vim will refuse this. In order to overrule this
protection, add a '<A HREF="change.html#!">!</A>' to the command. The changes will then be lost. For
example: "<A HREF="#:q">:q</A>" will not work if the buffer was changed, but ":q!" will. To see
whether the buffer was changed use the "<A HREF="#CTRL-G">CTRL-G</A>" command. The message includes
the <A HREF="eval.html#string">string</A> "[Modified]" if the buffer has been changed, or "<A HREF="motion.html#+">+</A>" if the '<A HREF="motion.html#m">m</A>' flag
is in <A HREF="options.html#'shortmess'">'shortmess'</A>.
If you want to automatically save the changes without asking, switch on the
<A HREF="options.html#'autowriteall'">'autowriteall'</A> option. <A HREF="options.html#'autowrite'">'autowrite'</A> is the associated Vi-compatible option
that does not work for all commands.
If you want to keep the changed buffer without saving <A HREF="motion.html#it">it</A>, switch on the
<A HREF="options.html#'hidden'">'hidden'</A> option. See |<A HREF="windows.html#hidden-buffer">hidden-buffer</A>|. Some commands work like this even when
<A HREF="options.html#'hidden'">'hidden'</A> is not set, check the help for the command.
==============================================================================
2. Editing a file *<A NAME="edit-a-file"></A><B>edit-a-file</B>*
*<A NAME=":e"></A><B>:e</B>* *<A NAME=":edit"></A><B>:edit</B>* *<A NAME="reload"></A><B>reload</B>*
:e[dit] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> Edit the current file. This is useful to re-edit the
current file, when <A HREF="motion.html#it">it</A> has been changed outside of Vim.
This fails when changes have been made to the current
buffer and <A HREF="options.html#'autowriteall'">'autowriteall'</A> isn't set or the file can't
be written.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{Vi: no ++opt}
*<A NAME=":edit!"></A><B>:edit!</B>* *<A NAME="discard"></A><B>discard</B>*
:e[dit]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Edit the current file always. Discard any changes to
the current buffer. This is useful if you want to
start all over again.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{Vi: no ++opt}
*<A NAME=":edit_f"></A><B>:edit_f</B>*
:e[dit] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{file}">{file}</A>
Edit <A HREF="#{file}">{file}</A>.
This fails when changes have been made to the current
buffer, unless <A HREF="options.html#'hidden'">'hidden'</A> is set or <A HREF="options.html#'autowriteall'">'autowriteall'</A> is
set and the file can be written.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{Vi: no ++opt}
*<A NAME=":edit!_f"></A><B>:edit!_f</B>*
:e[dit]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{file}">{file}</A>
Edit <A HREF="#{file}">{file}</A> always. Discard any changes to the
current buffer.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{Vi: no ++opt}
:e[dit] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> #[count]
Edit the [count]th buffer (as shown by |<A HREF="windows.html#:files">:files</A>|).
This command does the same <A HREF="motion.html#as">as</A> <A HREF="intro.html#[count]">[count]</A> <A HREF="#CTRL-^">CTRL-^</A>. But "<A HREF="#:e">:e</A>
#" doesn't work if the alternate buffer doesn't have a
file name, while <A HREF="#CTRL-^">CTRL-^</A> still works then.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{Vi: no ++opt}
*<A NAME=":ene"></A><B>:ene</B>* *<A NAME=":enew"></A><B>:enew</B>*
:ene[w] Edit a new, unnamed buffer. This fails when changes
have been made to the current buffer, unless <A HREF="options.html#'hidden'">'hidden'</A>
is set or <A HREF="options.html#'autowriteall'">'autowriteall'</A> is set and the file can be
written.
If <A HREF="options.html#'fileformats'">'fileformats'</A> is not empty, the first format given
will be used for the new buffer. If <A HREF="options.html#'fileformats'">'fileformats'</A> is
empty, the <A HREF="options.html#'fileformat'">'fileformat'</A> of the current buffer is used.
{not in Vi}
*<A NAME=":ene!"></A><B>:ene!</B>* *<A NAME=":enew!"></A><B>:enew!</B>*
:ene[w]! Edit a new, unnamed buffer. Discard any changes to
the current buffer.
Set <A HREF="options.html#'fileformat'">'fileformat'</A> like |<A HREF="#:enew">:enew</A>|.
{not in Vi}
*<A NAME=":fin"></A><B>:fin</B>* *<A NAME=":find"></A><B>:find</B>*
:fin[d][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{file}">{file}</A>
Find <A HREF="#{file}">{file}</A> in <A HREF="options.html#'path'">'path'</A> and then |<A HREF="#:edit">:edit</A>| it.
{not in Vi} {not available when the |<A HREF="various.html#+file_in_path">+file_in_path</A>|
feature was disabled at compile time}
:{count}fin[d][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{file}">{file}</A>
Just like "<A HREF="#:find">:find</A>", but use the {count} match in
<A HREF="options.html#'path'">'path'</A>. Thus ":2find file" will find the second
"file" found in <A HREF="options.html#'path'">'path'</A>. When there are fewer matches
for the file in <A HREF="options.html#'path'">'path'</A> than asked for, you get an
error message.
*<A NAME=":ex"></A><B>:ex</B>*
<A HREF="#:ex">:ex</A> <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> [file]
Same <A HREF="motion.html#as">as</A> |<A HREF="#:edit">:edit</A>|.
*<A NAME=":vi"></A><B>:vi</B>* *<A NAME=":visual"></A><B>:visual</B>*
:vi[sual][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> [file]
When used in Ex mode: Leave |<A HREF="intro.html#Ex-mode">Ex-mode</A>|, go back to
<A HREF="intro.html#Normal">Normal</A> mode. Otherwise same <A HREF="motion.html#as">as</A> |<A HREF="#:edit">:edit</A>|.
*<A NAME=":vie"></A><B>:vie</B>* *<A NAME=":view"></A><B>:view</B>*
:vie[w][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> file
When used in Ex mode: Leave |<A HREF="intro.html#Ex-mode">Ex-mode</A>|, go back to
<A HREF="intro.html#Normal">Normal</A> mode. Otherwise same <A HREF="motion.html#as">as</A> |<A HREF="#:edit">:edit</A>|, but set
<A HREF="options.html#'readonly'">'readonly'</A> option for this buffer. {not in Vi}
*<A NAME="CTRL-^"></A><B>CTRL-^</B>* *<A NAME="CTRL-6"></A><B>CTRL-6</B>*
<A HREF="#CTRL-^">CTRL-^</A> Edit the alternate file. Mostly the alternate file is
the previously edited file. This is a quick way to
toggle between two files. It is equivalent to "<A HREF="#:e">:e</A> #",
except that <A HREF="motion.html#it">it</A> also works when there is no file name.
If the <A HREF="options.html#'autowrite'">'autowrite'</A> or <A HREF="options.html#'autowriteall'">'autowriteall'</A> option is on and
the buffer was changed, write <A HREF="motion.html#it">it</A>.
Mostly the ^ character is positioned on the 6 key,
pressing CTRL and 6 then gets you what we call <A HREF="#CTRL-^">CTRL-^</A>.
But on some non-US keyboards <A HREF="#CTRL-^">CTRL-^</A> is produced in
another way.
{count}CTRL-^ Edit [count]th file in the buffer <A HREF="eval.html#list">list</A> (equivalent to
"<A HREF="#:e">:e</A> #[count]"). This is a quick way to switch between
files.
See |<A HREF="#CTRL-^">CTRL-^</A>| above for further details.
{not in Vi}
[count]]f *<A NAME="]f"></A><B>]f</B>* *<A NAME="[f"></A><B>[f</B>*
[count][f Same <A HREF="motion.html#as">as</A> "<A HREF="#gf">gf</A>". Deprecated.
*<A NAME="gf"></A><B>gf</B>* *<A NAME="E446"></A><B>E446</B>* *<A NAME="E447"></A><B>E447</B>*
[count]gf Edit the file whose name is under or after the cursor.
Mnemonic: "goto file".
Uses the <A HREF="options.html#'isfname'">'isfname'</A> option to find out which characters
are supposed to be in a file name. Trailing
punctuation characters ".,:;!" are ignored. Escaped
spaces "\ " are reduced to a single space.
Uses the <A HREF="options.html#'path'">'path'</A> option <A HREF="motion.html#as">as</A> a <A HREF="eval.html#list">list</A> of directory names to
look for the file. See the <A HREF="options.html#'path'">'path'</A> option for details
about relative directories and <A HREF="#wildcards">wildcards</A>.
Uses the <A HREF="options.html#'suffixesadd'">'suffixesadd'</A> option to check for file names
with a suffix added.
If the file can't be found, <A HREF="options.html#'includeexpr'">'includeexpr'</A> is used to
modify the name and another attempt is done.
If a <A HREF="intro.html#[count]">[count]</A> is given, the count'th file that is found
in the <A HREF="options.html#'path'">'path'</A> is edited.
This command fails if Vim refuses to |<A HREF="#abandon">abandon</A>| the
current file.
If you want to edit the file in a new <A HREF="windows.html#window">window</A> use
|<A HREF="windows.html#CTRL-W_CTRL-F">CTRL-W_CTRL-F</A>|.
If you <A HREF="diff.html#do">do</A> want to edit a new file, use:
<B> :e <cfile></B>
To make <A HREF="#gf">gf</A> always work like that:
<B> :map gf :e <cfile><CR></B>
If the name is a hypertext link, that looks like
"type://machine/path", you need the |<A HREF="pi_netrw.html#netrw">netrw</A>| <A HREF="usr_05.html#plugin">plugin</A>.
For <A HREF="os_unix.html#Unix">Unix</A> the '<A HREF="change.html#~">~</A>' character is expanded, like in
"~user/file". Environment <A HREF="eval.html#variables">variables</A> are expanded too
|<A HREF="options.html#expand-env">expand-env</A>|.
{not in Vi}
{not available when the |<A HREF="various.html#+file_in_path">+file_in_path</A>| feature was
disabled at compile time}
*<A NAME="v_gf"></A><B>v_gf</B>*
{Visual}[count]gf Same <A HREF="motion.html#as">as</A> "<A HREF="#gf">gf</A>", but the highlighted text is used <A HREF="motion.html#as">as</A> the
name of the file to edit. <A HREF="options.html#'isfname'">'isfname'</A> is ignored.
Leading blanks are skipped, otherwise all blanks and
special characters are included in the file name.
(For <A HREF="intro.html#{Visual}">{Visual}</A> see |<A HREF="visual.html#Visual-mode">Visual-mode</A>|.)
{not in VI}
*<A NAME="gF"></A><B>gF</B>*
[count]gF Same <A HREF="motion.html#as">as</A> "<A HREF="#gf">gf</A>", except if a number follows the file
name, then the cursor is positioned on that line in
the file. The file name and the number must be
separated by a non-filename (see <A HREF="options.html#'isfname'">'isfname'</A>) and
non-numeric character. White space between the
filename, the separator and the number are ignored.
Examples:
<B><FONT COLOR="PURPLE"> eval.c:10 </FONT></B>
<B><FONT COLOR="PURPLE"> eval.c @ 20 </FONT></B>
<B><FONT COLOR="PURPLE"> eval.c (30) </FONT></B>
<B><FONT COLOR="PURPLE"> eval.c 40 </FONT></B>
*<A NAME="v_gF"></A><B>v_gF</B>*
{Visual}[count]gF Same <A HREF="motion.html#as">as</A> "<A HREF="#v_gf">v_gf</A>".
These commands are used to start editing a single file. This means that the
file is read into the buffer and the current file name is set. The file that
is opened depends on the current directory, see |<A HREF="#:cd">:cd</A>|.
See |<A HREF="insert.html#read-messages">read-messages</A>| for an explanation of the message that is given after the
file has been read.
You can use the ":e!" command if you messed up the buffer and want to start
all over again. The "<A HREF="#:e">:e</A>" command is only useful if you have changed the
current file name.
*<A NAME=":filename"></A><B>:filename</B>* *<A NAME="{file}"></A><B>{file}</B>*
Besides the things mentioned here, more special items for where a filename is
expected are mentioned at |<A HREF="cmdline.html#cmdline-special">cmdline-special</A>|.
Note for systems other than <A HREF="os_unix.html#Unix">Unix</A>: When using a command that accepts a single
file name (like "<A HREF="#:edit">:edit</A> file") spaces in the file name are allowed, but
trailing spaces are ignored. This is useful on systems that regularly embed
spaces in file names (like <A HREF="os_win32.html#MS-Windows">MS-Windows</A> and the <A HREF="os_amiga.html#Amiga">Amiga</A>). Example: The command
"<A HREF="#:e">:e</A> Long File Name " will edit the file "Long File Name". When using a
command that accepts more than one file name (like "<A HREF="#:next">:next</A> file1 file2")
embedded spaces must be escaped with a <A HREF="intro.html#backslash">backslash</A>.
*<A NAME="wildcard"></A><B>wildcard</B>* *<A NAME="wildcards"></A><B>wildcards</B>*
Wildcards in <A HREF="#{file}">{file}</A> are expanded, but <A HREF="motion.html#as">as</A> with file completion, <A HREF="options.html#'wildignore'">'wildignore'</A>
and <A HREF="options.html#'suffixes'">'suffixes'</A> apply. Which <A HREF="#wildcards">wildcards</A> are supported depends on the system.
These are the common ones:
? matches one character
* matches anything, including nothing
** matches anything, including nothing, recurses into directories
[abc] match '<A HREF="insert.html#a">a</A>', '<A HREF="motion.html#b">b</A>' or '<A HREF="change.html#c">c</A>'
To avoid the special meaning of the <A HREF="#wildcards">wildcards</A> prepend a <A HREF="intro.html#backslash">backslash</A>. However,
on <A HREF="os_win32.html#MS-Windows">MS-Windows</A> the <A HREF="intro.html#backslash">backslash</A> is a path separator and "path\[abc]" is still seen
<A HREF="motion.html#as">as</A> a <A HREF="#wildcard">wildcard</A> when "<A HREF="index.html#[">[</A>" is in the <A HREF="options.html#'isfname'">'isfname'</A> option. A simple way to avoid this
is to use "path\[[]abc]", this matches the file "path\[abc]".
*<A NAME="starstar-wildcard"></A><B>starstar-wildcard</B>*
Expanding "**" is possible on <A HREF="os_unix.html#Unix">Unix</A>, <A HREF="os_win32.html#Win32">Win32</A>, <A HREF="os_mac.html#Mac">Mac</A> OS/X and a few other systems.
This allows searching a directory tree. This goes up to 100 directories deep.
Note there are some commands where this works slightly differently, see
|<A HREF="#file-searching">file-searching</A>|.
Example:
<B> :n **/*.txt</B>
Finds files:
<B><FONT COLOR="PURPLE"> aaa.txt </FONT></B>
<B><FONT COLOR="PURPLE"> subdir/bbb.txt </FONT></B>
<B><FONT COLOR="PURPLE"> a/b/c/d/ccc.txt </FONT></B>
When non-wildcard characters are used right before or after "**" these are
only matched in the top directory. They are not used for directories further
down in the tree. For example:
<B> :n /usr/inc**/types.h</B>
Finds files:
<B><FONT COLOR="PURPLE"> /usr/include/types.h </FONT></B>
<B><FONT COLOR="PURPLE"> /usr/include/sys/types.h </FONT></B>
<B><FONT COLOR="PURPLE"> /usr/inc/old/types.h </FONT></B>
Note that the path with "/sys" is included because <A HREF="motion.html#it">it</A> does not need to match
"/inc". Thus it's like matching "/usr/inc*/*/*...", not
"/usr/inc*/inc*/inc*".
*<A NAME="backtick-expansion"></A><B>backtick-expansion</B>* *<A NAME="`-expansion"></A><B>`-expansion</B>*
On <A HREF="os_unix.html#Unix">Unix</A> and a few other systems you can also use backticks for the file name
argument, for example:
<B> :next `find . -name ver\\*.c -print`</B>
<B> :view `ls -t *.patch \| head -n1`</B>
The backslashes before the <A HREF="pattern.html#star">star</A> are required to prevent the shell from
expanding "ver*.c" prior to execution of the find program. The <A HREF="intro.html#backslash">backslash</A>
before the shell pipe symbol "|" prevents Vim from parsing <A HREF="motion.html#it">it</A> <A HREF="motion.html#as">as</A> command
termination.
This also works for most other systems, with the restriction that the
backticks must be around the whole item. It is not possible to have text
directly before the first or just after the last backtick.
*<A NAME="`="></A><B>`=</B>*
You can have the backticks expanded <A HREF="motion.html#as">as</A> a Vim <A HREF="eval.html#expression">expression</A>, instead of <A HREF="motion.html#as">as</A> an
external command, by putting an equal sign right after the first backtick,
e.g.:
<B> :e `=tempname()`</B>
The <A HREF="eval.html#expression">expression</A> can contain just about anything, thus this can also be used to
avoid the special meaning of '"'', '|', '<A HREF="motion.html#%">%</A>' and '<A HREF="pattern.html##">#</A>'. However, <A HREF="options.html#'wildignore'">'wildignore'</A>
does apply like to other <A HREF="#wildcards">wildcards</A>.
Environment <A HREF="eval.html#variables">variables</A> in the <A HREF="eval.html#expression">expression</A> are expanded when evaluating the
<A HREF="eval.html#expression">expression</A>, thus this works:
<B> :e `=$HOME . '/.vimrc'`</B>
This does not work, <A HREF="options.html#$HOME">$HOME</A> is inside a <A HREF="eval.html#string">string</A> and used literally:
<B> :e `='$HOME' . '/.vimrc'`</B>
If the <A HREF="eval.html#expression">expression</A> returns a <A HREF="eval.html#string">string</A> then names are to be separated with line
breaks. When the result is a |<A HREF="eval.html#List">List</A>| then each item is used <A HREF="motion.html#as">as</A> a name. Line
breaks also separate names.
Note that such expressions are only supported in places where a filename is
expected <A HREF="motion.html#as">as</A> an argument to an Ex-command.
*<A NAME="++opt"></A><B>++opt</B>* *<A NAME="[++opt]"></A><B>[++opt]</B>*
The <A HREF="#[++opt]">[++opt]</A> argument can be used to force the value of <A HREF="options.html#'fileformat'">'fileformat'</A>,
<A HREF="options.html#'fileencoding'">'fileencoding'</A> or <A HREF="options.html#'binary'">'binary'</A> to a value for one command, and to specify the
behavior for bad characters. The form is:
<B> ++{optname}</B>
Or:
<B> ++{optname}={value}</B>
Where {optname} is one of: *<A NAME="++ff"></A><B>++ff</B>* *<A NAME="++enc"></A><B>++enc</B>* *<A NAME="++bin"></A><B>++bin</B>* *<A NAME="++nobin"></A><B>++nobin</B>* *<A NAME="++edit"></A><B>++edit</B>*
ff or fileformat overrides <A HREF="options.html#'fileformat'">'fileformat'</A>
enc or encoding overrides <A HREF="options.html#'fileencoding'">'fileencoding'</A>
bin or binary sets <A HREF="options.html#'binary'">'binary'</A>
nobin or nobinary resets <A HREF="options.html#'binary'">'binary'</A>
bad specifies behavior for bad characters
edit for |<A HREF="insert.html#:read">:read</A>| only: keep option values <A HREF="motion.html#as">as</A> if editing
a file
{value} cannot contain white space. It can be any valid value for these
<A HREF="options.html#options">options</A>. Examples:
<B> :e ++ff=unix</B>
This edits the same file again with <A HREF="options.html#'fileformat'">'fileformat'</A> set to "<A HREF="os_unix.html#unix">unix</A>".
<B> :w ++enc=latin1 newfile</B>
This writes the current buffer to "newfile" in latin1 format.
There may be several <A HREF="#++opt">++opt</A> arguments, separated by white space. They must all
appear before any |<A HREF="#+cmd">+cmd</A>| argument.
*<A NAME="++bad"></A><B>++bad</B>*
The argument of "++bad=" specifies what happens with characters that can't be
converted and illegal bytes. It can be one of three things:
++bad=X A single-byte character that replaces each bad character.
++bad=keep Keep bad characters without conversion. Note that this may
result in illegal bytes in your text!
++bad=drop Remove the bad characters.
The default is like "++bad=?": <A HREF="insert.html#Replace">Replace</A> each bad character with a question
<A HREF="motion.html#mark">mark</A>. In some places an inverted question <A HREF="motion.html#mark">mark</A> is used (0xBF).
Note that not all commands use the <A HREF="#++bad">++bad</A> argument, even though they <A HREF="diff.html#do">do</A> not
give an error when you add it. E.g. |<A HREF="#:write">:write</A>|.
Note that when reading, the <A HREF="options.html#'fileformat'">'fileformat'</A> and <A HREF="options.html#'fileencoding'">'fileencoding'</A> <A HREF="options.html#options">options</A> will be
set to the used format. When <A HREF="#writing">writing</A> this doesn't happen, thus a next write
will use the old value of the option. Same for the <A HREF="options.html#'binary'">'binary'</A> option.
*<A NAME="+cmd"></A><B>+cmd</B>* *<A NAME="[+cmd]"></A><B>[+cmd]</B>*
The <A HREF="#[+cmd]">[+cmd]</A> argument can be used to position the cursor in the newly opened
file, or execute any other command:
+ Start at the last line.
+{num} Start at line {num}.
+/{pat} Start at first line containing <A HREF="autocmd.html#{pat}">{pat}</A>.
+{command} Execute {command} after opening the new file.
{command} is any <A HREF="intro.html#Ex">Ex</A> command.
To include a white space in the <A HREF="autocmd.html#{pat}">{pat}</A> or {command}, precede <A HREF="motion.html#it">it</A> with a
<A HREF="intro.html#backslash">backslash</A>. Double the number of backslashes.
<B> :edit +/The\ book file</B>
<B> :edit +/dir\ dirname\\ file</B>
<B> :edit +set\ dir=c:\\\\temp file</B>
Note that in the last example the number of backslashes is halved <A HREF="if_cscop.html#twice">twice</A>: Once
for the "<A HREF="#+cmd">+cmd</A>" argument and once for the "<A HREF="options.html#:set">:set</A>" command.
*<A NAME="file-formats"></A><B>file-formats</B>*
The <A HREF="options.html#'fileformat'">'fileformat'</A> option sets the <A HREF="intro.html#<EOL>"><EOL></A> style for a file:
<B><FONT COLOR="PURPLE">'fileformat' characters name </FONT></B>
"<A HREF="os_dos.html#dos">dos</A>" <CR><NL> or <A HREF="motion.html#<NL>"><NL></A> <A HREF="os_dos.html#DOS">DOS</A> format *<A NAME="DOS-format"></A><B>DOS-format</B>*
"<A HREF="os_unix.html#unix">unix</A>" <A HREF="motion.html#<NL>"><NL></A> <A HREF="os_unix.html#Unix">Unix</A> format *<A NAME="Unix-format"></A><B>Unix-format</B>*
"<A HREF="os_mac.html#mac">mac</A>" <A HREF="motion.html#<CR>"><CR></A> <A HREF="os_mac.html#Mac">Mac</A> format *<A NAME="Mac-format"></A><B>Mac-format</B>*
Previously <A HREF="options.html#'textmode'">'textmode'</A> was used. It is obsolete now.
When reading a file, the mentioned characters are interpreted <A HREF="motion.html#as">as</A> the <A HREF="intro.html#<EOL>"><EOL></A>.
In <A HREF="os_dos.html#DOS">DOS</A> format (default for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>, <A HREF="os_os2.html#OS/2">OS/2</A> and Win32), <CR><NL> and <A HREF="motion.html#<NL>"><NL></A> are both
interpreted <A HREF="motion.html#as">as</A> the <A HREF="intro.html#<EOL>"><EOL></A>. Note that when <A HREF="#writing">writing</A> the file in <A HREF="os_dos.html#DOS">DOS</A> format,
<A HREF="motion.html#<CR>"><CR></A> characters will be added for each single <A HREF="motion.html#<NL>"><NL></A>. Also see |<A HREF="insert.html#file-read">file-read</A>|.
When <A HREF="#writing">writing</A> a file, the mentioned characters are used for <A HREF="intro.html#<EOL>"><EOL></A>. For <A HREF="os_dos.html#DOS">DOS</A>
format <CR><NL> is used. Also see |<A HREF="#DOS-format-write">DOS-format-write</A>|.
You can read a file in <A HREF="os_dos.html#DOS">DOS</A> format and write <A HREF="motion.html#it">it</A> in <A HREF="os_unix.html#Unix">Unix</A> format. This will
replace all <CR><NL> pairs by <A HREF="motion.html#<NL>"><NL></A> (assuming <A HREF="options.html#'fileformats'">'fileformats'</A> includes "dos"):
<B> :e file</B>
<B> :set fileformat=unix</B>
<B> :w</B>
If you read a file in <A HREF="os_unix.html#Unix">Unix</A> format and write with <A HREF="os_dos.html#DOS">DOS</A> format, all <A HREF="motion.html#<NL>"><NL></A>
characters will be replaced with <CR><NL> (assuming <A HREF="options.html#'fileformats'">'fileformats'</A> includes
"unix"):
<B> :e file</B>
<B> :set fileformat=dos</B>
<B> :w</B>
If you start editing a new file and the <A HREF="options.html#'fileformats'">'fileformats'</A> option is not empty
(which is the default), Vim will try to detect whether the lines in the file
are separated by the specified formats. When set to "unix,dos", Vim will
check for lines with a single <A HREF="motion.html#<NL>"><NL></A> (as used on <A HREF="os_unix.html#Unix">Unix</A> and <A HREF="os_amiga.html#Amiga">Amiga</A>) or by a <A HREF="motion.html#<CR>"><CR></A>
<A HREF="motion.html#<NL>"><NL></A> pair (MS-DOS). Only when ALL lines end in <CR><NL>, <A HREF="options.html#'fileformat'">'fileformat'</A> is set
to "<A HREF="os_dos.html#dos">dos</A>", otherwise <A HREF="motion.html#it">it</A> is set to "<A HREF="os_unix.html#unix">unix</A>". When <A HREF="options.html#'fileformats'">'fileformats'</A> includes "<A HREF="os_mac.html#mac">mac</A>",
and no <A HREF="motion.html#<NL>"><NL></A> characters are found in the file, <A HREF="options.html#'fileformat'">'fileformat'</A> is set to "<A HREF="os_mac.html#mac">mac</A>".
If the <A HREF="options.html#'fileformat'">'fileformat'</A> option is set to "<A HREF="os_dos.html#dos">dos</A>" on non-MS-DOS systems the message
"[dos format]" is shown to remind you that something unusual is happening. On
<A HREF="os_msdos.html#MS-DOS">MS-DOS</A> systems you get the message "[unix format]" if <A HREF="options.html#'fileformat'">'fileformat'</A> is set to
"<A HREF="os_unix.html#unix">unix</A>". On all systems but the <A HREF="os_mac.html#Macintosh">Macintosh</A> you get the message "[mac format]"
if <A HREF="options.html#'fileformat'">'fileformat'</A> is set to "<A HREF="os_mac.html#mac">mac</A>".
If the <A HREF="options.html#'fileformats'">'fileformats'</A> option is empty and <A HREF="os_dos.html#DOS">DOS</A> format is used, but while reading
a file some lines did not end in <CR><NL>, "[CR missing]" will be included in
the file message.
If the <A HREF="options.html#'fileformats'">'fileformats'</A> option is empty and <A HREF="os_mac.html#Mac">Mac</A> format is used, but while reading
a file a <A HREF="motion.html#<NL>"><NL></A> was found, "[NL missing]" will be included in the file message.
If the new file does not exist, the <A HREF="options.html#'fileformat'">'fileformat'</A> of the current buffer is used
when <A HREF="options.html#'fileformats'">'fileformats'</A> is empty. Otherwise the first format from <A HREF="options.html#'fileformats'">'fileformats'</A> is
used for the new file.
Before editing binary, executable or Vim <A HREF="usr_41.html#script">script</A> files you should set the
<A HREF="options.html#'binary'">'binary'</A> option. A simple way to <A HREF="diff.html#do">do</A> this is by starting Vim with the "<A HREF="starting.html#-b">-b</A>"
option. This will avoid the use of <A HREF="options.html#'fileformat'">'fileformat'</A>. Without this you risk that
single <A HREF="motion.html#<NL>"><NL></A> characters are unexpectedly replaced with <CR><NL>.
You can encrypt files that are written by setting the <A HREF="options.html#'key'">'key'</A> option. This
provides some security against others reading your files. |<A HREF="#encryption">encryption</A>|
==============================================================================
3. The argument <A HREF="eval.html#list">list</A> *<A NAME="argument-list"></A><B>argument-list</B>* *<A NAME="arglist"></A><B>arglist</B>*
If you give more than one file name when starting Vim, this <A HREF="eval.html#list">list</A> is remembered
<A HREF="motion.html#as">as</A> the argument <A HREF="eval.html#list">list</A>. You can jump to each file in this <A HREF="eval.html#list">list</A>.
Do not confuse this with the buffer <A HREF="eval.html#list">list</A>, which you can see with the
|<A HREF="windows.html#:buffers">:buffers</A>| command. The argument <A HREF="eval.html#list">list</A> was already present in <A HREF="intro.html#Vi">Vi</A>, the buffer
<A HREF="eval.html#list">list</A> is new in Vim. Every file name in the argument <A HREF="eval.html#list">list</A> will also be present
in the buffer <A HREF="eval.html#list">list</A> (unless <A HREF="motion.html#it">it</A> was deleted with |<A HREF="windows.html#:bdel">:bdel</A>| or |<A HREF="windows.html#:bwipe">:bwipe</A>|). But it's
common that names in the buffer <A HREF="eval.html#list">list</A> are not in the argument <A HREF="eval.html#list">list</A>.
This subject is introduced in section |<A HREF="usr_07.html#07.2">07.2</A>| of the user manual.
There is one global argument <A HREF="eval.html#list">list</A>, which is used for all <A HREF="windows.html#windows">windows</A> by default.
It is possible to create a new argument <A HREF="eval.html#list">list</A> local to a <A HREF="windows.html#window">window</A>, see
|<A HREF="#:arglocal">:arglocal</A>|.
You can use the argument <A HREF="eval.html#list">list</A> with the following commands, and with the
<A HREF="eval.html#expression">expression</A> <A HREF="eval.html#functions">functions</A> |<A HREF="eval.html#argc()">argc()</A>| and |<A HREF="eval.html#argv()">argv()</A>|. These all work on the argument
<A HREF="eval.html#list">list</A> of the current <A HREF="windows.html#window">window</A>.
*<A NAME=":ar"></A><B>:ar</B>* *<A NAME=":args"></A><B>:args</B>*
:ar[gs] Print the argument <A HREF="eval.html#list">list</A>, with the current file in
square brackets.
:ar[gs] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{arglist}">{arglist}</A> *<A NAME=":args_f"></A><B>:args_f</B>*
Define <A HREF="#{arglist}">{arglist}</A> <A HREF="motion.html#as">as</A> the new argument <A HREF="eval.html#list">list</A> and edit
the first one. This fails when changes have been made
and Vim does not want to |<A HREF="#abandon">abandon</A>| the current buffer.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{Vi: no ++opt}
:ar[gs]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{arglist}">{arglist}</A> *<A NAME=":args_f!"></A><B>:args_f!</B>*
Define <A HREF="#{arglist}">{arglist}</A> <A HREF="motion.html#as">as</A> the new argument <A HREF="eval.html#list">list</A> and edit
the first one. Discard any changes to the current
buffer.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{Vi: no ++opt}
:[count]arge[dit][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> {name} .. *<A NAME=":arge"></A><B>:arge</B>* *<A NAME=":argedit"></A><B>:argedit</B>*
Add {name}s to the argument <A HREF="eval.html#list">list</A> and edit <A HREF="motion.html#it">it</A>.
When {name} already exists in the argument <A HREF="eval.html#list">list</A>, this
entry is edited.
This is like using |<A HREF="#:argadd">:argadd</A>| and then |<A HREF="#:edit">:edit</A>|.
Spaces in filenames have to be escaped with "\".
<A HREF="intro.html#[count]">[count]</A> is used like with |<A HREF="#:argadd">:argadd</A>|.
If the current file cannot be |abandon|ed {name}s will
still be added to the argument <A HREF="eval.html#list">list</A>, but won't be
edited. No check for duplicates is done.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{not in Vi}
:[count]arga[dd] {name} .. *<A NAME=":arga"></A><B>:arga</B>* *<A NAME=":argadd"></A><B>:argadd</B>* *<A NAME="E479"></A><B>E479</B>*
:[count]arga[dd]
Add the {name}s to the argument <A HREF="eval.html#list">list</A>. When {name} is
omitted add the current buffer name to the argument
<A HREF="eval.html#list">list</A>.
If <A HREF="intro.html#[count]">[count]</A> is omitted, the {name}s are added just
after the current entry in the argument <A HREF="eval.html#list">list</A>.
Otherwise they are added after the [count]'th file.
If the argument <A HREF="eval.html#list">list</A> is "a <A HREF="motion.html#b">b</A> c", and "<A HREF="motion.html#b">b</A>" is the
current argument, then these commands result in:
<B><FONT COLOR="PURPLE"> command new argument list </FONT></B>
<A HREF="#:argadd">:argadd</A> <A HREF="change.html#x">x</A> a <A HREF="motion.html#b">b</A> <A HREF="change.html#x">x</A> <A HREF="change.html#c">c</A>
:0argadd <A HREF="change.html#x">x</A> <A HREF="change.html#x">x</A> a <A HREF="motion.html#b">b</A> <A HREF="change.html#c">c</A>
:1argadd <A HREF="change.html#x">x</A> a <A HREF="change.html#x">x</A> <A HREF="motion.html#b">b</A> <A HREF="change.html#c">c</A>
:$argadd <A HREF="change.html#x">x</A> a <A HREF="motion.html#b">b</A> <A HREF="change.html#c">c</A> <A HREF="change.html#x">x</A>
And after the last one:
:+2argadd <A HREF="change.html#y">y</A> a <A HREF="motion.html#b">b</A> <A HREF="change.html#c">c</A> <A HREF="change.html#x">x</A> <A HREF="change.html#y">y</A>
There is no check for duplicates, <A HREF="motion.html#it">it</A> is possible to
add a file to the argument <A HREF="eval.html#list">list</A> <A HREF="if_cscop.html#twice">twice</A>.
The currently edited file is not changed.
{not in Vi} {not available when compiled without the
|<A HREF="various.html#+listcmds">+listcmds</A>| feature}
Note: you can also use this method:
<B> :args ## x</B>
This will add the "<A HREF="change.html#x">x</A>" item and sort the new <A HREF="eval.html#list">list</A>.
:argd[elete] {pattern} .. *<A NAME=":argd"></A><B>:argd</B>* *<A NAME=":argdelete"></A><B>:argdelete</B>* *<A NAME="E480"></A><B>E480</B>*
Delete files from the argument <A HREF="eval.html#list">list</A> that match the
{pattern}s. {pattern} is used like a file <A HREF="pattern.html#pattern">pattern</A>,
see |<A HREF="autocmd.html#file-pattern">file-pattern</A>|. "<A HREF="motion.html#%">%</A>" can be used to delete the
current entry.
This command keeps the currently edited file, also
when it's deleted from the argument <A HREF="eval.html#list">list</A>.
Example:
<B> :argdel *.obj</B>
{not in Vi} {not available when compiled without the
|<A HREF="various.html#+listcmds">+listcmds</A>| feature}
:[range]argd[elete] Delete the {range} files from the argument <A HREF="eval.html#list">list</A>.
Example:
<B> :10,$argdel</B>
Deletes arguments 10 and further, keeping 1-9.
<B> :$argd</B>
Deletes just the last one.
<B> :argd</B>
<B> :.argd</B>
Deletes the current argument.
<B> :%argd</B>
Removes all the files from the <A HREF="#arglist">arglist</A>.
When the last number in the range is too high, up to
the last argument is deleted.
{not in Vi} {not available when compiled without the
|<A HREF="various.html#+listcmds">+listcmds</A>| feature}
*<A NAME=":argu"></A><B>:argu</B>* *<A NAME=":argument"></A><B>:argument</B>*
:[count]argu[ment] <A HREF="intro.html#[count]">[count]</A> <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Edit file <A HREF="intro.html#[count]">[count]</A> in the argument <A HREF="eval.html#list">list</A>. When <A HREF="intro.html#[count]">[count]</A>
is omitted the current entry is used. This fails
when changes have been made and Vim does not want to
|<A HREF="#abandon">abandon</A>| the current buffer.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{not in Vi} {not available when compiled without the
|<A HREF="various.html#+listcmds">+listcmds</A>| feature}
:[count]argu[ment]! <A HREF="intro.html#[count]">[count]</A> <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Edit file <A HREF="intro.html#[count]">[count]</A> in the argument <A HREF="eval.html#list">list</A>, <A HREF="#discard">discard</A> any
changes to the current buffer. When <A HREF="intro.html#[count]">[count]</A> is
omitted the current entry is used.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|.
{not in Vi} {not available when compiled without the
|<A HREF="various.html#+listcmds">+listcmds</A>| feature}
:[count]n[ext] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> *<A NAME=":n"></A><B>:n</B>* *<A NAME=":ne"></A><B>:ne</B>* *<A NAME=":next"></A><B>:next</B>* *<A NAME="E165"></A><B>E165</B>* *<A NAME="E163"></A><B>E163</B>*
Edit <A HREF="intro.html#[count]">[count]</A> next file. This fails when changes have
been made and Vim does not want to |<A HREF="#abandon">abandon</A>| the
current buffer. Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {Vi: no
<A HREF="intro.html#count">count</A> or ++opt}.
:[count]n[ext]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Edit <A HREF="intro.html#[count]">[count]</A> next file, <A HREF="#discard">discard</A> any changes to the
buffer. Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {Vi: no <A HREF="intro.html#count">count</A>
or ++opt}.
:n[ext] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{arglist}">{arglist}</A> *<A NAME=":next_f"></A><B>:next_f</B>*
Same <A HREF="motion.html#as">as</A> |<A HREF="#:args_f">:args_f</A>|.
:n[ext]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{arglist}">{arglist}</A>
Same <A HREF="motion.html#as">as</A> |<A HREF="#:args_f!">:args_f!</A>|.
:[count]N[ext] <A HREF="intro.html#[count]">[count]</A> <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> *<A NAME=":Next"></A><B>:Next</B>* *<A NAME=":N"></A><B>:N</B>* *<A NAME="E164"></A><B>E164</B>*
Edit <A HREF="intro.html#[count]">[count]</A> previous file in argument <A HREF="eval.html#list">list</A>. This
fails when changes have been made and Vim does not
want to |<A HREF="#abandon">abandon</A>| the current buffer.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {Vi: no <A HREF="intro.html#count">count</A> or ++opt}.
:[count]N[ext]! <A HREF="intro.html#[count]">[count]</A> <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Edit <A HREF="intro.html#[count]">[count]</A> previous file in argument <A HREF="eval.html#list">list</A>. Discard
any changes to the buffer. Also see |<A HREF="#++opt">++opt</A>| and
|<A HREF="#+cmd">+cmd</A>|. {Vi: no <A HREF="intro.html#count">count</A> or ++opt}.
:[count]prev[ious] <A HREF="intro.html#[count]">[count]</A> <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> *<A NAME=":prev"></A><B>:prev</B>* *<A NAME=":previous"></A><B>:previous</B>*
Same <A HREF="motion.html#as">as</A> <A HREF="#:Next">:Next</A>. Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {Vi:
only in some versions}
*<A NAME=":rew"></A><B>:rew</B>* *<A NAME=":rewind"></A><B>:rewind</B>*
:rew[ind] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Start editing the first file in the argument <A HREF="eval.html#list">list</A>.
This fails when changes have been made and Vim does
not want to |<A HREF="#abandon">abandon</A>| the current buffer.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {Vi: no ++opt}
:rew[ind]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Start editing the first file in the argument <A HREF="eval.html#list">list</A>.
Discard any changes to the buffer. Also see |<A HREF="#++opt">++opt</A>|
and |<A HREF="#+cmd">+cmd</A>|. {Vi: no ++opt}
*<A NAME=":fir"></A><B>:fir</B>* *<A NAME=":first"></A><B>:first</B>*
:fir[st][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Other name for "<A HREF="#:rewind">:rewind</A>". {not in Vi}
*<A NAME=":la"></A><B>:la</B>* *<A NAME=":last"></A><B>:last</B>*
:la[st] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Start editing the last file in the argument <A HREF="eval.html#list">list</A>.
This fails when changes have been made and Vim does
not want to |<A HREF="#abandon">abandon</A>| the current buffer.
Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {not in Vi}
:la[st]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A>
Start editing the last file in the argument <A HREF="eval.html#list">list</A>.
Discard any changes to the buffer. Also see |<A HREF="#++opt">++opt</A>|
and |<A HREF="#+cmd">+cmd</A>|. {not in Vi}
*<A NAME=":wn"></A><B>:wn</B>* *<A NAME=":wnext"></A><B>:wnext</B>*
:[count]wn[ext] <A HREF="#[++opt]">[++opt]</A>
Write current file and start editing the <A HREF="intro.html#[count]">[count]</A>
next file. Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {not in Vi}
:[count]wn[ext] <A HREF="#[++opt]">[++opt]</A> <A HREF="#{file}">{file}</A>
Write current file to <A HREF="#{file}">{file}</A> and start editing the
<A HREF="intro.html#[count]">[count]</A> next file, unless <A HREF="#{file}">{file}</A> already exists and
the <A HREF="options.html#'writeany'">'writeany'</A> option is off. Also see |<A HREF="#++opt">++opt</A>| and
|<A HREF="#+cmd">+cmd</A>|. {not in Vi}
:[count]wn[ext]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#{file}">{file}</A>
Write current file to <A HREF="#{file}">{file}</A> and start editing the
<A HREF="intro.html#[count]">[count]</A> next file. Also see |<A HREF="#++opt">++opt</A>| and |<A HREF="#+cmd">+cmd</A>|. {not
in Vi}
:[count]wN[ext][!] <A HREF="#[++opt]">[++opt]</A> [file] *<A NAME=":wN"></A><B>:wN</B>* *<A NAME=":wNext"></A><B>:wNext</B>*
:[count]wp[revious][!] <A HREF="#[++opt]">[++opt]</A> [file] *<A NAME=":wp"></A><B>:wp</B>* *<A NAME=":wprevious"></A><B>:wprevious</B>*
Same <A HREF="motion.html#as">as</A> <A HREF="#:wnext">:wnext</A>, but go to previous file instead of
next. {not in Vi}
The <A HREF="intro.html#[count]">[count]</A> in the commands above defaults to one. For some commands <A HREF="motion.html#it">it</A> is
possible to use two counts. The last one (rightmost one) is used.
If no <A HREF="#[+cmd]">[+cmd]</A> argument is present, the cursor is positioned at the last known
cursor position for the file. If <A HREF="options.html#'startofline'">'startofline'</A> is set, the cursor will be
positioned at the first non-blank in the line, otherwise the last know column
is used. If there is no last known cursor position the cursor will be in the
first line (the last line in <A HREF="intro.html#Ex">Ex</A> mode).
*<A NAME="{arglist}"></A><B>{arglist}</B>*
The <A HREF="#wildcards">wildcards</A> in the argument <A HREF="eval.html#list">list</A> are expanded and the file names are sorted.
Thus you can use the command "vim *.c" to edit all the C files. From within
Vim the command "<A HREF="#:n">:n</A> *.c" does the same.
White space is used to separate file names. Put a <A HREF="intro.html#backslash">backslash</A> before a space or
<A HREF="intro.html#tab">tab</A> to include <A HREF="motion.html#it">it</A> in a file name. E.g., to edit the single file "foo bar":
<B> :next foo\ bar</B>
On <A HREF="os_unix.html#Unix">Unix</A> and a few other systems you can also use backticks, for example:
<B> :next `find . -name \\*.c -print`</B>
The backslashes before the <A HREF="pattern.html#star">star</A> are required to prevent "*.c" to be expanded
by the shell before executing the find program.
*<A NAME="arglist-position"></A><B>arglist-position</B>*
When there is an argument <A HREF="eval.html#list">list</A> you can see which file you are editing in the
title of the <A HREF="windows.html#window">window</A> (if there is one and <A HREF="options.html#'title'">'title'</A> is on) and with the file
message you get with the "<A HREF="#CTRL-G">CTRL-G</A>" command. You will see something like
(file 4 of 11)
If <A HREF="options.html#'shortmess'">'shortmess'</A> contains '<A HREF="motion.html#f">f</A>' <A HREF="motion.html#it">it</A> will be
(4 of 11)
If you are not really editing the file at the current position in the argument
<A HREF="eval.html#list">list</A> <A HREF="motion.html#it">it</A> will be
(file (4) of 11)
This means that you are position 4 in the argument <A HREF="eval.html#list">list</A>, but not editing the
fourth file in the argument <A HREF="eval.html#list">list</A>. This happens when you <A HREF="diff.html#do">do</A> "<A HREF="#:e">:e</A> file".
LOCAL ARGUMENT LIST
{not in Vi}
{not available when compiled without the |<A HREF="various.html#+windows">+windows</A>| or |<A HREF="various.html#+listcmds">+listcmds</A>| features}
*<A NAME=":arglocal"></A><B>:arglocal</B>*
:argl[ocal] Make a local copy of the global argument <A HREF="eval.html#list">list</A>.
Doesn't start editing another file.
:argl[ocal][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{arglist}">{arglist}</A>
Define a new argument <A HREF="eval.html#list">list</A>, which is local to the
current <A HREF="windows.html#window">window</A>. Works like |<A HREF="#:args_f">:args_f</A>| otherwise.
*<A NAME=":argglobal"></A><B>:argglobal</B>*
:argg[lobal] Use the global argument <A HREF="eval.html#list">list</A> for the current <A HREF="windows.html#window">window</A>.
Doesn't start editing another file.
:argg[lobal][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#[+cmd]">[+cmd]</A> <A HREF="#{arglist}">{arglist}</A>
Use the global argument <A HREF="eval.html#list">list</A> for the current <A HREF="windows.html#window">window</A>.
Define a new global argument <A HREF="eval.html#list">list</A> like |<A HREF="#:args_f">:args_f</A>|.
All <A HREF="windows.html#windows">windows</A> using the global argument <A HREF="eval.html#list">list</A> will see
this new <A HREF="eval.html#list">list</A>.
There can be several argument lists. They can be shared between <A HREF="windows.html#windows">windows</A>.
When they are shared, <A HREF="change.html#changing">changing</A> the argument <A HREF="eval.html#list">list</A> in one <A HREF="windows.html#window">window</A> will also
change <A HREF="motion.html#it">it</A> in the other <A HREF="windows.html#window">window</A>.
When a <A HREF="windows.html#window">window</A> is split the new <A HREF="windows.html#window">window</A> inherits the argument <A HREF="eval.html#list">list</A> from the
current <A HREF="windows.html#window">window</A>. The two <A HREF="windows.html#windows">windows</A> then share this <A HREF="eval.html#list">list</A>, until one of them uses
|<A HREF="#:arglocal">:arglocal</A>| or |<A HREF="#:argglobal">:argglobal</A>| to use another argument <A HREF="eval.html#list">list</A>.
USING THE ARGUMENT LIST
*<A NAME=":argdo"></A><B>:argdo</B>*
:[range]argdo[!] {cmd} Execute {cmd} for each file in the argument <A HREF="eval.html#list">list</A> or
if <A HREF="cmdline.html#[range]">[range]</A> is specified only for arguments in that
range. It works like doing this:
<B> :rewind</B>
<B> :{cmd}</B>
<B> :next</B>
<B> :{cmd}</B>
<B> etc.</B>
When the current file can't be |abandon|ed and the [!]
is not present, the command fails.
When an error is detected on one file, further files
in the argument <A HREF="eval.html#list">list</A> will not be visited.
The last file in the argument <A HREF="eval.html#list">list</A> (or where an error
occurred) becomes the current file.
{cmd} can contain '|' to concatenate several commands.
{cmd} must not change the argument <A HREF="eval.html#list">list</A>.
Note: While this command is executing, the <A HREF="autocmd.html#Syntax">Syntax</A>
<A HREF="autocmd.html#autocommand">autocommand</A> event is disabled by adding <A HREF="motion.html#it">it</A> to
<A HREF="options.html#'eventignore'">'eventignore'</A>. This considerably speeds up editing
each file.
{not in Vi} {not available when compiled without the
|<A HREF="various.html#+listcmds">+listcmds</A>| feature}
Also see |<A HREF="windows.html#:windo">:windo</A>|, |<A HREF="tabpage.html#:tabdo">:tabdo</A>|, |<A HREF="windows.html#:bufdo">:bufdo</A>|, |<A HREF="quickfix.html#:cdo">:cdo</A>|, |<A HREF="quickfix.html#:ldo">:ldo</A>|,
|<A HREF="quickfix.html#:cfdo">:cfdo</A>| and |<A HREF="quickfix.html#:lfdo">:lfdo</A>|
Example:
<B> :args *.c</B>
<B> :argdo set ff=unix | update</B>
This sets the <A HREF="options.html#'fileformat'">'fileformat'</A> option to "<A HREF="os_unix.html#unix">unix</A>" and writes the file if <A HREF="motion.html#it">it</A> is now
changed. This is done for all *.c files.
Example:
<B> :args *.[ch]</B>
<B> :argdo %s/\<my_foo\>/My_Foo/ge | update</B>
This changes the <A HREF="motion.html#word">word</A> "my_foo" to "My_Foo" in all *.c and *.h files. The "<A HREF="motion.html#e">e</A>"
flag is used for the "<A HREF="change.html#:substitute">:substitute</A>" command to avoid an error for files where
"my_foo" isn't used. "<A HREF="#:update">:update</A>" writes the file only if changes were made.
==============================================================================
4. Writing *<A NAME="writing"></A><B>writing</B>* *<A NAME="save-file"></A><B>save-file</B>*
Note: When the <A HREF="options.html#'write'">'write'</A> option is off, you are not able to write any file.
*<A NAME=":w"></A><B>:w</B>* *<A NAME=":write"></A><B>:write</B>*
*<A NAME="E502"></A><B>E502</B>* *<A NAME="E503"></A><B>E503</B>* *<A NAME="E504"></A><B>E504</B>* *<A NAME="E505"></A><B>E505</B>*
*<A NAME="E512"></A><B>E512</B>* *<A NAME="E514"></A><B>E514</B>* *<A NAME="E667"></A><B>E667</B>* *<A NAME="E796"></A><B>E796</B>* *<A NAME="E949"></A><B>E949</B>*
:w[rite] <A HREF="#[++opt]">[++opt]</A> Write the whole buffer to the current file. This is
the normal way to save changes to a file. It fails
when the <A HREF="options.html#'readonly'">'readonly'</A> option is set or when there is
another reason why the file can't be written.
For ++opt see |<A HREF="#++opt">++opt</A>|, but only <A HREF="#++bin">++bin</A>, <A HREF="#++nobin">++nobin</A>, <A HREF="#++ff">++ff</A>
and <A HREF="#++enc">++enc</A> are effective.
:w[rite]! <A HREF="#[++opt]">[++opt]</A> Like "<A HREF="#:write">:write</A>", but forcefully write when <A HREF="options.html#'readonly'">'readonly'</A> is
set or there is another reason why <A HREF="#writing">writing</A> was
refused.
Note: This may change the permission and ownership of
the file and break (symbolic) links. Add the '<A HREF="motion.html#W">W</A>' flag
to <A HREF="options.html#'cpoptions'">'cpoptions'</A> to avoid this.
:[range]w[rite][!] <A HREF="#[++opt]">[++opt]</A>
Write the specified lines to the current file. This
is unusual, because the file will not contain all
lines in the buffer.
*<A NAME=":w_f"></A><B>:w_f</B>* *<A NAME=":write_f"></A><B>:write_f</B>*
:[range]w[rite] <A HREF="#[++opt]">[++opt]</A> <A HREF="#{file}">{file}</A>
Write the specified lines to <A HREF="#{file}">{file}</A>, unless <A HREF="motion.html#it">it</A>
already exists and the <A HREF="options.html#'writeany'">'writeany'</A> option is off.
*<A NAME=":w!"></A><B>:w!</B>*
:[range]w[rite]! <A HREF="#[++opt]">[++opt]</A> <A HREF="#{file}">{file}</A>
Write the specified lines to <A HREF="#{file}">{file}</A>. Overwrite an
existing file.
*<A NAME=":w_a"></A><B>:w_a</B>* *<A NAME=":write_a"></A><B>:write_a</B>* *<A NAME="E494"></A><B>E494</B>*
:[range]w[rite][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="change.html#>>">>></A>
Append the specified lines to the current file.
:[range]w[rite][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="change.html#>>">>></A> <A HREF="#{file}">{file}</A>
Append the specified lines to <A HREF="#{file}">{file}</A>. '<A HREF="change.html#!">!</A>' forces the
write even if file does not exist.
*<A NAME=":w_c"></A><B>:w_c</B>* *<A NAME=":write_c"></A><B>:write_c</B>*
:[range]w[rite] <A HREF="#[++opt]">[++opt]</A> !{cmd}
Execute {cmd} with <A HREF="cmdline.html#[range]">[range]</A> lines <A HREF="motion.html#as">as</A> standard input
(note the space in front of the '!'). {cmd} is
executed like with ":!{cmd}", any '<A HREF="change.html#!">!</A>' is replaced with
the previous command |<A HREF="various.html#:!">:!</A>|.
The default <A HREF="cmdline.html#[range]">[range]</A> for the "<A HREF="#:w">:w</A>" command is the whole buffer (1,$). If you
write the whole buffer, <A HREF="motion.html#it">it</A> is no longer considered changed. When you
write <A HREF="motion.html#it">it</A> to a different file with "<A HREF="#:w">:w</A> somefile" <A HREF="motion.html#it">it</A> depends on the "<A HREF="motion.html#+">+</A>" flag in
<A HREF="options.html#'cpoptions'">'cpoptions'</A>. When included, the write command will reset the <A HREF="options.html#'modified'">'modified'</A> flag,
even though the buffer itself may still be different from its file.
If a file name is given with "<A HREF="#:w">:w</A>" <A HREF="motion.html#it">it</A> becomes the alternate file. This can be
used, for example, when the write fails and you want to try again later with
"<A HREF="#:w">:w</A> #". This can be switched off by removing the '<A HREF="insert.html#A">A</A>' flag from the
<A HREF="options.html#'cpoptions'">'cpoptions'</A> option.
Note that the <A HREF="options.html#'fsync'">'fsync'</A> option matters here. If it's set <A HREF="motion.html#it">it</A> may make writes
slower (but safer).
*<A NAME=":sav"></A><B>:sav</B>* *<A NAME=":saveas"></A><B>:saveas</B>*
:sav[eas][!] <A HREF="#[++opt]">[++opt]</A> <A HREF="#{file}">{file}</A>
Save the current buffer under the name <A HREF="#{file}">{file}</A> and set
the filename of the current buffer to <A HREF="#{file}">{file}</A>. The
previous name is used for the alternate file name.
The [!] is needed to overwrite an existing file.
When <A HREF="options.html#'filetype'">'filetype'</A> is empty <A HREF="filetype.html#filetype">filetype</A> detection is done
with the new name, before the file is written.
When the write was successful <A HREF="options.html#'readonly'">'readonly'</A> is reset.
{not in Vi}
*<A NAME=":up"></A><B>:up</B>* *<A NAME=":update"></A><B>:update</B>*
:[range]up[date][!] <A HREF="#[++opt]">[++opt]</A> [>>] [file]
Like "<A HREF="#:write">:write</A>", but only write when the buffer has been
modified. {not in Vi}
WRITING WITH MULTIPLE BUFFERS *<A NAME="buffer-write"></A><B>buffer-write</B>*
*<A NAME=":wa"></A><B>:wa</B>* *<A NAME=":wall"></A><B>:wall</B>*
:wa[ll] Write all changed <A HREF="windows.html#buffers">buffers</A>. Buffers without a file
name cause an error message. Buffers which are
readonly are not written. {not in Vi}
:wa[ll]! Write all changed <A HREF="windows.html#buffers">buffers</A>, even the ones that are
readonly. Buffers without a file name are not
written and cause an error message. {not in Vi}
Vim will warn you if you try to overwrite a file that has been changed
elsewhere. See |<A HREF="#timestamp">timestamp</A>|.
*<A NAME="backup"></A><B>backup</B>* *<A NAME="E207"></A><B>E207</B>* *<A NAME="E506"></A><B>E506</B>* *<A NAME="E507"></A><B>E507</B>* *<A NAME="E508"></A><B>E508</B>* *<A NAME="E509"></A><B>E509</B>* *<A NAME="E510"></A><B>E510</B>*
If you write to an existing file (but <A HREF="diff.html#do">do</A> not append) while the <A HREF="options.html#'backup'">'backup'</A>,
<A HREF="options.html#'writebackup'">'writebackup'</A> or <A HREF="options.html#'patchmode'">'patchmode'</A> option is on, a <A HREF="#backup">backup</A> of the original file is
made. The file is either copied or renamed (see <A HREF="options.html#'backupcopy'">'backupcopy'</A>). After the
file has been successfully written and when the <A HREF="options.html#'writebackup'">'writebackup'</A> option is on and
the <A HREF="options.html#'backup'">'backup'</A> option is off, the <A HREF="#backup">backup</A> file is deleted. When the <A HREF="options.html#'patchmode'">'patchmode'</A>
option is on the <A HREF="#backup">backup</A> file may be renamed.
*<A NAME="backup-table"></A><B>backup-table</B>*
<B><FONT COLOR="PURPLE">'backup' 'writebackup' action </FONT></B>
off off no <A HREF="#backup">backup</A> made
off on <A HREF="#backup">backup</A> current file, deleted afterwards (default)
on off delete old <A HREF="#backup">backup</A>, <A HREF="#backup">backup</A> current file
on on delete old <A HREF="#backup">backup</A>, <A HREF="#backup">backup</A> current file
When the <A HREF="options.html#'backupskip'">'backupskip'</A> <A HREF="pattern.html#pattern">pattern</A> matches with the name of the file which is
written, no <A HREF="#backup">backup</A> file is made. The values of <A HREF="options.html#'backup'">'backup'</A> and <A HREF="options.html#'writebackup'">'writebackup'</A> are
ignored then.
When the <A HREF="options.html#'backup'">'backup'</A> option is on, an old <A HREF="#backup">backup</A> file (with the same name <A HREF="motion.html#as">as</A> the
new <A HREF="#backup">backup</A> file) will be deleted. If <A HREF="options.html#'backup'">'backup'</A> is not set, but <A HREF="options.html#'writebackup'">'writebackup'</A>
is set, an existing <A HREF="#backup">backup</A> file will not be deleted. The <A HREF="#backup">backup</A> file that is
made while the file is being written will have a different name.
On some filesystems it's possible that in a crash you lose both the <A HREF="#backup">backup</A> and
the newly written file (it might be there but contain bogus data). In that
<A HREF="change.html#case">case</A> try <A HREF="recover.html#recovery">recovery</A>, because the swap file is synced to disk and might still be
there. |<A HREF="recover.html#:recover">:recover</A>|
The directories given with the <A HREF="options.html#'backupdir'">'backupdir'</A> option are used to put the <A HREF="#backup">backup</A>
file in. (default: same directory <A HREF="motion.html#as">as</A> the written file).
Whether the <A HREF="#backup">backup</A> is a new file, which is a copy of the original file, or the
original file renamed depends on the <A HREF="options.html#'backupcopy'">'backupcopy'</A> option. See there for an
explanation of when the copy is made and when the file is renamed.
If the creation of a <A HREF="#backup">backup</A> file fails, the write is not done. If you want
to write anyway add a '<A HREF="change.html#!">!</A>' to the command.
*<A NAME="write-permissions"></A><B>write-permissions</B>*
When <A HREF="#writing">writing</A> a new file the permissions are read-write. For <A HREF="os_unix.html#unix">unix</A> the mask is
0666 with additionally umask applied. When <A HREF="#writing">writing</A> a file that was read Vim
will preserve the permissions, but clear the s-bit.
*<A NAME="write-readonly"></A><B>write-readonly</B>*
When the <A HREF="options.html#'cpoptions'">'cpoptions'</A> option contains '<A HREF="motion.html#W">W</A>', Vim will refuse to overwrite a
readonly file. When '<A HREF="motion.html#W">W</A>' is not present, "<A HREF="#:w!">:w!</A>" will overwrite a readonly file,
if the system allows <A HREF="motion.html#it">it</A> (the directory must be writable).
*<A NAME="write-fail"></A><B>write-fail</B>*
If the <A HREF="#writing">writing</A> of the new file fails, you have to be careful not to lose
your changes AND the original file. If there is no <A HREF="#backup">backup</A> file and <A HREF="#writing">writing</A>
the new file failed, you have already lost the original file! DON'T EXIT VIM
UNTIL YOU WRITE OUT THE FILE! If a <A HREF="#backup">backup</A> was made, <A HREF="motion.html#it">it</A> is put back in place
of the original file (if possible). If you exit Vim, and lose the changes
you made, the original file will mostly still be there. If putting back the
original file fails, there will be an error message telling you that you
lost the original file.
*<A NAME="DOS-format-write"></A><B>DOS-format-write</B>*
If the <A HREF="options.html#'fileformat'">'fileformat'</A> is "<A HREF="os_dos.html#dos">dos</A>", <A HREF="motion.html#<CR>"><CR></A> <A HREF="motion.html#<NL>"><NL></A> is used for <A HREF="intro.html#<EOL>"><EOL></A>. This is default
for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>, <A HREF="os_win32.html#Win32">Win32</A> and <A HREF="os_os2.html#OS/2">OS/2</A>. On other systems the message "[dos format]" is
shown to remind you that an unusual <A HREF="intro.html#<EOL>"><EOL></A> was used.
*<A NAME="Unix-format-write"></A><B>Unix-format-write</B>*
If the <A HREF="options.html#'fileformat'">'fileformat'</A> is "<A HREF="os_unix.html#unix">unix</A>", <A HREF="motion.html#<NL>"><NL></A> is used for <A HREF="intro.html#<EOL>"><EOL></A>. On <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>, <A HREF="os_win32.html#Win32">Win32</A> and
<A HREF="os_os2.html#OS/2">OS/2</A> the message "[unix format]" is shown.
*<A NAME="Mac-format-write"></A><B>Mac-format-write</B>*
If the <A HREF="options.html#'fileformat'">'fileformat'</A> is "<A HREF="os_mac.html#mac">mac</A>", <A HREF="motion.html#<CR>"><CR></A> is used for <A HREF="intro.html#<EOL>"><EOL></A>. On non-Mac systems the
message "[mac format]" is shown.
See also |<A HREF="#file-formats">file-formats</A>| and the <A HREF="options.html#'fileformat'">'fileformat'</A> and <A HREF="options.html#'fileformats'">'fileformats'</A> <A HREF="options.html#options">options</A>.
*<A NAME="ACL"></A><B>ACL</B>*
<A HREF="#ACL">ACL</A> stands for Access Control <A HREF="eval.html#List">List</A>. It is an advanced way to <A HREF="intro.html#control">control</A> access
rights for a file. It is used on new <A HREF="os_win32.html#MS-Windows">MS-Windows</A> and <A HREF="os_unix.html#Unix">Unix</A> systems, but only
when the filesystem supports <A HREF="motion.html#it">it</A>.
Vim attempts to preserve the <A HREF="#ACL">ACL</A> info when <A HREF="#writing">writing</A> a file. The <A HREF="#backup">backup</A> file
will get the <A HREF="#ACL">ACL</A> info of the original file.
The <A HREF="#ACL">ACL</A> info is also used to check if a file is read-only (when opening the
file).
*<A NAME="read-only-share"></A><B>read-only-share</B>*
When <A HREF="os_win32.html#MS-Windows">MS-Windows</A> shares a drive on the <A HREF="pi_netrw.html#network">network</A> <A HREF="motion.html#it">it</A> can be marked <A HREF="motion.html#as">as</A> read-only.
This means that even if the file read-only attribute is absent, and the <A HREF="#ACL">ACL</A>
settings on NT <A HREF="pi_netrw.html#network">network</A> shared drives allow <A HREF="#writing">writing</A> to the file, you can still
not write to the file. Vim on <A HREF="os_win32.html#Win32">Win32</A> platforms will detect read-only <A HREF="pi_netrw.html#network">network</A>
drives and will <A HREF="motion.html#mark">mark</A> the file <A HREF="motion.html#as">as</A> read-only. You will not be able to override
it with |<A HREF="#:write">:write</A>|.
*<A NAME="write-device"></A><B>write-device</B>*
When the file name is actually a device name, Vim will not make a <A HREF="#backup">backup</A> (that
would be impossible). You need to use "<A HREF="change.html#!">!</A>", since the device already exists.
Example for <A HREF="os_unix.html#Unix">Unix</A>:
<B> :w! /dev/lpt0</B>
and for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> or <A HREF="os_win32.html#MS-Windows">MS-Windows</A>:
<B> :w! lpt0</B>
For <A HREF="os_unix.html#Unix">Unix</A> a device is detected when the name doesn't refer to a normal file or
a directory. A fifo or named pipe also looks like a device to Vim.
For <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> and <A HREF="os_win32.html#MS-Windows">MS-Windows</A> the device is detected by its name:
AUX
CON
CLOCK$
NUL
PRN
COMn n=1,2,3... etc
LPTn n=1,2,3... etc
The names can be in upper- or <A HREF="change.html#lowercase">lowercase</A>.
==============================================================================
5. Writing and quitting *<A NAME="write-quit"></A><B>write-quit</B>*
*<A NAME=":q"></A><B>:q</B>* *<A NAME=":quit"></A><B>:quit</B>*
:q[uit] Quit the current <A HREF="windows.html#window">window</A>. Quit Vim if this is the last
<A HREF="windows.html#window">window</A>. This fails when changes have been made and
Vim refuses to |<A HREF="#abandon">abandon</A>| the current buffer, and when
the last file in the argument <A HREF="eval.html#list">list</A> has not been
edited.
If there are other <A HREF="intro.html#tab">tab</A> pages and quitting the last
<A HREF="windows.html#window">window</A> in the current <A HREF="intro.html#tab">tab</A> page the current <A HREF="intro.html#tab">tab</A> page is
closed |<A HREF="tabpage.html#tab-page">tab-page</A>|.
Triggers the |<A HREF="autocmd.html#QuitPre">QuitPre</A>| <A HREF="autocmd.html#autocommand">autocommand</A> event.
See |<A HREF="windows.html#CTRL-W_q">CTRL-W_q</A>| for quitting another <A HREF="windows.html#window">window</A>.
:conf[irm] q[uit] Quit, but give prompt when changes have been made, or
the last file in the argument <A HREF="eval.html#list">list</A> has not been
edited. See |<A HREF="#:confirm">:confirm</A>| and <A HREF="options.html#'confirm'">'confirm'</A>. {not in Vi}
:q[uit]! Quit without <A HREF="#writing">writing</A>, also when the current buffer has
changes. The buffer is unloaded, also when <A HREF="motion.html#it">it</A> has
<A HREF="options.html#'hidden'">'hidden'</A> set.
If this is the last <A HREF="windows.html#window">window</A> and there is a modified
hidden buffer, the current buffer is abandoned and the
first changed hidden buffer becomes the current
buffer.
Use ":qall!" to exit always.
:cq[uit] Quit always, without <A HREF="#writing">writing</A>, and return an error
code. See |<A HREF="quickfix.html#:cq">:cq</A>|. Used for Manx's QuickFix mode (see
|<A HREF="quickfix.html#quickfix">quickfix</A>|). {not in Vi}
*<A NAME=":wq"></A><B>:wq</B>*
<A HREF="#:wq">:wq</A> <A HREF="#[++opt]">[++opt]</A> Write the current file and quit. Writing fails when
the file is read-only or the buffer does not have a
name. Quitting fails when the last file in the
argument <A HREF="eval.html#list">list</A> has not been edited.
<A HREF="#:wq">:wq</A>! <A HREF="#[++opt]">[++opt]</A> Write the current file and quit. Writing fails when
the current buffer does not have a name.
<A HREF="#:wq">:wq</A> <A HREF="#[++opt]">[++opt]</A> <A HREF="#{file}">{file}</A> Write to <A HREF="#{file}">{file}</A> and quit. Quitting fails when the
last file in the argument <A HREF="eval.html#list">list</A> has not been edited.
<A HREF="#:wq">:wq</A>! <A HREF="#[++opt]">[++opt]</A> <A HREF="#{file}">{file}</A> Write to <A HREF="#{file}">{file}</A> and quit.
:[range]wq[!] <A HREF="#[++opt]">[++opt]</A> [file]
Same <A HREF="motion.html#as">as</A> above, but only write the lines in <A HREF="cmdline.html#[range]">[range]</A>.
*<A NAME=":x"></A><B>:x</B>* *<A NAME=":xit"></A><B>:xit</B>*
:[range]x[it][!] <A HREF="#[++opt]">[++opt]</A> [file]
Like "<A HREF="#:wq">:wq</A>", but write only when changes have been
made.
When <A HREF="options.html#'hidden'">'hidden'</A> is set and there are more <A HREF="windows.html#windows">windows</A>, the
current buffer becomes hidden, after <A HREF="#writing">writing</A> the file.
*<A NAME=":exi"></A><B>:exi</B>* *<A NAME=":exit"></A><B>:exit</B>*
:[range]exi[t][!] <A HREF="#[++opt]">[++opt]</A> [file]
Same <A HREF="motion.html#as">as</A> <A HREF="#:xit">:xit</A>.
*<A NAME="ZZ"></A><B>ZZ</B>*
<A HREF="#ZZ">ZZ</A> Write current file, if modified, and quit (same <A HREF="motion.html#as">as</A>
":x"). (Note: If there are several <A HREF="windows.html#windows">windows</A> for the
current file, the file is written if <A HREF="motion.html#it">it</A> was modified
and the <A HREF="windows.html#window">window</A> is closed).
*<A NAME="ZQ"></A><B>ZQ</B>*
<A HREF="#ZQ">ZQ</A> Quit without checking for changes (same <A HREF="motion.html#as">as</A> ":q!").
{not in Vi}
MULTIPLE WINDOWS AND BUFFERS *<A NAME="window-exit"></A><B>window-exit</B>*
*<A NAME=":qa"></A><B>:qa</B>* *<A NAME=":qall"></A><B>:qall</B>*
:qa[ll] Exit Vim, unless there are some <A HREF="windows.html#buffers">buffers</A> which have been
changed. (Use ":bmod" to go to the next modified buffer).
When <A HREF="options.html#'autowriteall'">'autowriteall'</A> is set all changed <A HREF="windows.html#buffers">buffers</A> will be
written, like |<A HREF="#:wqall">:wqall</A>|. {not in Vi}
:conf[irm] qa[ll]
Exit Vim. Bring up a prompt when some <A HREF="windows.html#buffers">buffers</A> have been
changed. See |<A HREF="#:confirm">:confirm</A>|. {not in Vi}
:qa[ll]! Exit Vim. Any changes to <A HREF="windows.html#buffers">buffers</A> are lost. {not in Vi}
Also see |<A HREF="quickfix.html#:cquit">:cquit</A>|, it does the same but exits with a non-zero
value.
*<A NAME=":quita"></A><B>:quita</B>* *<A NAME=":quitall"></A><B>:quitall</B>*
:quita[ll][!] Same <A HREF="motion.html#as">as</A> "<A HREF="#:qall">:qall</A>". {not in Vi}
:wqa[ll] <A HREF="#[++opt]">[++opt]</A> *<A NAME=":wqa"></A><B>:wqa</B>* *<A NAME=":wqall"></A><B>:wqall</B>* *<A NAME=":xa"></A><B>:xa</B>* *<A NAME=":xall"></A><B>:xall</B>*
:xa[ll] Write all changed <A HREF="windows.html#buffers">buffers</A> and exit Vim. If there are <A HREF="windows.html#buffers">buffers</A>
without a file name, which are readonly or which cannot be
written for another reason, Vim will not quit. {not in Vi}
:conf[irm] wqa[ll] <A HREF="#[++opt]">[++opt]</A>
:conf[irm] xa[ll]
Write all changed <A HREF="windows.html#buffers">buffers</A> and exit Vim. Bring up a prompt
when some <A HREF="windows.html#buffers">buffers</A> are readonly or cannot be written for
another reason. See |<A HREF="#:confirm">:confirm</A>|. {not in Vi}
:wqa[ll]! <A HREF="#[++opt]">[++opt]</A>
:xa[ll]! Write all changed <A HREF="windows.html#buffers">buffers</A>, even the ones that are readonly,
and exit Vim. If there are <A HREF="windows.html#buffers">buffers</A> without a file name or
which cannot be written for another reason, Vim will not quit.
{not in Vi}
==============================================================================
6. Dialogs *<A NAME="edit-dialogs"></A><B>edit-dialogs</B>*
*<A NAME=":confirm"></A><B>:confirm</B>* *<A NAME=":conf"></A><B>:conf</B>*
:conf[irm] {command} Execute {command}, and use a <A HREF="gui_w32.html#dialog">dialog</A> when an
operation has to be confirmed. Can be used on the
|<A HREF="#:q">:q</A>|, |<A HREF="#:qa">:qa</A>| and |<A HREF="#:w">:w</A>| commands (the latter to override
a read-only setting), and any other command that can
fail in such a way, such <A HREF="motion.html#as">as</A> |<A HREF="windows.html#:only">:only</A>|, |<A HREF="windows.html#:buffer">:buffer</A>|,
|<A HREF="windows.html#:bdelete">:bdelete</A>|, etc.
Examples:
<B> :confirm w foo</B>
Will ask for confirmation when "foo" already exists.
<B> :confirm q</B>
Will ask for confirmation when there are changes.
<B> :confirm qa</B>
If any modified, unsaved <A HREF="windows.html#buffers">buffers</A> exist, you will be prompted to save
or <A HREF="#abandon">abandon</A> each one. There are also choices to "save all" or "<A HREF="#abandon">abandon</A>
all".
If you want to always use "<A HREF="#:confirm">:confirm</A>", set the <A HREF="options.html#'confirm'">'confirm'</A> option.
*<A NAME=":browse"></A><B>:browse</B>* *<A NAME=":bro"></A><B>:bro</B>* *<A NAME="E338"></A><B>E338</B>* *<A NAME="E614"></A><B>E614</B>* *<A NAME="E615"></A><B>E615</B>* *<A NAME="E616"></A><B>E616</B>*
:bro[wse] {command} Open a file selection <A HREF="gui_w32.html#dialog">dialog</A> for an argument to
{command}. At present this works for |<A HREF="#:e">:e</A>|, |<A HREF="#:w">:w</A>|,
|<A HREF="#:wall">:wall</A>|, |<A HREF="#:wq">:wq</A>|, |<A HREF="#:wqall">:wqall</A>|, |<A HREF="#:x">:x</A>|, |<A HREF="#:xall">:xall</A>|, |<A HREF="#:exit">:exit</A>|,
|<A HREF="#:view">:view</A>|, |<A HREF="windows.html#:sview">:sview</A>|, |<A HREF="insert.html#:r">:r</A>|, |<A HREF="#:saveas">:saveas</A>|, |<A HREF="windows.html#:sp">:sp</A>|, |<A HREF="starting.html#:mkexrc">:mkexrc</A>|,
|<A HREF="starting.html#:mkvimrc">:mkvimrc</A>|, |<A HREF="starting.html#:mksession">:mksession</A>|, |<A HREF="starting.html#:mkview">:mkview</A>|, |<A HREF="windows.html#:split">:split</A>|,
|<A HREF="windows.html#:vsplit">:vsplit</A>|, |<A HREF="tabpage.html#:tabe">:tabe</A>|, |<A HREF="tabpage.html#:tabnew">:tabnew</A>|, |<A HREF="quickfix.html#:cfile">:cfile</A>|, |<A HREF="quickfix.html#:cgetfile">:cgetfile</A>|,
|<A HREF="quickfix.html#:caddfile">:caddfile</A>|, |<A HREF="quickfix.html#:lfile">:lfile</A>|, |<A HREF="quickfix.html#:lgetfile">:lgetfile</A>|, |<A HREF="quickfix.html#:laddfile">:laddfile</A>|,
|<A HREF="diff.html#:diffsplit">:diffsplit</A>|, |<A HREF="diff.html#:diffpatch">:diffpatch</A>|, |<A HREF="vi_diff.html#:open">:open</A>|, |<A HREF="windows.html#:pedit">:pedit</A>|,
|<A HREF="various.html#:redir">:redir</A>|, |<A HREF="repeat.html#:source">:source</A>|, |<A HREF="#:update">:update</A>|, |<A HREF="#:visual">:visual</A>|, |<A HREF="windows.html#:vsplit">:vsplit</A>|,
and |<A HREF="#:qall">:qall</A>| if <A HREF="options.html#'confirm'">'confirm'</A> is set.
{only in <A HREF="os_win32.html#Win32">Win32</A>, <A HREF="gui_x11.html#Athena">Athena</A>, <A HREF="gui_x11.html#Motif">Motif</A>, <A HREF="gui_x11.html#GTK">GTK</A> and <A HREF="os_mac.html#Mac">Mac</A> GUI}
When "<A HREF="#:browse">:browse</A>" is not possible you get an error
message. If the |<A HREF="various.html#+browse">+browse</A>| feature is missing or the
{command} doesn't support browsing, the {command} is
executed without a <A HREF="gui_w32.html#dialog">dialog</A>.
"<A HREF="#:browse">:browse</A> set" works like |<A HREF="options.html#:options">:options</A>|.
See also |<A HREF="starting.html#:oldfiles">:oldfiles</A>| for "<A HREF="#:browse">:browse</A> oldfiles".
The <A HREF="syntax.html#syntax">syntax</A> is best shown via some examples:
<B> :browse e $vim/foo</B>
Open the browser in the $vim/foo directory, and edit the
file chosen.
<B> :browse e</B>
Open the browser in the directory specified with <A HREF="options.html#'browsedir'">'browsedir'</A>,
and edit the file chosen.
<B> :browse w</B>
Open the browser in the directory of the current buffer,
with the current buffer filename <A HREF="motion.html#as">as</A> default, and save the
buffer under the filename chosen.
<B> :browse w C:/bar</B>
Open the browser in the C:/bar directory, with the current
buffer filename <A HREF="motion.html#as">as</A> default, and save the buffer under the
filename chosen.
Also see the |<A HREF="options.html#'browsedir'">'browsedir'</A>| option.
For versions of Vim where browsing is not supported, the command is executed
unmodified.
*<A NAME="browsefilter"></A><B>browsefilter</B>*
For MS Windows and <A HREF="gui_x11.html#GTK">GTK</A>, you can modify the filters that are used in the browse
<A HREF="gui_w32.html#dialog">dialog</A>. By setting the g:browsefilter or b:browsefilter <A HREF="eval.html#variables">variables</A>, you can
change the filters globally or locally to the buffer. The variable is set to
a <A HREF="eval.html#string">string</A> in the format "{filter label}\t{pattern};{pattern}\n" where {filter
label} is the text that appears in the "Files of Type" comboBox, and {pattern}
is the <A HREF="pattern.html#pattern">pattern</A> which filters the filenames. Several patterns can be given,
separated by '<A HREF="motion.html#;">;</A>'.
For <A HREF="gui_x11.html#Motif">Motif</A> the same format is used, but only the very first <A HREF="pattern.html#pattern">pattern</A> is actually
used (Motif only offers one <A HREF="pattern.html#pattern">pattern</A>, but you can edit <A HREF="motion.html#it">it</A>).
For example, to have only Vim files in the <A HREF="gui_w32.html#dialog">dialog</A>, you could use the following
command:
<B> let g:browsefilter = "Vim Scripts\t*.vim\nVim Startup Files\t*vimrc\n"</B>
You can override the <A HREF="change.html#filter">filter</A> setting on a per-buffer basis by setting the
b:browsefilter variable. You would most likely set b:browsefilter in a
<A HREF="filetype.html#filetype">filetype</A> <A HREF="usr_05.html#plugin">plugin</A>, so that the browse <A HREF="gui_w32.html#dialog">dialog</A> would contain entries related to
the type of file you are currently editing. Disadvantage: This makes <A HREF="motion.html#it">it</A>
difficult to start editing a file of a different type. To overcome this, you
may want to add "All Files\t*.*\n" <A HREF="motion.html#as">as</A> the final <A HREF="change.html#filter">filter</A>, so that the user can
still access any desired file.
To avoid setting <A HREF="#browsefilter">browsefilter</A> when Vim does not actually support <A HREF="motion.html#it">it</A>, you can
use has("browsefilter"):
<B> if has("browsefilter")</B>
<B> let g:browsefilter = "whatever"</B>
<B> endif</B>
==============================================================================
7. The current directory *<A NAME="current-directory"></A><B>current-directory</B>*
You may use the |<A HREF="#:cd">:cd</A>| and |<A HREF="#:lcd">:lcd</A>| commands to change to another directory, so
you will not have to type that directory name in front of the file names. It
also makes a difference for executing external commands, e.g. ":!ls".
Changing directory fails when the current buffer is modified, the '<A HREF="repeat.html#.">.</A>' flag is
present in <A HREF="options.html#'cpoptions'">'cpoptions'</A> and "<A HREF="change.html#!">!</A>" is not used in the command.
*<A NAME=":cd"></A><B>:cd</B>* *<A NAME="E747"></A><B>E747</B>* *<A NAME="E472"></A><B>E472</B>*
:cd[!] On non-Unix systems: Print the current directory
name. On <A HREF="os_unix.html#Unix">Unix</A> systems: Change the current directory
to the home directory. Use |<A HREF="#:pwd">:pwd</A>| to print the
current directory on all systems.
:cd[!] {path} Change the current directory to {path}.
If {path} is relative, <A HREF="motion.html#it">it</A> is searched for in the
directories listed in |<A HREF="options.html#'cdpath'">'cdpath'</A>|.
Does not change the meaning of an already opened file,
because its full path name is remembered. Files from
the |<A HREF="#arglist">arglist</A>| may change though!
On <A HREF="os_msdos.html#MS-DOS">MS-DOS</A> this also changes the active drive.
To change to the directory of the current file:
<B> :cd %:h</B>
*<A NAME=":cd-"></A><B>:cd-</B>* *<A NAME="E186"></A><B>E186</B>*
:cd[!] - Change to the previous current directory (before the
previous "<A HREF="#:cd">:cd</A> {path}" command). {not in Vi}
*<A NAME=":chd"></A><B>:chd</B>* *<A NAME=":chdir"></A><B>:chdir</B>*
:chd[ir][!] [path] Same <A HREF="motion.html#as">as</A> |<A HREF="#:cd">:cd</A>|.
*<A NAME=":lc"></A><B>:lc</B>* *<A NAME=":lcd"></A><B>:lcd</B>*
:lc[d][!] {path} Like |<A HREF="#:cd">:cd</A>|, but only set the current directory when
the cursor is in the current <A HREF="windows.html#window">window</A>. The current
directory for other <A HREF="windows.html#windows">windows</A> is not changed, switching
to another <A HREF="windows.html#window">window</A> will stop using {path}.
{not in Vi}
*<A NAME=":lch"></A><B>:lch</B>* *<A NAME=":lchdir"></A><B>:lchdir</B>*
:lch[dir][!] Same <A HREF="motion.html#as">as</A> |<A HREF="#:lcd">:lcd</A>|. {not in Vi}
*<A NAME=":pw"></A><B>:pw</B>* *<A NAME=":pwd"></A><B>:pwd</B>* *<A NAME="E187"></A><B>E187</B>*
:pw[d] Print the current directory name. {Vi: no pwd}
Also see |<A HREF="eval.html#getcwd()">getcwd()</A>|.
So long <A HREF="motion.html#as">as</A> no |<A HREF="#:lcd">:lcd</A>| command has been used, all <A HREF="windows.html#windows">windows</A> share the same current
directory. Using a command to jump to another <A HREF="windows.html#window">window</A> doesn't change anything
for the current directory.
When a |<A HREF="#:lcd">:lcd</A>| command has been used for a <A HREF="windows.html#window">window</A>, the specified directory
becomes the current directory for that <A HREF="windows.html#window">window</A>. Windows where the |<A HREF="#:lcd">:lcd</A>|
command has not been used stick to the global current directory. When jumping
to another <A HREF="windows.html#window">window</A> the current directory will become the last specified local
current directory. If none was specified, the global current directory is
used.
When a |<A HREF="#:cd">:cd</A>| command is used, the current <A HREF="windows.html#window">window</A> will lose his local current
directory and will use the global current directory from now on.
After using |<A HREF="#:cd">:cd</A>| the full path name will be used for reading and <A HREF="#writing">writing</A>
files. On some networked file systems this may cause problems. The result of
using the full path name is that the file names currently in use will remain
referring to the same file. Example: If you have a file a:test and a
directory a:vim the commands "<A HREF="#:e">:e</A> test" "<A HREF="#:cd">:cd</A> vim" "<A HREF="#:w">:w</A>" will overwrite the file
a:test and not write a:vim/test. But if you <A HREF="diff.html#do">do</A> "<A HREF="#:w">:w</A> test" the file a:vim/test
will be written, because you gave a new file name and did not refer to a
filename before the "<A HREF="#:cd">:cd</A>".
==============================================================================
8. Editing binary files *<A NAME="edit-binary"></A><B>edit-binary</B>*
Although Vim was made to edit text files, <A HREF="motion.html#it">it</A> is possible to edit binary
files. The |<A HREF="starting.html#-b">-b</A>| Vim argument (b for binary) makes Vim <A HREF="diff.html#do">do</A> file I/O in binary
mode, and sets some <A HREF="options.html#options">options</A> for editing binary files ('binary' on, <A HREF="options.html#'textwidth'">'textwidth'</A>
to 0, <A HREF="options.html#'modeline'">'modeline'</A> off, <A HREF="options.html#'expandtab'">'expandtab'</A> off). Setting the <A HREF="options.html#'binary'">'binary'</A> option has the
same effect. Don't forget to <A HREF="diff.html#do">do</A> this before reading the file.
There are a few things to remember when editing binary files:
- When editing executable files the number of characters must not change.
Use only the "<A HREF="change.html#R">R</A>" or "<A HREF="change.html#r">r</A>" command to change text. Do not delete characters
with "<A HREF="change.html#x">x</A>" or by backspacing.
- Set the <A HREF="options.html#'textwidth'">'textwidth'</A> option to 0. Otherwise lines will unexpectedly be
split in two.
- When there are not many <EOL>s, the lines will become very long. If you
want to edit a line that does not fit on the screen reset the <A HREF="options.html#'wrap'">'wrap'</A> option.
Horizontal <A HREF="scroll.html#scrolling">scrolling</A> is used then. If a line becomes too long (more than
about 32767 characters on the <A HREF="os_amiga.html#Amiga">Amiga</A>, much more on 32-bit systems, see
|<A HREF="vi_diff.html#limits">limits</A>|) you cannot edit that line. The line will be split when reading
the file. It is also possible that you get an "out of memory" error when
reading the file.
- Make sure the <A HREF="options.html#'binary'">'binary'</A> option is set BEFORE loading the
file. Otherwise both <A HREF="motion.html#<CR>"><CR></A> <A HREF="motion.html#<NL>"><NL></A> and <A HREF="motion.html#<NL>"><NL></A> are considered to end a line
and when the file is written the <A HREF="motion.html#<NL>"><NL></A> will be replaced with <A HREF="motion.html#<CR>"><CR></A> <A HREF="motion.html#<NL>"><NL></A>.
- <A HREF="intro.html#<Nul>"><Nul></A> characters are shown on the screen <A HREF="motion.html#as">as</A> ^@. You can enter them with
"<A HREF="visual.html#CTRL-V">CTRL-V</A> CTRL-@" or "<A HREF="visual.html#CTRL-V">CTRL-V</A> 000" {Vi cannot handle <A HREF="intro.html#<Nul>"><Nul></A> characters in the
file}
- To insert a <A HREF="motion.html#<NL>"><NL></A> character in the file split a line. When <A HREF="#writing">writing</A> the
buffer to a file a <A HREF="motion.html#<NL>"><NL></A> will be written for the <A HREF="intro.html#<EOL>"><EOL></A>.
- Vim normally appends an <A HREF="intro.html#<EOL>"><EOL></A> at the end of the file if there is none.
Setting the <A HREF="options.html#'binary'">'binary'</A> option prevents this. If you want to add the final
<A HREF="intro.html#<EOL>"><EOL></A>, set the <A HREF="options.html#'endofline'">'endofline'</A> option. You can also read the value of this
option to see if there was an <A HREF="intro.html#<EOL>"><EOL></A> for the last line (you cannot see this
in the text).
==============================================================================
9. Encryption *<A NAME="encryption"></A><B>encryption</B>*
Vim is able to write files encrypted, and read them back. The encrypted text
cannot be read without the right key.
{only available when compiled with the |<A HREF="various.html#+cryptv">+cryptv</A>| feature} *<A NAME="E833"></A><B>E833</B>*
The text in the swap file and the <A HREF="undo.html#undo">undo</A> file is also encrypted. *<A NAME="E843"></A><B>E843</B>*
However, this is done block-by-block and may reduce the time needed to crack a
password. You can disable the swap file, but then a crash will cause you to
lose your work. The <A HREF="undo.html#undo">undo</A> file can be disabled without much disadvantage.
<B> :set noundofile</B>
<B> :noswapfile edit secrets</B>
Note: The text in memory is not encrypted. A system administrator may be able
to see your text while you are editing <A HREF="motion.html#it">it</A>. When filtering text with
":!filter" or using "<A HREF="#:w">:w</A> !command" the text is also not encrypted, this may
reveal <A HREF="motion.html#it">it</A> to others. The <A HREF="options.html#'viminfo'">'viminfo'</A> file is not encrypted.
You could <A HREF="diff.html#do">do</A> this to edit very secret text:
<B> :set noundofile viminfo=</B>
<B> :noswapfile edit secrets.txt</B>
Keep in mind that without a swap file you risk losing your work in the event
of a crash or a power failure.
WARNING: If you make a typo when entering the key and then write the file and
exit, the text will be lost!
The normal way to work with <A HREF="#encryption">encryption</A>, is to use the "<A HREF="#:X">:X</A>" command, which will
ask you to enter a key. A following write command will use that key to
encrypt the file. If you later edit the same file, Vim will ask you to enter
a key. If you type the same key <A HREF="motion.html#as">as</A> that was used for <A HREF="#writing">writing</A>, the text will
be readable again. If you use a wrong key, <A HREF="motion.html#it">it</A> will be a mess.
*<A NAME=":X"></A><B>:X</B>*
<A HREF="#:X">:X</A> Prompt for an <A HREF="#encryption">encryption</A> key. The typing is done without showing the
actual text, so that someone looking at the display won't see <A HREF="motion.html#it">it</A>.
The typed key is stored in the <A HREF="options.html#'key'">'key'</A> option, which is used to encrypt
the file when <A HREF="motion.html#it">it</A> is written. The file will remain unchanged until you
write <A HREF="motion.html#it">it</A>. See also |<A HREF="starting.html#-x">-x</A>|.
The value of the <A HREF="options.html#'key'">'key'</A> <A HREF="options.html#options">options</A> is used when text is written. When the option
is not empty, the written file will be encrypted, using the value <A HREF="motion.html#as">as</A> the
<A HREF="#encryption">encryption</A> key. A magic number is prepended, so that Vim can recognize that
the file is encrypted.
To disable the <A HREF="#encryption">encryption</A>, reset the <A HREF="options.html#'key'">'key'</A> option to an empty value:
<B> :set key=</B>
You can use the <A HREF="options.html#'cryptmethod'">'cryptmethod'</A> option to select the type of <A HREF="#encryption">encryption</A>, use one
of these:
<B> :setlocal cm=zip " weak method, backwards compatible</B>
<B> :setlocal cm=blowfish " method with flaws</B>
<B> :setlocal cm=blowfish2 " medium strong method</B>
Do this before <A HREF="#writing">writing</A> the file. When reading an encrypted file <A HREF="motion.html#it">it</A> will be
set automatically to the method used when that file was written. You can
change <A HREF="options.html#'cryptmethod'">'cryptmethod'</A> before <A HREF="#writing">writing</A> that file to change the method.
To set the default method, used for new files, use this in your |<A HREF="starting.html#vimrc">vimrc</A>|
file:
<B> set cm=blowfish2</B>
Using "<A HREF="options.html#blowfish2">blowfish2</A>" is highly recommended. Only use another method if you
must use an older Vim version that does not support <A HREF="motion.html#it">it</A>.
The message given for reading and <A HREF="#writing">writing</A> a file will show "[crypted]" when
using <A HREF="pi_zip.html#zip">zip</A>, "[blowfish]" when using <A HREF="options.html#blowfish">blowfish</A>, etc.
When <A HREF="#writing">writing</A> an <A HREF="undo.html#undo">undo</A> file, the same key and method will be used for the text
in the undo file. |<A HREF="undo.html#persistent-undo">persistent-undo</A>|.
To test for <A HREF="options.html#blowfish">blowfish</A> support you can use these conditions:
<B> has('crypt-blowfish')</B>
<B> has('crypt-blowfish2')</B>
This works since Vim 7.4.1099 while <A HREF="options.html#blowfish">blowfish</A> support was added earlier.
Thus the condition failing doesn't mean <A HREF="options.html#blowfish">blowfish</A> is not supported. You can
test for <A HREF="options.html#blowfish">blowfish</A> with:
<B> v:version >= 703</B>
And for <A HREF="options.html#blowfish2">blowfish2</A> with:
<B> v:version > 704 || (v:version == 704 && has('patch401'))</B>
If you are sure Vim includes patch 7.4.237 a simpler check is:
<B> has('patch-7.4.401')</B>
*<A NAME="E817"></A><B>E817</B>* *<A NAME="E818"></A><B>E818</B>* *<A NAME="E819"></A><B>E819</B>* *<A NAME="E820"></A><B>E820</B>*
When <A HREF="#encryption">encryption</A> does not work properly, you would be able to write your text
to a file and never be able to read <A HREF="motion.html#it">it</A> back. Therefore a test is performed to
check if the <A HREF="#encryption">encryption</A> works <A HREF="motion.html#as">as</A> expected. If you get one of these <A HREF="message.html#errors">errors</A>
don't write the file encrypted! You need to rebuild the Vim binary to fix
this.
*<A NAME="E831"></A><B>E831</B>* This is an internal error, "cannot happen". If you can reproduce <A HREF="motion.html#it">it</A>,
please report to the developers.
When reading a file that has been encrypted and the <A HREF="options.html#'key'">'key'</A> option is not empty,
<A HREF="motion.html#it">it</A> will be used for decryption. If the value is empty, you will be prompted
to enter the key. If you don't enter a key, or you enter the wrong key, the
file is edited without being decrypted. There is no warning about using the
wrong key (this makes brute force methods to find the key more difficult).
If want to start reading a file that uses a different key, set the <A HREF="options.html#'key'">'key'</A>
option to an empty <A HREF="eval.html#string">string</A>, so that Vim will prompt for a new one. Don't use
the "<A HREF="options.html#:set">:set</A>" command to enter the value, other people can read the command over
your shoulder.
Since the value of the <A HREF="options.html#'key'">'key'</A> option is supposed to be a secret, its value can
never be viewed. You should not set this option in a <A HREF="starting.html#vimrc">vimrc</A> file.
An encrypted file can be recognized by the "file" command, if you add these
lines to "/etc/magic", "/usr/share/misc/magic" or wherever your system has the
"magic" file:
<B> 0 string VimCrypt~ Vim encrypted file</B>
<B> >9 string 01 - "zip" cryptmethod</B>
<B> >9 string 02 - "blowfish" cryptmethod</B>
<B> >9 string 03 - "blowfish2" cryptmethod</B>
Notes:
- Encryption is not possible when doing conversion with <A HREF="options.html#'charconvert'">'charconvert'</A>.
- Text you copy or delete goes to the numbered <A HREF="change.html#registers">registers</A>. The <A HREF="change.html#registers">registers</A> can
be saved in the .viminfo file, where they could be read. Change your
<A HREF="options.html#'viminfo'">'viminfo'</A> option to be safe.
- Someone can type commands in Vim when you walk away for a moment, he should
not be able to get the key.
- If you make a typing mistake when entering the key, you might not be able to
get your text back!
- If you type the key with a "<A HREF="options.html#:set">:set</A> <A HREF="options.html#'key'">key</A>=value" command, <A HREF="motion.html#it">it</A> can be kept in the
<A HREF="cmdline.html#history">history</A>, showing the <A HREF="options.html#'key'">'key'</A> value in a <A HREF="starting.html#viminfo">viminfo</A> file.
- There is never 100% safety. The <A HREF="#encryption">encryption</A> in Vim has not been tested for
robustness.
- The algorithm used for <A HREF="options.html#'cryptmethod'">'cryptmethod'</A> "<A HREF="pi_zip.html#zip">zip</A>" is breakable. A 4 character key
in about one hour, a 6 character key in one day (on a Pentium 133 PC). This
requires that you know some text that must appear in the file. An expert
can break <A HREF="motion.html#it">it</A> for any key. When the text has been decrypted, this also means
that the key can be revealed, and other files encrypted with the same key
can be decrypted.
- Pkzip uses the same <A HREF="#encryption">encryption</A> <A HREF="motion.html#as">as</A> <A HREF="options.html#'cryptmethod'">'cryptmethod'</A> "<A HREF="pi_zip.html#zip">zip</A>", and US Govt has no
objection to its export. Pkzip's public file APPNOTE.TXT describes this
algorithm in detail.
- The implementation of <A HREF="options.html#'cryptmethod'">'cryptmethod'</A> "<A HREF="options.html#blowfish">blowfish</A>" has a flaw. It is possible
to crack the first 64 bytes of a file and in some circumstances more of the
file. Use of <A HREF="motion.html#it">it</A> is not recommended, but it's still the strongest method
supported by Vim 7.3 and 7.4. The "<A HREF="pi_zip.html#zip">zip</A>" method is even weaker.
- Vim originates from the Netherlands. That is where the sources come from.
Thus the <A HREF="#encryption">encryption</A> code is not exported from the USA.
==============================================================================
10. Timestamps *<A NAME="timestamp"></A><B>timestamp</B>* *<A NAME="timestamps"></A><B>timestamps</B>*
Vim remembers the modification <A HREF="#timestamp">timestamp</A>, mode and size of a file when you
begin editing <A HREF="motion.html#it">it</A>. This is used to avoid that you have two different versions
of the same file (without you knowing this).
After a shell command is run (|<A HREF="various.html#:!cmd">:!cmd</A>| |<A HREF="starting.html#suspend">suspend</A>| |<A HREF="insert.html#:read!">:read!</A>| |<A HREF="various.html#K">K</A>|) <A HREF="#timestamps">timestamps</A>,
file modes and file sizes are compared for all <A HREF="windows.html#buffers">buffers</A> in a <A HREF="windows.html#window">window</A>. Vim will
run any associated |<A HREF="autocmd.html#FileChangedShell">FileChangedShell</A>| autocommands or display a warning for
any files that have changed. In the <A HREF="gui.html#GUI">GUI</A> this happens when Vim regains input
focus.
*<A NAME="E321"></A><B>E321</B>* *<A NAME="E462"></A><B>E462</B>*
If you want to automatically <A HREF="#reload">reload</A> a file when <A HREF="motion.html#it">it</A> has been changed outside of
Vim, set the <A HREF="options.html#'autoread'">'autoread'</A> option. This doesn't work at the moment you write the
file though, only when the file wasn't changed inside of Vim.
If you <A HREF="diff.html#do">do</A> not want to be asked or automatically <A HREF="#reload">reload</A> the file, you can use
this:
<B> set buftype=nofile</B>
Or, when starting <A HREF="starting.html#gvim">gvim</A> from a shell:
<B> gvim file.log -c "set buftype=nofile"</B>
Note that if a <A HREF="autocmd.html#FileChangedShell">FileChangedShell</A> <A HREF="autocmd.html#autocommand">autocommand</A> is defined you will not get a
warning message or prompt. The <A HREF="autocmd.html#autocommand">autocommand</A> is expected to handle this.
There is no warning for a directory (e.g., with |<A HREF="pi_netrw.html#netrw-browse">netrw-browse</A>|). But you <A HREF="diff.html#do">do</A>
get warned if you started editing a new file and <A HREF="motion.html#it">it</A> was created <A HREF="motion.html#as">as</A> a directory
later.
When Vim notices the <A HREF="#timestamp">timestamp</A> of a file has changed, and the file is being
edited in a buffer but has not changed, Vim checks if the contents of the file
is equal. This is done by reading the file again (into a hidden buffer, which
is immediately deleted again) and comparing the text. If the text is equal,
you will get no warning.
If you don't get warned often enough you can use the following command.
*<A NAME=":checkt"></A><B>:checkt</B>* *<A NAME=":checktime"></A><B>:checktime</B>*
:checkt[ime] Check if any <A HREF="windows.html#buffers">buffers</A> were changed outside of Vim.
This checks and warns you if you would end up with two
versions of a file.
If this is called from an <A HREF="autocmd.html#autocommand">autocommand</A>, a "<A HREF="repeat.html#:global">:global</A>"
command or is not typed the actual check is postponed
until a moment the side effects (reloading the file)
would be harmless.
Each loaded buffer is checked for its associated file
being changed. If the file was changed Vim will take
action. If there are no changes in the buffer and
<A HREF="options.html#'autoread'">'autoread'</A> is set, the buffer is reloaded. Otherwise,
you are offered the choice of reloading the file. If
the file was deleted you get an error message.
If the file previously didn't exist you get a warning
if <A HREF="motion.html#it">it</A> exists now.
Once a file has been checked the <A HREF="#timestamp">timestamp</A> is reset,
you will not be warned again.
:[N]checkt[ime] {filename}
:[N]checkt[ime] [N]
Check the <A HREF="#timestamp">timestamp</A> of a specific buffer. The buffer
may be specified by name, number or with a <A HREF="pattern.html#pattern">pattern</A>.
*<A NAME="E813"></A><B>E813</B>* *<A NAME="E814"></A><B>E814</B>*
Vim will <A HREF="#reload">reload</A> the buffer if you chose to. If a <A HREF="windows.html#window">window</A> is visible that
contains this buffer, the reloading will happen in the context of this <A HREF="windows.html#window">window</A>.
Otherwise a special <A HREF="windows.html#window">window</A> is used, so that most autocommands will work. You
can't close this <A HREF="windows.html#window">window</A>. A few other restrictions apply. Best is to make
sure nothing happens outside of the current buffer. E.g., setting
window-local <A HREF="options.html#options">options</A> may end up in the wrong <A HREF="windows.html#window">window</A>. Splitting the <A HREF="windows.html#window">window</A>,
doing something there and closing <A HREF="motion.html#it">it</A> should be OK (if there are no side
effects from other autocommands). Closing unrelated <A HREF="windows.html#windows">windows</A> and <A HREF="windows.html#buffers">buffers</A> will
get you into trouble.
Before <A HREF="#writing">writing</A> a file the <A HREF="#timestamp">timestamp</A> is checked. If <A HREF="motion.html#it">it</A> has changed, Vim will
ask if you really want to overwrite the file:
WARNING: The file has been changed since reading it!!!
Do you really want to write to <A HREF="motion.html#it">it</A> (y/n)?
If you hit '<A HREF="change.html#y">y</A>' Vim will continue <A HREF="#writing">writing</A> the file. If you hit '<A HREF="pattern.html#n">n</A>' the write is
aborted. If you used "<A HREF="#:wq">:wq</A>" or "<A HREF="#ZZ">ZZ</A>" Vim will not exit, you will get another
chance to write the file.
The message would normally mean that somebody has written to the file after
the edit session started. This could be another person, in which <A HREF="change.html#case">case</A> you
probably want to check if your changes to the file and the changes from the
other person should be merged. Write the file under another name and check for
differences (the "<A HREF="diff.html#diff">diff</A>" program can be used for this).
It is also possible that you modified the file yourself, from another edit
session or with another command (e.g., a <A HREF="change.html#filter">filter</A> command). Then you will know
which version of the file you want to keep.
There is one situation where you get the message while there is nothing wrong:
On a <A HREF="os_win32.html#Win32">Win32</A> system on the day daylight saving time starts. There is something
in the <A HREF="os_win32.html#Win32">Win32</A> libraries that confuses Vim about the hour time difference. The
problem goes away the next day.
==============================================================================
11. File Searching *<A NAME="file-searching"></A><B>file-searching</B>*
{not available when compiled without the |<A HREF="various.html#+path_extra">+path_extra</A>| feature}
The file searching is currently used for the <A HREF="options.html#'path'">'path'</A>, <A HREF="options.html#'cdpath'">'cdpath'</A> and <A HREF="options.html#'tags'">'tags'</A>
<A HREF="options.html#options">options</A>, for |<A HREF="eval.html#finddir()">finddir()</A>| and |<A HREF="eval.html#findfile()">findfile()</A>|. Other commands use |<A HREF="#wildcards">wildcards</A>|
which is slightly different.
There are three different types of searching:
1) Downward search: *<A NAME="starstar"></A><B>starstar</B>*
Downward search uses the <A HREF="#wildcards">wildcards</A> '*', '**' and possibly others
supported by your operating system. '*' and '**' are handled inside Vim,
so they work on all operating systems. Note that "**" only acts <A HREF="motion.html#as">as</A> a
special <A HREF="#wildcard">wildcard</A> when <A HREF="motion.html#it">it</A> is at the start of a name.
The usage of '*' is quite simple: It matches 0 or more characters. In a
search <A HREF="pattern.html#pattern">pattern</A> this would be ".*". Note that the "<A HREF="repeat.html#.">.</A>" is not used for file
searching.
'**' is more sophisticated:
- It ONLY matches directories.
- It matches up to 30 directories deep by default, so you can use <A HREF="motion.html#it">it</A> to
search an entire directory tree
- The maximum number of levels matched can be given by appending a number
to '**'.
Thus '/usr/**2' can match:
<B> /usr</B>
<B> /usr/include</B>
<B> /usr/include/sys</B>
<B> /usr/include/g++</B>
<B> /usr/lib</B>
<B> /usr/lib/X11</B>
<B> ....</B>
It does NOT match '/usr/include/g++/std' <A HREF="motion.html#as">as</A> this would be three
levels.
The allowed number range is 0 ('**0' is removed) to 100
If the given number is smaller than 0 <A HREF="motion.html#it">it</A> defaults to 30, if it's
bigger than 100 then 100 is used. The system also has a limit on the
path length, usually 256 or 1024 bytes.
- '**' can only be at the end of the path or be followed by a path
separator or by a number and a path separator.
You can combine '*' and '**' in any order:
<B> /usr/**/sys/*</B>
<B> /usr/*tory/sys/**</B>
<B> /usr/**2/sys/*</B>
2) Upward search:
Here you can give a directory and then search the directory tree upward for
a file. You could give stop-directories to limit the upward search. The
stop-directories are appended to the path (for the <A HREF="options.html#'path'">'path'</A> option) or to
the filename (for the <A HREF="options.html#'tags'">'tags'</A> option) with a '<A HREF="motion.html#;">;</A>'. If you want several
stop-directories separate them with '<A HREF="motion.html#;">;</A>'. If you want no stop-directory
("search upward till the root directory) just use '<A HREF="motion.html#;">;</A>'.
<B> /usr/include/sys;/usr</B>
will search in:
<B> /usr/include/sys</B>
<B> /usr/include</B>
<B> /usr</B>
If you use a relative path the upward search is started in Vim's current
directory or in the directory of the current file (if the relative path
starts with './' and '<A HREF="change.html#d">d</A>' is not included in <A HREF="options.html#'cpoptions'">'cpoptions'</A>).
If Vim's current path is /u/user_x/work/release and you <A HREF="diff.html#do">do</A>
<B> :set path=include;/u/user_x</B>
and then search for a file with |<A HREF="#gf">gf</A>| the file is searched in:
<B> /u/user_x/work/release/include</B>
<B> /u/user_x/work/include</B>
<B> /u/user_x/include</B>
3) Combined up/downward search:
If Vim's current path is /u/user_x/work/release and you <A HREF="diff.html#do">do</A>
<B> set path=**;/u/user_x</B>
and then search for a file with |<A HREF="#gf">gf</A>| the file is searched in:
<B> /u/user_x/work/release/**</B>
<B> /u/user_x/work/**</B>
<B> /u/user_x/**</B>
BE CAREFUL! This might consume a lot of time, <A HREF="motion.html#as">as</A> the search of
'/u/user_x/**' includes '/u/user_x/work/**' and
'/u/user_x/work/release/**'. So '/u/user_x/work/release/**' is searched
three times and '/u/user_x/work/**' is searched <A HREF="if_cscop.html#twice">twice</A>.
In the above example you might want to set path to:
<B> :set path=**,/u/user_x/**</B>
This searches:
<B><FONT COLOR="PURPLE"> /u/user_x/work/release/** </FONT></B>
<B><FONT COLOR="PURPLE"> /u/user_x/** </FONT></B>
This searches the same directories, but in a different order.
Note that completion for "<A HREF="#:find">:find</A>", "<A HREF="windows.html#:sfind">:sfind</A>", and "<A HREF="tabpage.html#:tabfind">:tabfind</A>" commands <A HREF="diff.html#do">do</A> not
currently work with <A HREF="options.html#'path'">'path'</A> items that contain a URL or use the double <A HREF="pattern.html#star">star</A>
with depth limiter (/usr/**2) or upward search (;) notations.
<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>
</HTML>
|