/usr/share/doc/vim/html/cmdline.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 | <HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: cmdline</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: cmdline</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>
<HR>
<PRE>
*<A NAME="cmdline.txt"></A><B>cmdline.txt</B>* For Vim version 8.0. Last change: 2017 Oct 19
VIM REFERENCE MANUAL by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>
*<A NAME="Cmdline-mode"></A><B>Cmdline-mode</B>* *<A NAME="Command-line-mode"></A><B>Command-line-mode</B>*
<A HREF="#Command-line">Command-line</A> mode *<A NAME="Cmdline"></A><B>Cmdline</B>* *<A NAME="Command-line"></A><B>Command-line</B>* *<A NAME="mode-cmdline"></A><B>mode-cmdline</B>* *<A NAME=":"></A><B>:</B>*
<A HREF="#Command-line">Command-line</A> mode is used to enter <A HREF="intro.html#Ex">Ex</A> commands (":"), search patterns
("/" and "?"), and <A HREF="change.html#filter">filter</A> commands ("!").
Basic command line editing is explained in chapter 20 of the user manual
|<A HREF="usr_20.html">usr_20.txt</A>|.
1. <A HREF="#Command-line">Command-line</A> editing |<A HREF="#cmdline-editing">cmdline-editing</A>|
2. <A HREF="#Command-line">Command-line</A> completion |<A HREF="#cmdline-completion">cmdline-completion</A>|
3. <A HREF="intro.html#Ex">Ex</A> command-lines |<A HREF="#cmdline-lines">cmdline-lines</A>|
4. <A HREF="intro.html#Ex">Ex</A> command-line ranges |<A HREF="#cmdline-ranges">cmdline-ranges</A>|
5. <A HREF="intro.html#Ex">Ex</A> command-line flags |<A HREF="#ex-flags">ex-flags</A>|
6. <A HREF="intro.html#Ex">Ex</A> special characters |<A HREF="#cmdline-special">cmdline-special</A>|
7. <A HREF="#Command-line">Command-line</A> window |<A HREF="#cmdline-window">cmdline-window</A>|
==============================================================================
1. <A HREF="#Command-line">Command-line</A> editing *<A NAME="cmdline-editing"></A><B>cmdline-editing</B>*
Normally characters are inserted in front of the cursor position. You can
move around in the command-line with the left and right cursor keys. With the
<A HREF="insert.html#<Insert>"><Insert></A> key, you can toggle between <A HREF="insert.html#inserting">inserting</A> and overstriking characters.
{Vi: can only alter the last character in the line}
Note that if your keyboard does not have working cursor keys or any of the
other special keys, you can use "<A HREF="map.html#:cnoremap">:cnoremap</A>" to define another key for them.
For example, to define tcsh style editing keys: *<A NAME="tcsh-style"></A><B>tcsh-style</B>*
<B> :cnoremap <C-A> <Home></B>
<B> :cnoremap <C-F> <Right></B>
<B> :cnoremap <C-B> <Left></B>
<B> :cnoremap <Esc>b <S-Left></B>
<B> :cnoremap <Esc>f <S-Right></B>
(<> <A HREF="intro.html#notation">notation</A> |<A HREF="intro.html#<>"><></A>|; type all this literally)
*<A NAME="cmdline-too-long"></A><B>cmdline-too-long</B>*
When the command line is getting longer than what fits on the screen, only the
part that fits will be shown. The cursor can only move in this visible part,
thus you cannot edit beyond that.
*<A NAME="cmdline-history"></A><B>cmdline-history</B>* *<A NAME="history"></A><B>history</B>*
The command-lines that you enter are remembered in a <A HREF="#history">history</A> table. You can
recall them with the up and down cursor keys. There are actually five
<A HREF="#history">history</A> tables:
- one for '<A HREF="#:">:</A>' commands
- one for search strings
- one for expressions
- one for input lines, typed for the |<A HREF="eval.html#input()">input()</A>| function.
- one for debug mode commands
These are completely separate. Each <A HREF="#history">history</A> can only be accessed when
entering the same type of line.
Use the <A HREF="options.html#'history'">'history'</A> option to set the number of lines that are remembered
(default: 50).
Notes:
- When you enter a command-line that is exactly the same <A HREF="motion.html#as">as</A> an older one, the
old one is removed (to avoid repeated commands moving older commands out of
the <A HREF="#history">history</A>).
- Only commands that are typed are remembered. Ones that completely come from
mappings are not put in the <A HREF="#history">history</A>.
- All searches are put in the search <A HREF="#history">history</A>, including the ones that come
from commands like "*" and "<A HREF="pattern.html##">#</A>". But for a <A HREF="map.html#mapping">mapping</A>, only the last search is
remembered (to avoid that long mappings trash the <A HREF="#history">history</A>).
{Vi: no history}
{not available when compiled without the |<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>| feature}
There is an automatic completion of names on the command-line; see
|<A HREF="#cmdline-completion">cmdline-completion</A>|.
*<A NAME="c_CTRL-V"></A><B>c_CTRL-V</B>*
<A HREF="visual.html#CTRL-V">CTRL-V</A> <A HREF="insert.html#Insert">Insert</A> next non-digit literally. Up to three digits form the
decimal value of a single byte. The non-digit and the three
digits are not considered for <A HREF="map.html#mapping">mapping</A>. This works the same
way <A HREF="motion.html#as">as</A> in <A HREF="insert.html#Insert">Insert</A> mode (see above, |<A HREF="insert.html#i_CTRL-V">i_CTRL-V</A>|).
Note: Under Windows <A HREF="visual.html#CTRL-V">CTRL-V</A> is often mapped to paste text.
Use <A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A> instead then.
*<A NAME="c_CTRL-Q"></A><B>c_CTRL-Q</B>*
<A HREF="gui_w32.html#CTRL-Q">CTRL-Q</A> Same <A HREF="motion.html#as">as</A> <A HREF="visual.html#CTRL-V">CTRL-V</A>. But with some terminals <A HREF="motion.html#it">it</A> is used for
<A HREF="intro.html#control">control</A> flow, <A HREF="motion.html#it">it</A> doesn't work then.
*<A NAME="c_<Left>"></A><B>c_<Left></B>* *<A NAME="c_Left"></A><B>c_Left</B>*
<A HREF="motion.html#<Left>"><Left></A> cursor left
*<A NAME="c_<Right>"></A><B>c_<Right></B>* *<A NAME="c_Right"></A><B>c_Right</B>*
<A HREF="motion.html#<Right>"><Right></A> cursor right
*<A NAME="c_<S-Left>"></A><B>c_<S-Left></B>*
<A HREF="motion.html#<S-Left>"><S-Left></A> or <A HREF="motion.html#<C-Left>"><C-Left></A> *<A NAME="c_<C-Left>"></A><B>c_<C-Left></B>*
cursor one <A HREF="motion.html#WORD">WORD</A> left
*<A NAME="c_<S-Right>"></A><B>c_<S-Right></B>*
<A HREF="motion.html#<S-Right>"><S-Right></A> or <A HREF="motion.html#<C-Right>"><C-Right></A> *<A NAME="c_<C-Right>"></A><B>c_<C-Right></B>*
cursor one <A HREF="motion.html#WORD">WORD</A> right
<A HREF="scroll.html#CTRL-B">CTRL-B</A> or <A HREF="motion.html#<Home>"><Home></A> *<A NAME="c_CTRL-B"></A><B>c_CTRL-B</B>* *<A NAME="c_<Home>"></A><B>c_<Home></B>* *<A NAME="c_Home"></A><B>c_Home</B>*
cursor to beginning of command-line
<A HREF="scroll.html#CTRL-E">CTRL-E</A> or <A HREF="motion.html#<End>"><End></A> *<A NAME="c_CTRL-E"></A><B>c_CTRL-E</B>* *<A NAME="c_<End>"></A><B>c_<End></B>* *<A NAME="c_End"></A><B>c_End</B>*
cursor to end of command-line
*<A NAME="c_<LeftMouse>"></A><B>c_<LeftMouse></B>*
<A HREF="visual.html#<LeftMouse>"><LeftMouse></A> Move the cursor to the position of the mouse click.
*<A NAME="c_<MiddleMouse>"></A><B>c_<MiddleMouse></B>*
<A HREF="change.html#<MiddleMouse>"><MiddleMouse></A> Paste the contents of the <A HREF="gui.html#clipboard">clipboard</A> (for <A HREF="options.html#X11">X11</A> the primary
selection). This is similar to using <A HREF="undo.html#CTRL-R">CTRL-R</A> *, but no CR
characters are inserted between lines.
<A HREF="motion.html#CTRL-H">CTRL-H</A> *<A NAME="c_<BS>"></A><B>c_<BS></B>* *<A NAME="c_CTRL-H"></A><B>c_CTRL-H</B>* *<A NAME="c_BS"></A><B>c_BS</B>*
<A HREF="motion.html#<BS>"><BS></A> Delete the character in front of the cursor (see |<A HREF="options.html#:fixdel">:fixdel</A>| if
your <A HREF="motion.html#<BS>"><BS></A> key does not <A HREF="diff.html#do">do</A> what you want).
*<A NAME="c_<Del>"></A><B>c_<Del></B>* *<A NAME="c_Del"></A><B>c_Del</B>*
<A HREF="change.html#<Del>"><Del></A> Delete the character under the cursor (at end of line:
character before the cursor) (see |<A HREF="options.html#:fixdel">:fixdel</A>| if your <A HREF="change.html#<Del>"><Del></A>
key does not <A HREF="diff.html#do">do</A> what you want).
*<A NAME="c_CTRL-W"></A><B>c_CTRL-W</B>*
<A HREF="index.html#CTRL-W">CTRL-W</A> Delete the |<A HREF="motion.html#word">word</A>| before the cursor. This depends on the
<A HREF="options.html#'iskeyword'">'iskeyword'</A> option.
*<A NAME="c_CTRL-U"></A><B>c_CTRL-U</B>*
<A HREF="scroll.html#CTRL-U">CTRL-U</A> Remove all characters between the cursor position and
the beginning of the line. Previous versions of vim
deleted all characters on the line. If that is the
preferred behavior, add the following to your <A HREF="starting.html#.vimrc">.vimrc</A>:
<B> :cnoremap <C-U> <C-E><C-U></B>
*<A NAME="c_<Insert>"></A><B>c_<Insert></B>* *<A NAME="c_Insert"></A><B>c_Insert</B>*
<A HREF="insert.html#<Insert>"><Insert></A> Toggle between insert and overstrike. {not in Vi}
{char1} <A HREF="motion.html#<BS>"><BS></A> {char2} or *<A NAME="c_digraph"></A><B>c_digraph</B>*
CTRL-K {char1} {char2} *<A NAME="c_CTRL-K"></A><B>c_CTRL-K</B>*
enter digraph (see |<A HREF="digraph.html#digraphs">digraphs</A>|). When {char1} is a special
key, the code for that key is inserted in <A HREF="intro.html#<>"><></A> form. {not in Vi}
<A HREF="undo.html#CTRL-R">CTRL-R</A> {0-9a-z"%#:-=.} *<A NAME="c_CTRL-R"></A><B>c_CTRL-R</B>* *<A NAME="c_<C-R>"></A><B>c_<C-R></B>*
<A HREF="insert.html#Insert">Insert</A> the contents of a numbered or named <A HREF="sponsor.html#register">register</A>. Between
typing <A HREF="undo.html#CTRL-R">CTRL-R</A> and the second character '"'' will be displayed
to indicate that you are expected to enter the name of a
<A HREF="sponsor.html#register">register</A>.
The text is inserted <A HREF="motion.html#as">as</A> if you typed <A HREF="motion.html#it">it</A>, but mappings and
<A HREF="map.html#abbreviations">abbreviations</A> are not used. <A HREF="#Command-line">Command-line</A> completion through
<A HREF="options.html#'wildchar'">'wildchar'</A> is not triggered though. And characters that end
the command line are inserted literally (<Esc>, <A HREF="motion.html#<CR>"><CR></A>, <A HREF="motion.html#<NL>"><NL></A>,
<C-C>). A <A HREF="motion.html#<BS>"><BS></A> or <A HREF="index.html#CTRL-W">CTRL-W</A> could still end the command line
though, and remaining characters will then be interpreted in
another mode, which might not be what you intended.
<A HREF="eval.html#Special">Special</A> <A HREF="change.html#registers">registers</A>:
'"'' the unnamed <A HREF="sponsor.html#register">register</A>, containing the text of
the last delete or <A HREF="change.html#yank">yank</A>
'<A HREF="motion.html#%">%</A>' the current file name
'<A HREF="pattern.html##">#</A>' the alternate file name
'*' the <A HREF="gui.html#clipboard">clipboard</A> contents (X11: primary selection)
'<A HREF="motion.html#+">+</A>' the <A HREF="gui.html#clipboard">clipboard</A> contents
'<A HREF="pattern.html#/">/</A>' the last search <A HREF="pattern.html#pattern">pattern</A>
'<A HREF="#:">:</A>' the last command-line
'<A HREF="motion.html#-">-</A>' the last small (less than a line) delete
'<A HREF="repeat.html#.">.</A>' the last inserted text
*<A NAME="c_CTRL-R_="></A><B>c_CTRL-R_=</B>*
'<A HREF="change.html#=">=</A>' the <A HREF="eval.html#expression">expression</A> <A HREF="sponsor.html#register">register</A>: you are prompted to
enter an expression (see |<A HREF="eval.html#expression">expression</A>|)
(doesn't work at the <A HREF="eval.html#expression">expression</A> prompt; some
things such <A HREF="motion.html#as">as</A> <A HREF="change.html#changing">changing</A> the buffer or current
<A HREF="windows.html#window">window</A> are not allowed to avoid side effects)
When the result is a |<A HREF="eval.html#List">List</A>| the items are used
<A HREF="motion.html#as">as</A> lines. They can have line breaks inside
too.
When the result is a <A HREF="eval.html#Float">Float</A> it's automatically
converted to a <A HREF="eval.html#String">String</A>.
See |<A HREF="change.html#registers">registers</A>| about registers. {not in Vi}
Implementation detail: When using the |<A HREF="eval.html#expression">expression</A>| <A HREF="sponsor.html#register">register</A>
and invoking <A HREF="eval.html#setcmdpos()">setcmdpos()</A>, this sets the position before
<A HREF="insert.html#inserting">inserting</A> the resulting <A HREF="eval.html#string">string</A>. Use <A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="undo.html#CTRL-R">CTRL-R</A> to set the
position afterwards.
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="scroll.html#CTRL-F">CTRL-F</A> *<A NAME="c_CTRL-R_CTRL-F"></A><B>c_CTRL-R_CTRL-F</B>* *<A NAME="c_<C-R>_<C-F>"></A><B>c_<C-R>_<C-F></B>*
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> *<A NAME="c_CTRL-R_CTRL-P"></A><B>c_CTRL-R_CTRL-P</B>* *<A NAME="c_<C-R>_<C-P>"></A><B>c_<C-R>_<C-P></B>*
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="index.html#CTRL-W">CTRL-W</A> *<A NAME="c_CTRL-R_CTRL-W"></A><B>c_CTRL-R_CTRL-W</B>* *<A NAME="c_<C-R>_<C-W>"></A><B>c_<C-R>_<C-W></B>*
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="change.html#CTRL-A">CTRL-A</A> *<A NAME="c_CTRL-R_CTRL-A"></A><B>c_CTRL-R_CTRL-A</B>* *<A NAME="c_<C-R>_<C-A>"></A><B>c_<C-R>_<C-A></B>*
<A HREF="insert.html#Insert">Insert</A> the object under the cursor:
<A HREF="scroll.html#CTRL-F">CTRL-F</A> the Filename under the cursor
<A HREF="motion.html#CTRL-P">CTRL-P</A> the Filename under the cursor, expanded with
<A HREF="options.html#'path'">'path'</A> <A HREF="motion.html#as">as</A> in |<A HREF="editing.html#gf">gf</A>|
<A HREF="index.html#CTRL-W">CTRL-W</A> the Word under the cursor
<A HREF="change.html#CTRL-A">CTRL-A</A> the WORD under the cursor; see |<A HREF="motion.html#WORD">WORD</A>|
When <A HREF="options.html#'incsearch'">'incsearch'</A> is set the cursor position at the end of the
currently displayed match is used. With <A HREF="index.html#CTRL-W">CTRL-W</A> the part of
the <A HREF="motion.html#word">word</A> that was already typed is not inserted again.
{not in Vi}
<A HREF="scroll.html#CTRL-F">CTRL-F</A> and <A HREF="motion.html#CTRL-P">CTRL-P</A>: {only when |<A HREF="various.html#+file_in_path">+file_in_path</A>| feature is
included}
*<A NAME="c_CTRL-R_CTRL-R"></A><B>c_CTRL-R_CTRL-R</B>* *<A NAME="c_<C-R>_<C-R>"></A><B>c_<C-R>_<C-R></B>*
*<A NAME="c_CTRL-R_CTRL-O"></A><B>c_CTRL-R_CTRL-O</B>* *<A NAME="c_<C-R>_<C-O>"></A><B>c_<C-R>_<C-O></B>*
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="undo.html#CTRL-R">CTRL-R</A> {0-9a-z"%#:-=. <A HREF="scroll.html#CTRL-F">CTRL-F</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> <A HREF="index.html#CTRL-W">CTRL-W</A> CTRL-A}
<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="motion.html#CTRL-O">CTRL-O</A> {0-9a-z"%#:-=. <A HREF="scroll.html#CTRL-F">CTRL-F</A> <A HREF="motion.html#CTRL-P">CTRL-P</A> <A HREF="index.html#CTRL-W">CTRL-W</A> CTRL-A}
<A HREF="insert.html#Insert">Insert</A> <A HREF="sponsor.html#register">register</A> or object under the cursor. Works like
|<A HREF="#c_CTRL-R">c_CTRL-R</A>| but inserts the text literally. For example, if
<A HREF="sponsor.html#register">register</A> a contains "xy^Hz" (where ^H is a backspace),
"<A HREF="undo.html#CTRL-R">CTRL-R</A> a" will insert "xz" while "<A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="undo.html#CTRL-R">CTRL-R</A> a" will
insert "xy^Hz".
CTRL-\ <A HREF="motion.html#e">e</A> {expr} *<A NAME="c_CTRL-\_e"></A><B>c_CTRL-\_e</B>*
Evaluate {expr} and replace the whole command line with the
result. You will be prompted for the <A HREF="eval.html#expression">expression</A>, type <A HREF="intro.html#<Enter>"><Enter></A>
to finish <A HREF="motion.html#it">it</A>. It's most useful in mappings though. See
|<A HREF="eval.html#expression">expression</A>|.
See |<A HREF="#c_CTRL-R_=">c_CTRL-R_=</A>| for <A HREF="insert.html#inserting">inserting</A> the result of an <A HREF="eval.html#expression">expression</A>.
Useful <A HREF="eval.html#functions">functions</A> are |<A HREF="eval.html#getcmdtype()">getcmdtype()</A>|, |<A HREF="eval.html#getcmdline()">getcmdline()</A>| and
|<A HREF="eval.html#getcmdpos()">getcmdpos()</A>|.
The cursor position is unchanged, except when the cursor was
at the end of the line, then <A HREF="motion.html#it">it</A> stays at the end.
|<A HREF="eval.html#setcmdpos()">setcmdpos()</A>| can be used to set the cursor position.
The |<A HREF="eval.html#sandbox">sandbox</A>| is used for evaluating the <A HREF="eval.html#expression">expression</A> to avoid
nasty side effects.
Example:
<B> :cmap <F7> <C-\>eAppendSome()<CR></B>
<B> :func AppendSome()</B>
<B> :let cmd = getcmdline() . " Some()"</B>
<B> :" place the cursor on the )</B>
<B> :call setcmdpos(strlen(cmd))</B>
<B> :return cmd</B>
<B> :endfunc</B>
This doesn't work recursively, thus not when already editing
an <A HREF="eval.html#expression">expression</A>. But <A HREF="motion.html#it">it</A> is possible to use in a <A HREF="map.html#mapping">mapping</A>.
*<A NAME="c_CTRL-Y"></A><B>c_CTRL-Y</B>*
<A HREF="scroll.html#CTRL-Y">CTRL-Y</A> When there is a modeless selection, copy the selection into
the <A HREF="gui.html#clipboard">clipboard</A>. |<A HREF="gui.html#modeless-selection">modeless-selection</A>|
If there is no selection <A HREF="scroll.html#CTRL-Y">CTRL-Y</A> is inserted <A HREF="motion.html#as">as</A> a character.
<A HREF="motion.html#CTRL-M">CTRL-M</A> or <A HREF="motion.html#CTRL-J">CTRL-J</A> *<A NAME="c_CTRL-M"></A><B>c_CTRL-M</B>* *<A NAME="c_CTRL-J"></A><B>c_CTRL-J</B>* *<A NAME="c_<NL>"></A><B>c_<NL></B>* *<A NAME="c_<CR>"></A><B>c_<CR></B>* *<A NAME="c_CR"></A><B>c_CR</B>*
<A HREF="motion.html#<CR>"><CR></A> or <A HREF="motion.html#<NL>"><NL></A> start entered command
CTRL-[ *<A NAME="c_CTRL-["></A><B>c_CTRL-[</B>* *<A NAME="c_<Esc>"></A><B>c_<Esc></B>* *<A NAME="c_Esc"></A><B>c_Esc</B>*
<A HREF="intro.html#<Esc>"><Esc></A> When typed and '<A HREF="change.html#x">x</A>' not present in <A HREF="options.html#'cpoptions'">'cpoptions'</A>, quit
<A HREF="#Command-line">Command-line</A> mode without executing. In macros or when '<A HREF="change.html#x">x</A>'
present in <A HREF="options.html#'cpoptions'">'cpoptions'</A>, start entered command.
Note: If your <A HREF="intro.html#<Esc>"><Esc></A> key is hard to hit on your keyboard, train
yourself to use CTRL-[.
*<A NAME="c_CTRL-C"></A><B>c_CTRL-C</B>*
<A HREF="pattern.html#CTRL-C">CTRL-C</A> quit command-line without executing
*<A NAME="c_<Up>"></A><B>c_<Up></B>* *<A NAME="c_Up"></A><B>c_Up</B>*
<A HREF="motion.html#<Up>"><Up></A> recall older command-line from <A HREF="#history">history</A>, whose beginning
matches the current command-line (see below).
{not available when compiled without the |<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>|
feature}
*<A NAME="c_<Down>"></A><B>c_<Down></B>* *<A NAME="c_Down"></A><B>c_Down</B>*
<A HREF="motion.html#<Down>"><Down></A> recall more recent command-line from <A HREF="#history">history</A>, whose beginning
matches the current command-line (see below).
{not available when compiled without the |<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>|
feature}
*<A NAME="c_<S-Up>"></A><B>c_<S-Up></B>* *<A NAME="c_<PageUp>"></A><B>c_<PageUp></B>*
<A HREF="scroll.html#<S-Up>"><S-Up></A> or <A HREF="scroll.html#<PageUp>"><PageUp></A>
recall older command-line from <A HREF="#history">history</A>
{not available when compiled without the |<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>|
feature}
*<A NAME="c_<S-Down>"></A><B>c_<S-Down></B>* *<A NAME="c_<PageDown>"></A><B>c_<PageDown></B>*
<A HREF="scroll.html#<S-Down>"><S-Down></A> or <A HREF="scroll.html#<PageDown>"><PageDown></A>
recall more recent command-line from <A HREF="#history">history</A>
{not available when compiled without the |<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>|
feature}
<A HREF="scroll.html#CTRL-D">CTRL-D</A> command-line completion (see |<A HREF="#cmdline-completion">cmdline-completion</A>|)
<A HREF="options.html#'wildchar'">'wildchar'</A> option
command-line completion (see |<A HREF="#cmdline-completion">cmdline-completion</A>|)
<A HREF="motion.html#CTRL-N">CTRL-N</A> command-line completion (see |<A HREF="#cmdline-completion">cmdline-completion</A>|)
<A HREF="motion.html#CTRL-P">CTRL-P</A> command-line completion (see |<A HREF="#cmdline-completion">cmdline-completion</A>|)
<A HREF="change.html#CTRL-A">CTRL-A</A> command-line completion (see |<A HREF="#cmdline-completion">cmdline-completion</A>|)
<A HREF="various.html#CTRL-L">CTRL-L</A> command-line completion (see |<A HREF="#cmdline-completion">cmdline-completion</A>|)
*<A NAME="c_CTRL-_"></A><B>c_CTRL-_</B>*
CTRL-_ a - switch between Hebrew and English keyboard mode, which is
private to the command-line and not related to hkmap.
This is useful when Hebrew text entry is required in the
command-line, searches, <A HREF="map.html#abbreviations">abbreviations</A>, etc. Applies only if
Vim is compiled with the |<A HREF="various.html#+rightleft">+rightleft</A>| feature and the
<A HREF="options.html#'allowrevins'">'allowrevins'</A> option is set.
See |<A HREF="rileft.html">rileft.txt</A>|.
<A HREF="motion.html#b">b</A> - switch between <A HREF="farsi.html#Farsi">Farsi</A> and English keyboard mode, which is
private to the command-line and not related to fkmap. In
<A HREF="farsi.html#Farsi">Farsi</A> keyboard mode the characters are inserted in reverse
insert manner. This is useful when <A HREF="farsi.html#Farsi">Farsi</A> text entry is
required in the command-line, searches, <A HREF="map.html#abbreviations">abbreviations</A>, etc.
Applies only if Vim is compiled with the |<A HREF="various.html#+farsi">+farsi</A>| feature.
See |<A HREF="farsi.html">farsi.txt</A>|.
*<A NAME="c_CTRL-^"></A><B>c_CTRL-^</B>*
<A HREF="editing.html#CTRL-^">CTRL-^</A> Toggle the use of language |<A HREF="map.html#:lmap">:lmap</A>| mappings and/or Input
Method.
When typing a <A HREF="pattern.html#pattern">pattern</A> for a search command and <A HREF="options.html#'imsearch'">'imsearch'</A> is
not -1, VAL is the value of <A HREF="options.html#'imsearch'">'imsearch'</A>, otherwise VAL is the
value of <A HREF="options.html#'iminsert'">'iminsert'</A>.
When language mappings are defined:
- If VAL is 1 (langmap mappings used) <A HREF="motion.html#it">it</A> becomes 0 (no langmap
mappings used).
- If VAL was not 1 <A HREF="motion.html#it">it</A> becomes 1, thus langmap mappings are
enabled.
When no language mappings are defined:
- If VAL is 2 (Input Method is used) <A HREF="motion.html#it">it</A> becomes 0 (no input
method used)
- If VAL has another value <A HREF="motion.html#it">it</A> becomes 2, thus the Input Method
is enabled.
These language mappings are normally used to type characters
that are different from what the keyboard produces. The
<A HREF="options.html#'keymap'">'keymap'</A> option can be used to <A HREF="usr_90.html#install">install</A> a whole number of them.
When entering a command line, langmap mappings are switched
off, since you are expected to type a command. After
switching <A HREF="motion.html#it">it</A> on with <A HREF="editing.html#CTRL-^">CTRL-^</A>, the new state is not used again
for the next command or Search <A HREF="pattern.html#pattern">pattern</A>.
{not in Vi}
*<A NAME="c_CTRL-]"></A><B>c_CTRL-]</B>*
<A HREF="tagsrch.html#CTRL-]">CTRL-]</A> Trigger abbreviation, without <A HREF="insert.html#inserting">inserting</A> a character. {not in
Vi}
For Emacs-style editing on the command-line see |<A HREF="tips.html#emacs-keys">emacs-keys</A>|.
The <A HREF="motion.html#<Up>"><Up></A> and <A HREF="motion.html#<Down>"><Down></A> keys take the current command-line <A HREF="motion.html#as">as</A> a search <A HREF="eval.html#string">string</A>.
The beginning of the next/previous command-lines are compared with this
<A HREF="eval.html#string">string</A>. The first line that matches is the new command-line. When typing
these two keys repeatedly, the same <A HREF="eval.html#string">string</A> is used again. For example, this
can be used to find the previous substitute command: Type "<A HREF="change.html#:s">:s</A>" and then <A HREF="motion.html#<Up>"><Up></A>.
The same could be done by typing <A HREF="scroll.html#<S-Up>"><S-Up></A> a number of times until the desired
command-line is shown. (Note: the shifted arrow keys <A HREF="diff.html#do">do</A> not work on all
terminals)
*<A NAME=":his"></A><B>:his</B>* *<A NAME=":history"></A><B>:history</B>*
:his[tory] Print the <A HREF="#history">history</A> of last entered commands.
{not in Vi}
{not available when compiled without the |<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>|
feature}
:his[tory] [{name}] [{first}][, [{last}]]
<A HREF="eval.html#List">List</A> the contents of <A HREF="#history">history</A> {name} which can be:
c[md] or : command-line <A HREF="#history">history</A>
s[earch] or / or ? search <A HREF="eval.html#string">string</A> <A HREF="#history">history</A>
e[xpr] or = <A HREF="eval.html#expression">expression</A> <A HREF="sponsor.html#register">register</A> <A HREF="#history">history</A>
i[nput] or @ input line <A HREF="#history">history</A>
d[ebug] or <A HREF="change.html#>">></A> debug command <A HREF="#history">history</A>
a[ll] all of the above
{not in Vi}
If the numbers {first} and/or {last} are given, the respective
range of entries from a <A HREF="#history">history</A> is listed. These numbers can
be specified in the following form:
*<A NAME=":history-indexing"></A><B>:history-indexing</B>*
A positive number represents the absolute index of an entry
<A HREF="motion.html#as">as</A> <A HREF="motion.html#it">it</A> is given in the first column of a <A HREF="#:history">:history</A> listing.
This number remains fixed even if other entries are deleted.
A negative number means the relative position of an entry,
counted from the newest entry (which has index -1) backwards.
Examples:
<A HREF="eval.html#List">List</A> entries 6 to 12 from the search <A HREF="#history">history</A>:
<B> :history / 6,12</B>
<A HREF="eval.html#List">List</A> the penultimate entry from all histories:
<B> :history all -2</B>
<A HREF="eval.html#List">List</A> the most recent two entries from all histories:
<B> :history all -2,</B>
:keepp[atterns] {command} *<A NAME=":keepp"></A><B>:keepp</B>* *<A NAME=":keeppatterns"></A><B>:keeppatterns</B>*
Execute {command}, without adding anything to the search
<A HREF="#history">history</A>
==============================================================================
2. <A HREF="#Command-line">Command-line</A> completion *<A NAME="cmdline-completion"></A><B>cmdline-completion</B>*
When editing the command-line, a few commands can be used to complete the
<A HREF="motion.html#word">word</A> before the cursor. This is available for:
- Command names: At the start of the command-line.
- Tags: Only after the "<A HREF="tagsrch.html#:tag">:tag</A>" command.
- File names: Only after a command that accepts a file name or a setting for
an option that can be set to a file name. This is called file name
completion.
- Shell command names: After "<A HREF="various.html#:!cmd">:!cmd</A>", "<A HREF="insert.html#:r">:r</A> !cmd" and "<A HREF="editing.html#:w">:w</A> !cmd". $PATH is used.
- Options: Only after the "<A HREF="options.html#:set">:set</A>" command.
- Mappings: Only after a "<A HREF="map.html#:map">:map</A>" or similar command.
- Variable and function names: Only after a "<A HREF="eval.html#:if">:if</A>", "<A HREF="eval.html#:call">:call</A>" or similar command.
When Vim was compiled without the |<A HREF="various.html#+cmdline_compl">+cmdline_compl</A>| feature only file names,
directories and help items can be completed. The number of help item matches
is limited (currently to 300) to avoid a long delay when there are very many
matches.
These are the commands that can be used:
*<A NAME="c_CTRL-D"></A><B>c_CTRL-D</B>*
<A HREF="scroll.html#CTRL-D">CTRL-D</A> <A HREF="eval.html#List">List</A> names that match the <A HREF="pattern.html#pattern">pattern</A> in front of the cursor.
When showing file names, directories are highlighted (see
<A HREF="options.html#'highlight'">'highlight'</A> option). Names where <A HREF="options.html#'suffixes'">'suffixes'</A> matches are moved
to the end.
The <A HREF="options.html#'wildoptions'">'wildoptions'</A> option can be set to "tagfile" to <A HREF="eval.html#list">list</A> the
file of matching <A HREF="tagsrch.html#tags">tags</A>.
*<A NAME="c_CTRL-I"></A><B>c_CTRL-I</B>* *<A NAME="c_wildchar"></A><B>c_wildchar</B>* *<A NAME="c_<Tab>"></A><B>c_<Tab></B>*
<A HREF="options.html#'wildchar'">'wildchar'</A> option
A match is done on the <A HREF="pattern.html#pattern">pattern</A> in front of the cursor. The
match (if there are several, the first match) is inserted
in place of the <A HREF="pattern.html#pattern">pattern</A>. (Note: does not work inside a
<A HREF="map.html#macro">macro</A>, because <A HREF="motion.html#<Tab>"><Tab></A> or <A HREF="intro.html#<Esc>"><Esc></A> are mostly used <A HREF="motion.html#as">as</A> <A HREF="options.html#'wildchar'">'wildchar'</A>,
and these have a special meaning in some macros.) When typed
again and there were multiple matches, the next
match is inserted. After the last match, the first is used
again (wrap around).
The behavior can be changed with the <A HREF="options.html#'wildmode'">'wildmode'</A> option.
*<A NAME="c_CTRL-N"></A><B>c_CTRL-N</B>*
<A HREF="motion.html#CTRL-N">CTRL-N</A> After using <A HREF="options.html#'wildchar'">'wildchar'</A> which got multiple matches, go to next
match. Otherwise recall more recent command-line from <A HREF="#history">history</A>.
<A HREF="term.html#<S-Tab>"><S-Tab></A> *<A NAME="c_CTRL-P"></A><B>c_CTRL-P</B>* *<A NAME="c_<S-Tab>"></A><B>c_<S-Tab></B>*
<A HREF="motion.html#CTRL-P">CTRL-P</A> After using <A HREF="options.html#'wildchar'">'wildchar'</A> which got multiple matches, go to
previous match. Otherwise recall older command-line from
<A HREF="#history">history</A>. <A HREF="term.html#<S-Tab>"><S-Tab></A> only works with the <A HREF="gui.html#GUI">GUI</A>, on the <A HREF="os_amiga.html#Amiga">Amiga</A> and
with <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>.
*<A NAME="c_CTRL-A"></A><B>c_CTRL-A</B>*
<A HREF="change.html#CTRL-A">CTRL-A</A> All names that match the <A HREF="pattern.html#pattern">pattern</A> in front of the cursor are
inserted.
*<A NAME="c_CTRL-L"></A><B>c_CTRL-L</B>*
<A HREF="various.html#CTRL-L">CTRL-L</A> A match is done on the <A HREF="pattern.html#pattern">pattern</A> in front of the cursor. If
there is one match, <A HREF="motion.html#it">it</A> is inserted in place of the <A HREF="pattern.html#pattern">pattern</A>.
If there are multiple matches the longest common part is
inserted in place of the <A HREF="pattern.html#pattern">pattern</A>. If the result is shorter
than the <A HREF="pattern.html#pattern">pattern</A>, no completion is done.
*<A NAME="/_CTRL-L"></A><B>/_CTRL-L</B>*
When <A HREF="options.html#'incsearch'">'incsearch'</A> is set, entering a search <A HREF="pattern.html#pattern">pattern</A> for "<A HREF="pattern.html#/">/</A>" or
"<A HREF="pattern.html#?">?</A>" and the current match is displayed then <A HREF="various.html#CTRL-L">CTRL-L</A> will add
one character from the end of the current match. If
<A HREF="options.html#'ignorecase'">'ignorecase'</A> and <A HREF="options.html#'smartcase'">'smartcase'</A> are set and the command line has
no <A HREF="change.html#uppercase">uppercase</A> characters, the added character is converted to
<A HREF="change.html#lowercase">lowercase</A>.
*<A NAME="c_CTRL-G"></A><B>c_CTRL-G</B>* *<A NAME="/_CTRL-G"></A><B>/_CTRL-G</B>*
<A HREF="editing.html#CTRL-G">CTRL-G</A> When <A HREF="options.html#'incsearch'">'incsearch'</A> is set, entering a search <A HREF="pattern.html#pattern">pattern</A> for "<A HREF="pattern.html#/">/</A>" or
"<A HREF="pattern.html#?">?</A>" and the current match is displayed then <A HREF="editing.html#CTRL-G">CTRL-G</A> will move
to the next match (does not take |<A HREF="pattern.html#search-offset">search-offset</A>| into account)
Use <A HREF="tagsrch.html#CTRL-T">CTRL-T</A> to move to the previous match. Hint: on a regular
keyboard <A HREF="motion.html#T">T</A> is above <A HREF="motion.html#G">G</A>.
*<A NAME="c_CTRL-T"></A><B>c_CTRL-T</B>* *<A NAME="/_CTRL-T"></A><B>/_CTRL-T</B>*
<A HREF="tagsrch.html#CTRL-T">CTRL-T</A> When <A HREF="options.html#'incsearch'">'incsearch'</A> is set, entering a search <A HREF="pattern.html#pattern">pattern</A> for "<A HREF="pattern.html#/">/</A>" or
"<A HREF="pattern.html#?">?</A>" and the current match is displayed then <A HREF="tagsrch.html#CTRL-T">CTRL-T</A> will move
to the previous match (does not take |<A HREF="pattern.html#search-offset">search-offset</A>| into
account).
Use <A HREF="editing.html#CTRL-G">CTRL-G</A> to move to the next match. Hint: on a regular
keyboard <A HREF="motion.html#T">T</A> is above <A HREF="motion.html#G">G</A>.
The <A HREF="options.html#'wildchar'">'wildchar'</A> option defaults to <A HREF="motion.html#<Tab>"><Tab></A> (CTRL-E when in <A HREF="intro.html#Vi">Vi</A> compatible mode; in
a previous version <A HREF="intro.html#<Esc>"><Esc></A> was used). In the <A HREF="pattern.html#pattern">pattern</A> standard <A HREF="editing.html#wildcards">wildcards</A> '*' and
'<A HREF="pattern.html#?">?</A>' are accepted when matching file names. '*' matches any <A HREF="eval.html#string">string</A>, '<A HREF="pattern.html#?">?</A>'
matches exactly one character.
The <A HREF="options.html#'wildignorecase'">'wildignorecase'</A> option can be set to ignore <A HREF="change.html#case">case</A> in filenames.
The <A HREF="options.html#'wildmenu'">'wildmenu'</A> option can be set to show the matches just above the command
line.
If you like tcsh's autolist completion, you can use this <A HREF="map.html#mapping">mapping</A>:
<A HREF="map.html#:cnoremap">:cnoremap</A> X <C-L><C-D>
(Where X is the command key to use, <C-L> is <A HREF="various.html#CTRL-L">CTRL-L</A> and <C-D> is <A HREF="scroll.html#CTRL-D">CTRL-D</A>)
This will find the longest match and then <A HREF="eval.html#list">list</A> all matching files.
If you like tcsh's autolist completion, you can use the <A HREF="options.html#'wildmode'">'wildmode'</A> option to
emulate <A HREF="motion.html#it">it</A>. For example, this mimics autolist=ambiguous:
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'wildmode'">wildmode</A>=longest,list
This will find the longest match with the first <A HREF="options.html#'wildchar'">'wildchar'</A>, then <A HREF="eval.html#list">list</A> all
matching files with the next.
*<A NAME="suffixes"></A><B>suffixes</B>*
For file name completion you can use the <A HREF="options.html#'suffixes'">'suffixes'</A> option to set a priority
between files with almost the same name. If there are multiple matches,
those files with an extension that is in the <A HREF="options.html#'suffixes'">'suffixes'</A> option are ignored.
The default is ".bak,~,.o,.h,.info,.swp,.obj", which means that files ending
in ".bak", "<A HREF="change.html#~">~</A>", ".o", ".h", ".info", ".swp" and ".obj" are sometimes ignored.
An empty entry, two consecutive commas, match a file name that does not
contain a "<A HREF="repeat.html#.">.</A>", thus has no suffix. This is useful to ignore "prog" and prefer
"prog.c".
Examples:
<B><FONT COLOR="PURPLE"> pattern: files: match: </FONT></B>
test* test.c test.h test.o test.c
test* test.h test.o test.h and test.o
test* test.i test.h test.c test.i and test.c
It is impossible to ignore <A HREF="#suffixes">suffixes</A> with two dots.
If there is more than one matching file (after ignoring the ones matching
the <A HREF="options.html#'suffixes'">'suffixes'</A> option) the first file name is inserted. You can see that
there is only one match when you type <A HREF="options.html#'wildchar'">'wildchar'</A> <A HREF="if_cscop.html#twice">twice</A> and the completed
match stays the same. You can get to the other matches by entering
<A HREF="options.html#'wildchar'">'wildchar'</A>, <A HREF="motion.html#CTRL-N">CTRL-N</A> or <A HREF="motion.html#CTRL-P">CTRL-P</A>. All files are included, also the ones with
extensions matching the <A HREF="options.html#'suffixes'">'suffixes'</A> option.
To completely ignore files with some extension use <A HREF="options.html#'wildignore'">'wildignore'</A>.
To match only files that end at the end of the typed text append a "<A HREF="motion.html#$">$</A>". For
example, to match only files that end in ".c":
<B> :e *.c$</B>
This will not match a file ending in ".cpp". Without the "<A HREF="motion.html#$">$</A>" <A HREF="motion.html#it">it</A> does match.
The old value of an option can be obtained by hitting <A HREF="options.html#'wildchar'">'wildchar'</A> just after
the '<A HREF="change.html#=">=</A>'. For example, typing <A HREF="options.html#'wildchar'">'wildchar'</A> after "<A HREF="options.html#:set">:set</A> <A HREF="options.html#'dir'">dir</A>=" will insert the
current value of <A HREF="options.html#'dir'">'dir'</A>. This overrules file name completion for the <A HREF="options.html#options">options</A>
that take a file name.
If you would like using <A HREF="term.html#<S-Tab>"><S-Tab></A> for <A HREF="motion.html#CTRL-P">CTRL-P</A> in an xterm, put this command in
your .cshrc:
<B> xmodmap -e "keysym Tab = Tab Find"</B>
And this in your <A HREF="starting.html#.vimrc">.vimrc</A>:
<B> :cmap <Esc>[1~ <C-P></B>
==============================================================================
3. <A HREF="intro.html#Ex">Ex</A> command-lines *<A NAME="cmdline-lines"></A><B>cmdline-lines</B>*
The <A HREF="intro.html#Ex">Ex</A> commands have a few specialties:
*<A NAME=":quote"></A><B>:quote</B>* *<A NAME=":comment"></A><B>:comment</B>*
'"'' at the start of a line causes the whole line to be ignored. '"''
after a command causes the rest of the line to be ignored. This can be used
to add comments. Example:
<B> :set ai "set 'autoindent' option</B>
It is not possible to add a comment to a shell command "<A HREF="various.html#:!cmd">:!cmd</A>" or to the
"<A HREF="map.html#:map">:map</A>" command and a few others, because they see the '"'' <A HREF="motion.html#as">as</A> part of their
argument. This is mentioned where the command is explained.
*<A NAME=":bar"></A><B>:bar</B>* *<A NAME=":\bar"></A><B>:\bar</B>*
'|' can be used to separate commands, so you can give multiple commands in one
line. If you want to use '|' in an argument, precede <A HREF="motion.html#it">it</A> with '\'.
These commands see the '|' <A HREF="motion.html#as">as</A> their argument, and can therefore not be
followed by another Vim command:
<A HREF="editing.html#:argdo">:argdo</A>
<A HREF="autocmd.html#:autocmd">:autocmd</A>
<A HREF="windows.html#:bufdo">:bufdo</A>
<A HREF="quickfix.html#:cdo">:cdo</A>
<A HREF="quickfix.html#:cfdo">:cfdo</A>
<A HREF="map.html#:command">:command</A>
<A HREF="if_cscop.html#:cscope">:cscope</A>
<A HREF="repeat.html#:debug">:debug</A>
<A HREF="fold.html#:folddoopen">:folddoopen</A>
<A HREF="fold.html#:folddoclosed">:folddoclosed</A>
<A HREF="eval.html#:function">:function</A>
<A HREF="repeat.html#:global">:global</A>
<A HREF="helphelp.html#:help">:help</A>
<A HREF="helphelp.html#:helpfind">:helpfind</A>
<A HREF="if_cscop.html#:lcscope">:lcscope</A>
<A HREF="quickfix.html#:ldo">:ldo</A>
<A HREF="quickfix.html#:lfdo">:lfdo</A>
<A HREF="quickfix.html#:make">:make</A>
<A HREF="various.html#:normal">:normal</A>
<A HREF="if_perl.html#:perl">:perl</A>
<A HREF="if_perl.html#:perldo">:perldo</A>
<A HREF="change.html#:promptfind">:promptfind</A>
<A HREF="change.html#:promptrepl">:promptrepl</A>
<A HREF="if_pyth.html#:pyfile">:pyfile</A>
<A HREF="if_pyth.html#:python">:python</A>
<A HREF="change.html#:registers">:registers</A>
<A HREF="insert.html#:read">:read</A> !
<A HREF="if_cscop.html#:scscope">:scscope</A>
<A HREF="sign.html#:sign">:sign</A>
<A HREF="if_tcl.html#:tcl">:tcl</A>
<A HREF="if_tcl.html#:tcldo">:tcldo</A>
<A HREF="if_tcl.html#:tclfile">:tclfile</A>
<A HREF="repeat.html#:vglobal">:vglobal</A>
<A HREF="windows.html#:windo">:windo</A>
<A HREF="editing.html#:write">:write</A> !
<A HREF="motion.html#:[range]">:[range]</A>!
a user defined command without the "-bar" argument |<A HREF="map.html#:command">:command</A>|
Note that this is confusing (inherited from Vi): With "<A HREF="repeat.html#:g">:g</A>" the '|' is included
in the command, with "<A HREF="change.html#:s">:s</A>" <A HREF="motion.html#it">it</A> is not.
To be able to use another command anyway, use the "<A HREF="eval.html#:execute">:execute</A>" command.
Example (append the output of "ls" and jump to the first line):
<B> :execute 'r !ls' | '[</B>
There is one exception: When the '<A HREF="motion.html#b">b</A>' flag is present in <A HREF="options.html#'cpoptions'">'cpoptions'</A>, with the
"<A HREF="map.html#:map">:map</A>" and ":abbr" commands and friends <A HREF="visual.html#CTRL-V">CTRL-V</A> needs to be used instead of
'\'. You can also use "<A HREF="intro.html#<Bar>"><Bar></A>" instead. See also |<A HREF="map.html#map_bar">map_bar</A>|.
Examples:
<B> :!ls | wc view the output of two commands</B>
<B> :r !ls | wc insert the same output in the text</B>
<B> :%g/foo/p|> moves all matching lines one shiftwidth</B>
<B> :%s/foo/bar/|> moves one line one shiftwidth</B>
<B> :map q 10^V| map "q" to "10|"</B>
<B> :map q 10\| map \ l map "q" to "10\" and map "\" to "l"</B>
<B> (when 'b' is present in 'cpoptions')</B>
You can also use <A HREF="motion.html#<NL>"><NL></A> to separate commands in the same way <A HREF="motion.html#as">as</A> with '|'. To
insert a <A HREF="motion.html#<NL>"><NL></A> use <A HREF="visual.html#CTRL-V">CTRL-V</A> <A HREF="motion.html#CTRL-J">CTRL-J</A>. "^@" will be shown. Using '|' is the
preferred method. But for external commands a <A HREF="motion.html#<NL>"><NL></A> must be used, because a
'|' is included in the external command. To avoid the special meaning of <A HREF="motion.html#<NL>"><NL></A>
<A HREF="motion.html#it">it</A> must be preceded with a <A HREF="intro.html#backslash">backslash</A>. Example:
<B> :r !date<NL>-join</B>
This reads the current date into the file and joins <A HREF="motion.html#it">it</A> with the previous line.
Note that when the command before the '|' generates an error, the following
commands will not be executed.
Because of <A HREF="intro.html#Vi">Vi</A> compatibility the following strange commands are supported:
<B> :| print current line (like ":p")</B>
<B> :3| print line 3 (like ":3p")</B>
<B> :3 goto line 3</B>
A colon is allowed between the range and the command name. It is ignored
(this is <A HREF="intro.html#Vi">Vi</A> compatible). For example:
<B> :1,$:s/pat/string</B>
When the character '<A HREF="motion.html#%">%</A>' or '<A HREF="pattern.html##">#</A>' is used where a file name is expected, they are
expanded to the current and alternate file name (see the chapter "editing
files" |<A HREF="#:_%">:_%</A>| |<A HREF="#:_#">:_#</A>|).
Embedded spaces in file names are allowed on the <A HREF="os_amiga.html#Amiga">Amiga</A> if one file name is
expected <A HREF="motion.html#as">as</A> argument. Trailing spaces will be ignored, unless escaped with a
<A HREF="intro.html#backslash">backslash</A> or <A HREF="visual.html#CTRL-V">CTRL-V</A>. Note that the "<A HREF="editing.html#:next">:next</A>" command uses spaces to separate
file names. Escape the spaces to include them in a file name. Example:
<B> :next foo\ bar goes\ to school\</B>
starts editing the three files "foo bar", "goes to" and "school ".
When you want to use the special characters '"'' or '|' in a command, or want
to use '<A HREF="motion.html#%">%</A>' or '<A HREF="pattern.html##">#</A>' in a file name, precede them with a <A HREF="intro.html#backslash">backslash</A>. The
<A HREF="intro.html#backslash">backslash</A> is not required in a range and in the "<A HREF="change.html#:substitute">:substitute</A>" command.
See also |<A HREF="editing.html#`=">`=</A>|.
*<A NAME=":_!"></A><B>:_!</B>*
The '<A HREF="change.html#!">!</A>' (bang) character after an <A HREF="intro.html#Ex">Ex</A> command makes the command behave in a
different way. The '<A HREF="change.html#!">!</A>' should be placed immediately after the command, without
any blanks in between. If you insert blanks the '<A HREF="change.html#!">!</A>' will be seen <A HREF="motion.html#as">as</A> an
argument for the command, which has a different meaning. For example:
<A HREF="editing.html#:w!">:w!</A> name write the current buffer to file "name", overwriting
any existing file
<A HREF="editing.html#:w">:w</A> !name send the current buffer <A HREF="motion.html#as">as</A> standard input to command
"name"
==============================================================================
4. <A HREF="intro.html#Ex">Ex</A> command-line ranges *<A NAME="cmdline-ranges"></A><B>cmdline-ranges</B>* *<A NAME="[range]"></A><B>[range]</B>* *<A NAME="E16"></A><B>E16</B>*
Some <A HREF="intro.html#Ex">Ex</A> commands accept a line range in front of them. This is noted <A HREF="motion.html#as">as</A>
<A HREF="#[range]">[range]</A>. It consists of one or more line specifiers, separated with '<A HREF="motion.html#,">,</A>' or
'<A HREF="motion.html#;">;</A>'.
The basics are explained in section |<A HREF="usr_10.html#10.3">10.3</A>| of the user manual.
*<A NAME=":,"></A><B>:,</B>* *<A NAME=":;"></A><B>:;</B>*
When separated with '<A HREF="motion.html#;">;</A>' the cursor position will be set to that line
before interpreting the next line specifier. This doesn't happen for '<A HREF="motion.html#,">,</A>'.
Examples:
<B> 4,/this line/</B>
from line 4 till match with "this line" after the cursor line.
<B> 5;/that line/</B>
from line 5 till match with "that line" after line 5.
The default line specifier for most commands is the cursor position, but the
commands "<A HREF="editing.html#:write">:write</A>" and "<A HREF="repeat.html#:global">:global</A>" have the whole file (1,$) <A HREF="motion.html#as">as</A> default.
If more line specifiers are given than required for the command, the first
one(s) will be ignored.
Line numbers may be specified with: *<A NAME=":range"></A><B>:range</B>* *<A NAME="E14"></A><B>E14</B>* *<A NAME="{address}"></A><B>{address}</B>*
{number} an absolute line number
. the current line *<A NAME=":."></A><B>:.</B>*
$ the last line in the file *<A NAME=":$"></A><B>:$</B>*
<A HREF="motion.html#%">%</A> equal to 1,$ (the entire file) *<A NAME=":%"></A><B>:%</B>*
't position of <A HREF="motion.html#mark">mark</A> t (lowercase) *<A NAME=":'"></A><B>:'</B>*
'T position of <A HREF="motion.html#mark">mark</A> <A HREF="motion.html#T">T</A> (uppercase); when the <A HREF="motion.html#mark">mark</A> is in
another file <A HREF="motion.html#it">it</A> cannot be used in a range
/{pattern}[/] the next line where {pattern} matches *<A NAME=":/"></A><B>:/</B>*
?{pattern}[?] the previous line where {pattern} matches *<A NAME=":?"></A><B>:?</B>*
\/ the next line where the previously used search
<A HREF="pattern.html#pattern">pattern</A> matches
\? the previous line where the previously used search
<A HREF="pattern.html#pattern">pattern</A> matches
\& the next line where the previously used substitute
<A HREF="pattern.html#pattern">pattern</A> matches
Each may be followed (several times) by '<A HREF="motion.html#+">+</A>' or '<A HREF="motion.html#-">-</A>' and an optional number.
This number is added or subtracted from the preceding line number. If the
number is omitted, 1 is used.
The "<A HREF="pattern.html#/">/</A>" and "<A HREF="pattern.html#?">?</A>" after {pattern} are required to separate the <A HREF="pattern.html#pattern">pattern</A> from
anything that follows.
The "<A HREF="pattern.html#/">/</A>" and "<A HREF="pattern.html#?">?</A>" may be preceded with another address. The search starts from
there. The difference from using '<A HREF="motion.html#;">;</A>' is that the cursor isn't moved.
Examples:
<B> /pat1//pat2/ Find line containing "pat2" after line containing</B>
<B> "pat1", without moving the cursor.</B>
<B> 7;/pat2/ Find line containing "pat2", after line 7, leaving</B>
<B> the cursor in line 7.</B>
The {number} must be between 0 and the number of lines in the file. When
using a 0 (zero) this is interpreted <A HREF="motion.html#as">as</A> a 1 by most commands. Commands that
use <A HREF="motion.html#it">it</A> <A HREF="motion.html#as">as</A> a <A HREF="intro.html#count">count</A> <A HREF="diff.html#do">do</A> use <A HREF="motion.html#it">it</A> <A HREF="motion.html#as">as</A> a zero (|<A HREF="tagsrch.html#:tag">:tag</A>|, |<A HREF="tagsrch.html#:pop">:pop</A>|, etc). Some commands
interpret the zero <A HREF="motion.html#as">as</A> "before the first line" (|<A HREF="insert.html#:read">:read</A>|, search <A HREF="pattern.html#pattern">pattern</A>, etc).
Examples:
<B> .+3 three lines below the cursor</B>
<B> /that/+1 the line below the next line containing "that"</B>
<B> .,$ from current line until end of file</B>
<B> 0;/that the first line containing "that", also matches in the</B>
<B> first line.</B>
<B> 1;/that the first line after line 1 containing "that"</B>
Some commands allow for a <A HREF="intro.html#count">count</A> after the command. This <A HREF="intro.html#count">count</A> is used <A HREF="motion.html#as">as</A> the
number of lines to be used, starting with the line given in the last line
specifier (the default is the cursor line). The commands that accept a <A HREF="intro.html#count">count</A>
are the ones that use a range but <A HREF="diff.html#do">do</A> not have a file name argument (because
a file name can also be a number).
Examples:
<B> :s/x/X/g 5 substitute 'x' by 'X' in the current line and four</B>
<B> following lines</B>
<B> :23d 4 delete lines 23, 24, 25 and 26</B>
Folds and Range
When <A HREF="fold.html#folds">folds</A> are active the line numbers are rounded off to include the whole
closed fold. See |<A HREF="fold.html#fold-behavior">fold-behavior</A>|.
Reverse Range *<A NAME="E493"></A><B>E493</B>*
A range should have the lower line number first. If this is not the <A HREF="change.html#case">case</A>, Vim
will ask you if <A HREF="motion.html#it">it</A> should swap the line numbers.
<B><FONT COLOR="PURPLE"> Backwards range given, OK to swap </FONT></B>
This is not done within the global command "<A HREF="repeat.html#:g">:g</A>".
You can use "<A HREF="various.html#:silent">:silent</A>" before a command to avoid the question, the range will
always be swapped then.
Count and Range *<A NAME="N:"></A><B>N:</B>*
When giving a <A HREF="intro.html#count">count</A> before entering "<A HREF="#:">:</A>", this is translated into:
:.,.+(count - 1)
In words: The '<A HREF="intro.html#count">count</A>' lines at and after the cursor. Example: To delete
three lines:
<B> 3:d<CR> is translated into: .,.+2d<CR></B>
<A HREF="visual.html#Visual">Visual</A> Mode and Range *<A NAME="v_:"></A><B>v_:</B>*
<A HREF="intro.html#{Visual}">{Visual}</A>: Starts a command-line with the <A HREF="visual.html#Visual">Visual</A> selected lines <A HREF="motion.html#as">as</A> a
range. The code `:'<,'>` is used for this range, which makes
<A HREF="motion.html#it">it</A> possible to select a similar line from the command-line
<A HREF="#history">history</A> for <A HREF="repeat.html#repeating">repeating</A> a command on different Visually selected
lines.
When <A HREF="visual.html#Visual">Visual</A> mode was already ended, a short way to use the
<A HREF="visual.html#Visual">Visual</A> area for a range is `:*`. This requires that "*" does
not appear in <A HREF="options.html#'cpo'">'cpo'</A>, see |<A HREF="options.html#cpo-star">cpo-star</A>|. Otherwise you will have
to type `:'<,'>`
==============================================================================
5. <A HREF="intro.html#Ex">Ex</A> command-line flags *<A NAME="ex-flags"></A><B>ex-flags</B>*
These flags are supported by a selection of <A HREF="intro.html#Ex">Ex</A> commands. They print the line
that the cursor ends up after executing the command:
l output like for |<A HREF="various.html#:list">:list</A>|
# add line number
p output like for |<A HREF="various.html#:print">:print</A>|
The flags can be combined, thus "l#" uses both a line number and |<A HREF="various.html#:list">:list</A>| style
output.
==============================================================================
6. <A HREF="intro.html#Ex">Ex</A> special characters *<A NAME="cmdline-special"></A><B>cmdline-special</B>*
Note: These are special characters in the executed command line. If you want
to insert special things while typing you can use the <A HREF="undo.html#CTRL-R">CTRL-R</A> command. For
example, "<A HREF="motion.html#%">%</A>" stands for the current file name, while <A HREF="undo.html#CTRL-R">CTRL-R</A> <A HREF="motion.html#%">%</A> inserts the
current file name right away. See |<A HREF="#c_CTRL-R">c_CTRL-R</A>|.
Note: If you want to avoid the effects of special characters in a Vim <A HREF="usr_41.html#script">script</A>
you may want to use |<A HREF="eval.html#fnameescape()">fnameescape()</A>|. Also see |<A HREF="editing.html#`=">`=</A>|.
In <A HREF="intro.html#Ex">Ex</A> commands, at places where a file name can be used, the following
characters have a special meaning. These can also be used in the <A HREF="eval.html#expression">expression</A>
function |<A HREF="eval.html#expand()">expand()</A>|.
<A HREF="motion.html#%">%</A> Is replaced with the current file name. *<A NAME=":_%"></A><B>:_%</B>* *<A NAME="c_%"></A><B>c_%</B>*
# Is replaced with the alternate file name. *<A NAME=":_#"></A><B>:_#</B>* *<A NAME="c_#"></A><B>c_#</B>*
This is remembered for every <A HREF="windows.html#window">window</A>.
#n (where <A HREF="pattern.html#n">n</A> is a number) is replaced with *<A NAME=":_#0"></A><B>:_#0</B>* *<A NAME=":_#n"></A><B>:_#n</B>*
the file name of buffer <A HREF="pattern.html#n">n</A>. "#0" is the same <A HREF="motion.html#as">as</A> "<A HREF="pattern.html##">#</A>". *<A NAME="c_#n"></A><B>c_#n</B>*
## Is replaced with all names in the argument <A HREF="eval.html#list">list</A> *<A NAME=":_##"></A><B>:_##</B>* *<A NAME="c_##"></A><B>c_##</B>*
concatenated, separated by spaces. Each space in a name
is preceded with a <A HREF="intro.html#backslash">backslash</A>.
#<n (where <A HREF="pattern.html#n">n</A> is a number <A HREF="change.html#>">></A> 0) is replaced with old *<A NAME=":_#<"></A><B>:_#<</B>* *<A NAME="c_#<"></A><B>c_#<</B>*
file name <A HREF="pattern.html#n">n</A>. See |<A HREF="starting.html#:oldfiles">:oldfiles</A>| or |<A HREF="eval.html#v:oldfiles">v:oldfiles</A>| to get the
number. *<A NAME="E809"></A><B>E809</B>*
{only when compiled with the |<A HREF="various.html#+eval">+eval</A>| and |<A HREF="various.html#+viminfo">+viminfo</A>| features}
Note that these, except "#<n", give the file name <A HREF="motion.html#as">as</A> <A HREF="motion.html#it">it</A> was typed. If an
absolute path is needed (when using the file name from a different directory),
you need to add "<A HREF="various.html#:p">:p</A>". See |<A HREF="#filename-modifiers">filename-modifiers</A>|.
The "#<n" item returns an absolute path, but <A HREF="motion.html#it">it</A> will start with "~/" for files
below your home directory.
Note that backslashes are inserted before spaces, so that the command will
correctly interpret the file name. But this doesn't happen for shell
commands. For those you probably have to use <A HREF="quotes.html#quotes">quotes</A> (this fails for files
that contain a <A HREF="change.html#quote">quote</A> and wildcards):
<B> :!ls "%"</B>
<B> :r !spell "%"</B>
To avoid the special meaning of '<A HREF="motion.html#%">%</A>' and '<A HREF="pattern.html##">#</A>' insert a <A HREF="intro.html#backslash">backslash</A> before <A HREF="motion.html#it">it</A>.
Detail: The special meaning is always escaped when there is a <A HREF="intro.html#backslash">backslash</A> before
<A HREF="motion.html#it">it</A>, no matter how many backslashes.
<B><FONT COLOR="PURPLE"> you type: result </FONT></B>
# alternate.file
\# #
\\# \#
Also see |<A HREF="editing.html#`=">`=</A>|.
*<A NAME=":<cword>"></A><B>:<cword></B>* *<A NAME=":<cWORD>"></A><B>:<cWORD></B>* *<A NAME=":<cfile>"></A><B>:<cfile></B>* *<A NAME="<cfile>"></A><B><cfile></B>*
*<A NAME=":<sfile>"></A><B>:<sfile></B>* *<A NAME="<sfile>"></A><B><sfile></B>* *<A NAME=":<afile>"></A><B>:<afile></B>* *<A NAME="<afile>"></A><B><afile></B>*
*<A NAME=":<abuf>"></A><B>:<abuf></B>* *<A NAME="<abuf>"></A><B><abuf></B>* *<A NAME=":<amatch>"></A><B>:<amatch></B>* *<A NAME="<amatch>"></A><B><amatch></B>*
*<A NAME=":<cexpr>"></A><B>:<cexpr></B>* *<A NAME="<cexpr>"></A><B><cexpr></B>*
*<A NAME="<slnum>"></A><B><slnum></B>* *<A NAME="E495"></A><B>E495</B>* *<A NAME="E496"></A><B>E496</B>* *<A NAME="E497"></A><B>E497</B>* *<A NAME="E499"></A><B>E499</B>* *<A NAME="E500"></A><B>E500</B>*
Note: these are typed literally, they are not special keys!
<cword> is replaced with the <A HREF="motion.html#word">word</A> under the cursor (like |<A HREF="pattern.html#star">star</A>|)
<cWORD> is replaced with the WORD under the cursor (see |<A HREF="motion.html#WORD">WORD</A>|)
<A HREF="#<cexpr>"><cexpr></A> is replaced with the <A HREF="motion.html#word">word</A> under the cursor, including more
to form a C <A HREF="eval.html#expression">expression</A>. E.g., when the cursor is on "arg"
of "ptr->arg" then the result is "ptr->arg"; when the
cursor is on "<A HREF="index.html#]">]</A>" of "list[idx]" then the result is
"list[idx]". This is used for |<A HREF="eval.html#v:beval_text">v:beval_text</A>|.
<A HREF="#<cfile>"><cfile></A> is replaced with the path name under the cursor (like what
|<A HREF="editing.html#gf">gf</A>| uses)
<A HREF="#<afile>"><afile></A> When executing autocommands, is replaced with the file name
of the buffer being manipulated, or the file for a read or
write.
<A HREF="#<abuf>"><abuf></A> When executing autocommands, is replaced with the currently
effective buffer number (for "<A HREF="insert.html#:r">:r</A> file" and "<A HREF="repeat.html#:so">:so</A> file" <A HREF="motion.html#it">it</A> is
the current buffer, the file being read/sourced is not in a
buffer).
<A HREF="#<amatch>"><amatch></A> When executing autocommands, is replaced with the match for
which this <A HREF="autocmd.html#autocommand">autocommand</A> was executed. It differs from
<A HREF="#<afile>"><afile></A> only when the file name isn't used to match with
(for <A HREF="autocmd.html#FileType">FileType</A>, <A HREF="autocmd.html#Syntax">Syntax</A> and <A HREF="autocmd.html#SpellFileMissing">SpellFileMissing</A> events).
<A HREF="#<sfile>"><sfile></A> When executing a "<A HREF="repeat.html#:source">:source</A>" command, is replaced with the
file name of the sourced file. *<A NAME="E498"></A><B>E498</B>*
When executing a function, is replaced with:
"function {function-name}[{lnum}]"
function call nesting is indicated like this:
"function {function-name1}[{lnum}]..{function-name2}[{lnum}]"
Note that <A HREF="#filename-modifiers">filename-modifiers</A> are useless when <A HREF="#<sfile>"><sfile></A> is
used inside a function.
<A HREF="#<slnum>"><slnum></A> When executing a "<A HREF="repeat.html#:source">:source</A>" command, is replaced with the
line number. *<A NAME="E842"></A><B>E842</B>*
When executing a function it's the line number relative to
the start of the function.
*<A NAME="filename-modifiers"></A><B>filename-modifiers</B>*
*<A NAME=":_%:"></A><B>:_%:</B>* *<A NAME="::8"></A><B>::8</B>* *<A NAME="::p"></A><B>::p</B>* *<A NAME="::."></A><B>::.</B>* *<A NAME="::~"></A><B>::~</B>* *<A NAME="::h"></A><B>::h</B>* *<A NAME="::t"></A><B>::t</B>* *<A NAME="::r"></A><B>::r</B>* *<A NAME="::e"></A><B>::e</B>* *<A NAME="::s"></A><B>::s</B>* *<A NAME="::gs"></A><B>::gs</B>* *<A NAME="::S"></A><B>::S</B>*
*<A NAME="%:8"></A><B>%:8</B>* *<A NAME="%:p"></A><B>%:p</B>* *<A NAME="%:."></A><B>%:.</B>* *<A NAME="%:~"></A><B>%:~</B>* *<A NAME="%:h"></A><B>%:h</B>* *<A NAME="%:t"></A><B>%:t</B>* *<A NAME="%:r"></A><B>%:r</B>* *<A NAME="%:e"></A><B>%:e</B>* *<A NAME="%:s"></A><B>%:s</B>* *<A NAME="%:gs"></A><B>%:gs</B>* *<A NAME="%:S"></A><B>%:S</B>*
The file name modifiers can be used after "<A HREF="motion.html#%">%</A>", "<A HREF="pattern.html##">#</A>", "#n", "<A HREF="#<cfile>"><cfile></A>", "<A HREF="#<sfile>"><sfile></A>",
"<A HREF="#<afile>"><afile></A>" or "<A HREF="#<abuf>"><abuf></A>". They are also used with the |<A HREF="eval.html#fnamemodify()">fnamemodify()</A>| function.
These are not available when Vim has been compiled without the |<A HREF="various.html#+modify_fname">+modify_fname</A>|
feature.
These modifiers can be given, in this order:
<A HREF="various.html#:p">:p</A> Make file name a full path. Must be the first modifier. Also
changes "~/" (and "~user/" for <A HREF="os_unix.html#Unix">Unix</A> and <A HREF="os_vms.html#VMS">VMS</A>) to the path for
the home directory. If the name is a directory a path
separator is added at the end. For a file name that does not
exist and does not have an absolute path the result is
unpredictable. On <A HREF="os_win32.html#MS-Windows">MS-Windows</A> an 8.3 filename is expanded to
the long name.
:8 Converts the path to 8.3 short format (currently only on
<A HREF="os_win32.html#MS-Windows">MS-Windows</A>). Will act on <A HREF="motion.html#as">as</A> much of a path that is an
existing path.
<A HREF="change.html#:~">:~</A> Reduce file name to be relative to the home directory, if
possible. File name is unmodified if <A HREF="motion.html#it">it</A> is not below the home
directory.
<A HREF="#:.">:.</A> Reduce file name to be relative to current directory, if
possible. File name is unmodified if <A HREF="motion.html#it">it</A> is not below the
current directory.
For maximum shortness, use ":~:.".
<A HREF="helphelp.html#:h">:h</A> Head of the file name (the last component and any separators
removed). Cannot be used with <A HREF="editing.html#:e">:e</A>, <A HREF="insert.html#:r">:r</A> or <A HREF="change.html#:t">:t</A>.
Can be repeated to remove several components at the end.
When the file name ends in a path separator, only the path
separator is removed. Thus ":p:h" on a directory name results
on the directory name itself (without trailing slash).
When the file name is an absolute path (starts with "<A HREF="pattern.html#/">/</A>" for
<A HREF="os_unix.html#Unix">Unix</A>; "x:\" for <A HREF="os_msdos.html#MS-DOS">MS-DOS</A>, WIN32, <A HREF="os_os2.html#OS/2">OS/2</A>; "drive:" for Amiga), that
part is not removed. When there is no head (path is relative
to current directory) the result is empty.
<A HREF="change.html#:t">:t</A> Tail of the file name (last component of the name). Must
precede any <A HREF="insert.html#:r">:r</A> or <A HREF="editing.html#:e">:e</A>.
<A HREF="insert.html#:r">:r</A> <A HREF="mbyte.html#Root">Root</A> of the file name (the last extension removed). When
there is only an extension (file name that starts with '<A HREF="repeat.html#.">.</A>',
e.g., ".vimrc"), <A HREF="motion.html#it">it</A> is not removed. Can be repeated to remove
several extensions (last one first).
<A HREF="editing.html#:e">:e</A> Extension of the file name. Only makes sense when used alone.
When there is no extension the result is empty.
When there is only an extension (file name that starts with
'.'), the result is empty. Can be repeated to include more
extensions. If there are not enough extensions (but at least
one) <A HREF="motion.html#as">as</A> much <A HREF="motion.html#as">as</A> possible are included.
:s?pat?sub?
Substitute the first occurrence of "pat" with "sub". This
works like the |<A HREF="change.html#:s">:s</A>| command. "pat" is a regular <A HREF="eval.html#expression">expression</A>.
Any character can be used for '<A HREF="pattern.html#?">?</A>', but <A HREF="motion.html#it">it</A> must not occur in
"pat" or "sub".
After this, the previous modifiers can be used again. For
example "<A HREF="various.html#:p">:p</A>", to make a full path after the substitution.
:gs?pat?sub?
Substitute all occurrences of "pat" with "sub". Otherwise
this works like "<A HREF="change.html#:s">:s</A>".
:S Escape special characters for use with a shell command (see
|<A HREF="eval.html#shellescape()">shellescape()</A>|). Must be the last one. Examples:
<B> :!dir <cfile>:S</B>
<B> :call system('chmod +w -- ' . expand('%:S'))</B>
Examples, when the file name is "src/version.c", current dir
"/home/mool/vim":
<B> :p /home/mool/vim/src/version.c</B>
<B> :p:. src/version.c</B>
<B> :p:~ ~/vim/src/version.c</B>
<B> :h src</B>
<B> :p:h /home/mool/vim/src</B>
<B> :p:h:h /home/mool/vim</B>
<B> :t version.c</B>
<B> :p:t version.c</B>
<B> :r src/version</B>
<B> :p:r /home/mool/vim/src/version</B>
<B> :t:r version</B>
<B> :e c</B>
<B> :s?version?main? src/main.c</B>
<B> :s?version?main?:p /home/mool/vim/src/main.c</B>
<B> :p:gs?/?\\? \home\mool\vim\src\version.c</B>
Examples, when the file name is "src/version.c.gz":
<B> :p /home/mool/vim/src/version.c.gz</B>
<B> :e gz</B>
<B> :e:e c.gz</B>
<B> :e:e:e c.gz</B>
<B> :e:e:r c</B>
<B> :r src/version.c</B>
<B> :r:e c</B>
<B> :r:r src/version</B>
<B> :r:r:r src/version</B>
*<A NAME="extension-removal"></A><B>extension-removal</B>* *<A NAME=":_%<"></A><B>:_%<</B>*
If a "<A HREF="change.html#<"><</A>" is appended to "<A HREF="motion.html#%">%</A>", "<A HREF="pattern.html##">#</A>", "#n" or "<A HREF="visual.html#CTRL-V">CTRL-V</A> p" the extension of the file
name is removed (everything after and including the last '<A HREF="repeat.html#.">.</A>' in the file
name). This is included for backwards compatibility with version 3.0, the
"<A HREF="insert.html#:r">:r</A>" form is preferred. Examples:
<B> % current file name</B>
<B> %< current file name without extension</B>
<B> # alternate file name for current window</B>
<B> #< idem, without extension</B>
<B> #31 alternate file number 31</B>
<B> #31< idem, without extension</B>
<B> <cword> word under the cursor</B>
<B> <cWORD> WORD under the cursor (see |WORD|)</B>
<B> <cfile> path name under the cursor</B>
<B> <cfile>< idem, without extension</B>
Note: Where a file name is expected <A HREF="editing.html#wildcards">wildcards</A> expansion is done. On <A HREF="os_unix.html#Unix">Unix</A> the
shell is used for this, unless <A HREF="motion.html#it">it</A> can be done internally (for speed).
Unless in |<A HREF="starting.html#restricted-mode">restricted-mode</A>|, backticks work also, like in
<B> :n `echo *.c`</B>
But expansion is only done if there are any <A HREF="editing.html#wildcards">wildcards</A> before expanding the
'<A HREF="motion.html#%">%</A>', '<A HREF="pattern.html##">#</A>', etc.. This avoids expanding <A HREF="editing.html#wildcards">wildcards</A> inside a file name. If you
want to expand the result of <A HREF="#<cfile>"><cfile></A>, add a <A HREF="editing.html#wildcard">wildcard</A> character to <A HREF="motion.html#it">it</A>.
Examples: (alternate file name is "?readme?")
<B><FONT COLOR="PURPLE"> command expands to </FONT></B>
<A HREF="editing.html#:e">:e</A> # <A HREF="editing.html#:e">:e</A> ?readme?
<A HREF="editing.html#:e">:e</A> `ls #` <A HREF="editing.html#:e">:e</A> {files matching "?readme?"}
<A HREF="editing.html#:e">:e</A> #.* <A HREF="editing.html#:e">:e</A> {files matching "?readme?.*"}
<A HREF="editing.html#:cd">:cd</A> <A HREF="#<cfile>"><cfile></A> <A HREF="editing.html#:cd">:cd</A> {file name under cursor}
<A HREF="editing.html#:cd">:cd</A> <cfile>* <A HREF="editing.html#:cd">:cd</A> {file name under cursor plus "*" and then expanded}
Also see |<A HREF="editing.html#`=">`=</A>|.
When the expanded argument contains a "<A HREF="change.html#!">!</A>" and <A HREF="motion.html#it">it</A> is used for a shell command
(":!cmd", "<A HREF="insert.html#:r">:r</A> !cmd" or "<A HREF="editing.html#:w">:w</A> !cmd"), the "<A HREF="change.html#!">!</A>" is escaped with a <A HREF="intro.html#backslash">backslash</A> to
avoid <A HREF="motion.html#it">it</A> being expanded into a previously used command. When the <A HREF="options.html#'shell'">'shell'</A>
option contains "sh", this is done <A HREF="if_cscop.html#twice">twice</A>, to avoid the shell trying to expand
the "<A HREF="change.html#!">!</A>".
*<A NAME="filename-backslash"></A><B>filename-backslash</B>*
For filesystems that use a <A HREF="intro.html#backslash">backslash</A> <A HREF="motion.html#as">as</A> directory separator (MS-DOS, Windows,
OS/2), it's a bit difficult to recognize a <A HREF="intro.html#backslash">backslash</A> that is used to <A HREF="intro.html#escape">escape</A>
the special meaning of the next character. The general rule is: If the
<A HREF="intro.html#backslash">backslash</A> is followed by a normal file name character, <A HREF="motion.html#it">it</A> does not have a
special meaning. Therefore "\file\foo" is a valid file name, you don't have
to type the <A HREF="intro.html#backslash">backslash</A> <A HREF="if_cscop.html#twice">twice</A>.
An exception is the '<A HREF="motion.html#$">$</A>' sign. It is a valid character in a file name. But
to avoid a file name like "$home" to be interpreted <A HREF="motion.html#as">as</A> an environment variable,
<A HREF="motion.html#it">it</A> needs to be preceded by a <A HREF="intro.html#backslash">backslash</A>. Therefore you need to use "/\$home"
for the file "$home" in the root directory. A few examples:
<B><FONT COLOR="PURPLE"> FILE NAME INTERPRETED AS </FONT></B>
$home expanded to value of environment var $home
\$home file "$home" in current directory
/\$home file "$home" in root directory
\\$home file "\\", followed by expanded $home
Also see |<A HREF="editing.html#`=">`=</A>|.
==============================================================================
7. <A HREF="#Command-line">Command-line</A> <A HREF="windows.html#window">window</A> *<A NAME="cmdline-window"></A><B>cmdline-window</B>* *<A NAME="cmdwin"></A><B>cmdwin</B>*
*<A NAME="command-line-window"></A><B>command-line-window</B>*
In the command-line <A HREF="windows.html#window">window</A> the command line can be edited just like editing
text in any <A HREF="windows.html#window">window</A>. It is a special kind of <A HREF="windows.html#window">window</A>, because you cannot leave
<A HREF="motion.html#it">it</A> in a normal way.
{not available when compiled without the |<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>| or |<A HREF="various.html#+vertsplit">+vertsplit</A>|
feature}
OPEN *<A NAME="c_CTRL-F"></A><B>c_CTRL-F</B>* *<A NAME="q:"></A><B>q:</B>* *<A NAME="q/"></A><B>q/</B>* *<A NAME="q?"></A><B>q?</B>*
There are two ways to open the command-line <A HREF="windows.html#window">window</A>:
1. From <A HREF="#Command-line">Command-line</A> mode, use the key specified with the <A HREF="options.html#'cedit'">'cedit'</A> option.
The default is <A HREF="scroll.html#CTRL-F">CTRL-F</A> when <A HREF="options.html#'compatible'">'compatible'</A> is not set.
2. From <A HREF="intro.html#Normal">Normal</A> mode, use the "<A HREF="#q:">q:</A>", "<A HREF="#q/">q/</A>" or "<A HREF="#q?">q?</A>" command.
This starts editing an <A HREF="intro.html#Ex">Ex</A> command-line ("q:") or search <A HREF="eval.html#string">string</A> ("q/" or
"q?"). Note that this is not possible while <A HREF="repeat.html#recording">recording</A> is in progress (the
"<A HREF="repeat.html#q">q</A>" stops <A HREF="repeat.html#recording">recording</A> then).
When the <A HREF="windows.html#window">window</A> opens <A HREF="motion.html#it">it</A> is filled with the command-line <A HREF="#history">history</A>. The last
line contains the command <A HREF="motion.html#as">as</A> typed so far. The left column will show a
character that indicates the type of command-line being edited, see
|<A HREF="#cmdwin-char">cmdwin-char</A>|.
Vim will be in <A HREF="intro.html#Normal">Normal</A> mode when the editor is opened, except when <A HREF="options.html#'insertmode'">'insertmode'</A>
is set.
The height of the <A HREF="windows.html#window">window</A> is specified with <A HREF="options.html#'cmdwinheight'">'cmdwinheight'</A> (or smaller if there
is no room). The <A HREF="windows.html#window">window</A> is always full width and is positioned just above the
command-line.
EDIT
You can now use commands to move around and edit the text in the <A HREF="windows.html#window">window</A>. Both
in <A HREF="intro.html#Normal">Normal</A> mode and <A HREF="insert.html#Insert">Insert</A> mode.
It is possible to use "<A HREF="#:">:</A>", "<A HREF="pattern.html#/">/</A>" and other commands that use the command-line,
but it's not possible to open another command-line <A HREF="windows.html#window">window</A> then. There is no
nesting.
*<A NAME="E11"></A><B>E11</B>*
The command-line <A HREF="windows.html#window">window</A> is not a normal <A HREF="windows.html#window">window</A>. It is not possible to move to
another <A HREF="windows.html#window">window</A> or edit another buffer. All commands that would <A HREF="diff.html#do">do</A> this are
disabled in the command-line <A HREF="windows.html#window">window</A>. Of course <A HREF="motion.html#it">it</A> _is_ possible to execute
any command that you entered in the command-line <A HREF="windows.html#window">window</A>. Other text edits are
discarded when closing the <A HREF="windows.html#window">window</A>.
CLOSE *<A NAME="E199"></A><B>E199</B>*
There are several ways to leave the command-line <A HREF="windows.html#window">window</A>:
<A HREF="motion.html#<CR>"><CR></A> Execute the command-line under the cursor. Works both in
<A HREF="insert.html#Insert">Insert</A> and in <A HREF="intro.html#Normal">Normal</A> mode.
<A HREF="pattern.html#CTRL-C">CTRL-C</A> Continue in <A HREF="#Command-line">Command-line</A> mode. The command-line under the
cursor is used <A HREF="motion.html#as">as</A> the command-line. Works both in <A HREF="insert.html#Insert">Insert</A> and
in <A HREF="intro.html#Normal">Normal</A> mode. There is no redraw, thus the <A HREF="windows.html#window">window</A> will
remain visible.
<A HREF="editing.html#:quit">:quit</A> Discard the command line and go back to <A HREF="intro.html#Normal">Normal</A> mode.
"<A HREF="windows.html#:close">:close</A>", "<A HREF="editing.html#:exit">:exit</A>", "<A HREF="editing.html#:xit">:xit</A>" and CTRL-\ <A HREF="motion.html#CTRL-N">CTRL-N</A> also work.
<A HREF="editing.html#:qall">:qall</A> Quit Vim, unless there are changes in some buffer.
<A HREF="editing.html#:qall">:qall</A>! Quit Vim, discarding changes to any buffer.
Once the command-line <A HREF="windows.html#window">window</A> is closed the old <A HREF="windows.html#window">window</A> sizes are restored. The
executed command applies to the <A HREF="windows.html#window">window</A> and buffer where the command-line was
started from. This works <A HREF="motion.html#as">as</A> if the command-line <A HREF="windows.html#window">window</A> was not there, except
that there will be an extra screen redraw.
The buffer used for the command-line <A HREF="windows.html#window">window</A> is deleted. Any changes to lines
other than the one that is executed with <A HREF="motion.html#<CR>"><CR></A> are lost.
If you would like to execute the command under the cursor and then have the
command-line <A HREF="windows.html#window">window</A> open again, you may find this <A HREF="map.html#mapping">mapping</A> useful:
<B> :autocmd CmdwinEnter * map <buffer> <F5> <CR>q:</B>
VARIOUS
The command-line <A HREF="windows.html#window">window</A> cannot be used:
- when there already is a command-line <A HREF="windows.html#window">window</A> (no nesting)
- for entering an <A HREF="editing.html#encryption">encryption</A> key or when using <A HREF="eval.html#inputsecret()">inputsecret()</A>
- when Vim was not compiled with the |<A HREF="various.html#+vertsplit">+vertsplit</A>| feature
Some <A HREF="options.html#options">options</A> are set when the command-line <A HREF="windows.html#window">window</A> is opened:
<A HREF="options.html#'filetype'">'filetype'</A> "vim", when editing an <A HREF="intro.html#Ex">Ex</A> command-line; this starts Vim <A HREF="syntax.html#syntax">syntax</A>
highlighting if <A HREF="motion.html#it">it</A> was enabled
<A HREF="options.html#'rightleft'">'rightleft'</A> off
<A HREF="options.html#'modifiable'">'modifiable'</A> on
<A HREF="options.html#'buftype'">'buftype'</A> "nofile"
<A HREF="options.html#'swapfile'">'swapfile'</A> off
It is allowed to write the buffer contents to a file. This is an <A HREF="starting.html#easy">easy</A> way to
save the command-line <A HREF="#history">history</A> and read <A HREF="motion.html#it">it</A> back later.
If the <A HREF="options.html#'wildchar'">'wildchar'</A> option is set to <A HREF="motion.html#<Tab>"><Tab></A>, and the command-line <A HREF="windows.html#window">window</A> is used
for an <A HREF="intro.html#Ex">Ex</A> command, then two mappings will be added to use <A HREF="motion.html#<Tab>"><Tab></A> for completion
in the command-line <A HREF="windows.html#window">window</A>, like this:
<B> :imap <buffer> <Tab> <C-X><C-V></B>
<B> :nmap <buffer> <Tab> a<C-X><C-V></B>
Note that hitting <A HREF="motion.html#<Tab>"><Tab></A> in <A HREF="intro.html#Normal">Normal</A> mode will <A HREF="diff.html#do">do</A> completion on the next
character. That way <A HREF="motion.html#it">it</A> works at the end of the line.
If you don't want these mappings, disable them with:
<B> au CmdwinEnter [:>] iunmap <Tab></B>
<B> au CmdwinEnter [:>] nunmap <Tab></B>
You could put these lines in your <A HREF="starting.html#vimrc">vimrc</A> file.
While in the command-line <A HREF="windows.html#window">window</A> you cannot use the mouse to put the cursor in
another <A HREF="windows.html#window">window</A>, or drag statuslines of other <A HREF="windows.html#windows">windows</A>. You can drag the
statusline of the command-line <A HREF="windows.html#window">window</A> itself and the statusline above <A HREF="motion.html#it">it</A>.
Thus you can resize the command-line <A HREF="windows.html#window">window</A>, but not others.
The |<A HREF="eval.html#getcmdwintype()">getcmdwintype()</A>| function returns the type of the command-line being
edited <A HREF="motion.html#as">as</A> described in |<A HREF="#cmdwin-char">cmdwin-char</A>|.
AUTOCOMMANDS
Two <A HREF="autocmd.html#autocommand">autocommand</A> events are used: |<A HREF="autocmd.html#CmdwinEnter">CmdwinEnter</A>| and |<A HREF="autocmd.html#CmdwinLeave">CmdwinLeave</A>|. Since this
<A HREF="windows.html#window">window</A> is of a special type, the <A HREF="autocmd.html#WinEnter">WinEnter</A>, <A HREF="autocmd.html#WinLeave">WinLeave</A>, <A HREF="autocmd.html#BufEnter">BufEnter</A> and <A HREF="autocmd.html#BufLeave">BufLeave</A>
events are not triggered. You can use the Cmdwin events to <A HREF="diff.html#do">do</A> settings
specifically for the command-line <A HREF="windows.html#window">window</A>. Be careful not to cause side
effects!
Example:
<B> :au CmdwinEnter : let b:cpt_save = &cpt | set cpt=.</B>
<B> :au CmdwinLeave : let &cpt = b:cpt_save</B>
This sets <A HREF="options.html#'complete'">'complete'</A> to use completion in the current <A HREF="windows.html#window">window</A> for |<A HREF="insert.html#i_CTRL-N">i_CTRL-N</A>|.
Another example:
<B> :au CmdwinEnter [/?] startinsert</B>
This will make Vim start in <A HREF="insert.html#Insert">Insert</A> mode in the command-line <A HREF="windows.html#window">window</A>.
*<A NAME="cmdwin-char"></A><B>cmdwin-char</B>*
The character used for the <A HREF="pattern.html#pattern">pattern</A> indicates the type of command-line:
: normal <A HREF="intro.html#Ex">Ex</A> command
<A HREF="change.html#>">></A> debug mode command |<A HREF="repeat.html#debug-mode">debug-mode</A>|
/ forward search <A HREF="eval.html#string">string</A>
? backward search <A HREF="eval.html#string">string</A>
= <A HREF="eval.html#expression">expression</A> for "<A HREF="change.html#=">=</A> |<A HREF="eval.html#expr-register">expr-register</A>|
@ <A HREF="eval.html#string">string</A> for |<A HREF="eval.html#input()">input()</A>|
- text for |<A HREF="insert.html#:insert">:insert</A>| or |<A HREF="insert.html#:append">:append</A>|
<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>
</HTML>
|