/usr/share/vim/vim82/doc
NameSizeModeActions
arabic.txt122040644editdlrm
autocmd.txt743140644editdlrm
builtin.txt3890750644editdlrm
change.txt792140644editdlrm
channel.txt503870644editdlrm
cmdline.txt501300644editdlrm
debug.txt68960644editdlrm
debugger.txt54430644editdlrm
develop.txt228610644editdlrm
diff.txt175150644editdlrm
digraph.txt620820644editdlrm
editing.txt753190644editdlrm
eval.txt1782820644editdlrm
farsi.txt5230644editdlrm
filetype.txt279980644editdlrm
fold.txt241390644editdlrm
ft_ada.txt182460644editdlrm
ft_ps1.txt21870644editdlrm
ft_raku.txt41830644editdlrm
ft_rust.txt95960644editdlrm
ft_sql.txt306970644editdlrm
gui.txt530760644editdlrm
gui_w32.txt191170644editdlrm
gui_x11.txt299060644editdlrm
hangulin.txt5980644editdlrm
hebrew.txt56660644editdlrm
help.txt90980644editdlrm
help.txt.vim-tiny14310644editdlrm
helphelp.txt159330644editdlrm
howto.txt29160644editdlrm
if_cscop.txt193250644editdlrm
if_lua.txt185460644editdlrm
if_mzsch.txt119410644editdlrm
if_ole.txt73610644editdlrm
if_perl.txt112810644editdlrm
if_pyth.txt386440644editdlrm
if_ruby.txt85160644editdlrm
if_sniff.txt2710644editdlrm
if_tcl.txt229410644editdlrm
indent.txt419020644editdlrm
index.txt811250644editdlrm
insert.txt875680644editdlrm
intro.txt389340644editdlrm
map.txt744640644editdlrm
mbyte.txt596400644editdlrm
message.txt316710644editdlrm
mlang.txt81870644editdlrm
motion.txt518910644editdlrm
netbeans.txt379820644editdlrm
options.txt4012540644editdlrm
os_390.txt47490644editdlrm
os_amiga.txt54660644editdlrm
os_beos.txt2930644editdlrm
os_dos.txt154960644editdlrm
os_haiku.txt84960644editdlrm
os_mac.txt68560644editdlrm
os_mint.txt3910644editdlrm
os_msdos.txt5230644editdlrm
os_os2.txt2990644editdlrm
os_qnx.txt40710644editdlrm
os_risc.txt3280644editdlrm
os_unix.txt26030644editdlrm
os_vms.txt329030644editdlrm
os_win32.txt144040644editdlrm
pattern.txt629490644editdlrm
pi_getscript.txt210820644editdlrm
pi_gzip.txt12940644editdlrm
pi_logipat.txt41960644editdlrm
pi_netrw.txt1818240644editdlrm
pi_paren.txt22740644editdlrm
pi_spec.txt41270644editdlrm
pi_tar.txt72470644editdlrm
pi_vimball.txt118590644editdlrm
pi_zip.txt74910644editdlrm
popup.txt396890644editdlrm
print.txt312090644editdlrm
quickfix.txt833310644editdlrm
quickref.txt724920644editdlrm
quotes.txt127480644editdlrm
README.Debian3240644editdlrm
recover.txt107200644editdlrm
remote.txt84200644editdlrm
repeat.txt435650644editdlrm
rileft.txt49380644editdlrm
russian.txt30240644editdlrm
scroll.txt137810644editdlrm
sign.txt268700644editdlrm
spell.txt640950644editdlrm
sponsor.txt68030644editdlrm
starting.txt735990644editdlrm
syntax.txt2297950644editdlrm
tabpage.txt172480644editdlrm
tags3626700644editdlrm
tags.vim-tiny300644editdlrm
tagsrch.txt402780644editdlrm
term.txt498220644editdlrm
terminal.txt570980644editdlrm
testing.txt166780644editdlrm
textprop.txt163950644editdlrm
tips.txt210890644editdlrm
todo.txt3071470644editdlrm
uganda.txt140280644editdlrm
undo.txt165840644editdlrm
usr_01.txt70810644editdlrm
usr_02.txt242290644editdlrm
usr_03.txt238720644editdlrm
usr_04.txt191310644editdlrm
usr_05.txt270230644editdlrm
usr_06.txt106380644editdlrm
usr_07.txt159950644editdlrm
usr_08.txt193790644editdlrm
usr_09.txt115020644editdlrm
usr_10.txt292000644editdlrm
usr_11.txt130250644editdlrm
usr_12.txt134330644editdlrm
usr_20.txt137330644editdlrm
usr_21.txt184560644editdlrm
usr_22.txt149990644editdlrm
usr_23.txt127440644editdlrm
usr_24.txt208270644editdlrm
usr_25.txt191760644editdlrm
usr_26.txt82590644editdlrm
usr_27.txt177090644editdlrm
usr_28.txt160200644editdlrm
usr_29.txt201210644editdlrm
usr_30.txt226580644editdlrm
usr_31.txt103990644editdlrm
usr_32.txt53780644editdlrm
usr_40.txt231950644editdlrm
usr_41.txt956260644editdlrm
usr_42.txt138530644editdlrm
usr_43.txt74090644editdlrm
usr_44.txt289480644editdlrm
usr_45.txt176880644editdlrm
usr_46.txt70960644editdlrm
usr_90.txt168360644editdlrm
usr_toc.txt95050644editdlrm
various.txt314830644editdlrm
version4.txt139110644editdlrm
version5.txt3085330644editdlrm
version6.txt5769420644editdlrm
version7.txt6747030644editdlrm
version8.txt19404660644editdlrm
vim9.txt686120644editdlrm
visual.txt218460644editdlrm
vi_diff.txt574280644editdlrm
windows.txt558980644editdlrm
workshop.txt3710644editdlrm
Edit: /usr/share/vim/vim82/doc/usr_20.txt (13733B)
*usr_20.txt* For Vim version 8.2. Last change: 2021 Nov 18 VIM USER MANUAL - by Bram Moolenaar Typing command-line commands quickly Vim has a few generic features that makes it easier to enter commands. Colon commands can be abbreviated, edited and repeated. Completion is available for nearly everything. |20.1| Command line editing |20.2| Command line abbreviations |20.3| Command line completion |20.4| Command line history |20.5| Command line window Next chapter: |usr_21.txt| Go away and come back Previous chapter: |usr_12.txt| Clever tricks Table of contents: |usr_toc.txt| ============================================================================== *20.1* Command line editing When you use a colon (:) command or search for a string with / or ?, Vim puts the cursor on the bottom of the screen. There you type the command or search pattern. This is called the Command line. Also when it's used for entering a search command. The most obvious way to edit the command you type is by pressing the key. This erases the character before the cursor. To erase another character, typed earlier, first move the cursor with the cursor keys. For example, you have typed this: > :s/col/pig/ Before you hit , you notice that "col" should be "cow". To correct this, you type five times. The cursor is now just after "col". Type and "w" to correct: > :s/cow/pig/ Now you can press directly. You don't have to move the cursor to the end of the line before executing the command. The most often used keys to move around in the command line: one character left one character right or one word left or one word right CTRL-B or to begin of command line CTRL-E or to end of command line Note: (cursor left key with Shift key pressed) and (cursor left key with Control pressed) will not work on all keyboards. Same for the other Shift and Control combinations. You can also use the mouse to move the cursor. DELETING As mentioned, deletes the character before the cursor. To delete a whole word use CTRL-W. /the fine pig ~ CTRL-W /the fine ~ CTRL-U removes all text, thus allows you to start all over again. OVERSTRIKE The key toggles between inserting characters and replacing the existing ones. Start with this text: /the fine pig ~ Move the cursor to the start of "fine" with twice (or eight times, if doesn't work). Now press to switch to overstrike and type "great": /the greatpig ~ Oops, we lost the space. Now, don't use , because it would delete the "t" (this is different from Replace mode). Instead, press to switch from overstrike to inserting, and type the space: /the great pig ~ CANCELLING You thought of executing a : or / command, but changed your mind. To get rid of what you already typed, without executing it, press CTRL-C or . Note: is the universal "get out" key. Unfortunately, in the good old Vi pressing in a command line executed the command! Since that might be considered to be a bug, Vim uses to cancel the command. But with the 'cpoptions' option it can be made Vi compatible. And when using a mapping (which might be written for Vi) also works Vi compatible. Therefore, using CTRL-C is a method that always works. If you are at the start of the command line, pressing will cancel the command. It's like deleting the ":" or "/" that the line starts with. ============================================================================== *20.2* Command line abbreviations Some of the ":" commands are really long. We already mentioned that ":substitute" can be abbreviated to ":s". This is a generic mechanism, all ":" commands can be abbreviated. How short can a command get? There are 26 letters, and many more commands. For example, ":set" also starts with ":s", but ":s" doesn't start a ":set" command. Instead ":set" can be abbreviated to ":se". When the shorter form of a command could be used for two commands, it stands for only one of them. There is no logic behind which one, you have to learn them. In the help files the shortest form that works is mentioned. For example: > :s[ubstitute] This means that the shortest form of ":substitute" is ":s". The following characters are optional. Thus ":su" and ":sub" also work. In the user manual we will either use the full name of command, or a short version that is still readable. For example, ":function" can be abbreviated to ":fu". But since most people don't understand what that stands for, we will use ":fun". (Vim doesn't have a ":funny" command, otherwise ":fun" would be confusing too.) It is recommended that in Vim scripts you write the full command name. That makes it easier to read back when you make later changes. Except for some often used commands like ":w" (":write") and ":r" (":read"). A particularly confusing one is ":end", which could stand for ":endif", ":endwhile" or ":endfunction". Therefore, always use the full name. SHORT OPTION NAMES In the user manual the long version of the option names is used. Many options also have a short name. Unlike ":" commands, there is only one short name that works. For example, the short name of 'autoindent' is 'ai'. Thus these two commands do the same thing: > :set autoindent :set ai You can find the full list of long and short names here: |option-list|. ============================================================================== *20.3* Command line completion This is one of those Vim features that, by itself, is a reason to switch from Vi to Vim. Once you have used this, you can't do without. Suppose you have a directory that contains these files: info.txt intro.txt bodyofthepaper.txt To edit the last one, you use the command: > :edit bodyofthepaper.txt It's easy to type this wrong. A much quicker way is: > :edit b Which will result in the same command. What happened? The key does completion of the word before the cursor. In this case "b". Vim looks in the directory and finds only one file that starts with a "b". That must be the one you are looking for, thus Vim completes the file name for you. Now type: > :edit i Vim will beep, and give you: > :edit info.txt The beep means that Vim has found more than one match. It then uses the first match it found (alphabetically). If you press again, you get: > :edit intro.txt Thus, if the first doesn't give you the file you were looking for, press it again. If there are more matches, you will see them all, one at a time. If you press on the last matching entry, you will go back to what you first typed: > :edit i Then it starts all over again. Thus Vim cycles through the list of matches. Use CTRL-P to go through the list in the other direction: <------------------- -------------------------+ | --> --> :edit i :edit info.txt :edit intro.txt <-- CTRL-P <-- CTRL-P | +---------------------- CTRL-P ------------------------> CONTEXT When you type ":set i" instead of ":edit i" and press you get: > :set icon Hey, why didn't you get ":set info.txt"? That's because Vim has context sensitive completion. The kind of words Vim will look for depends on the command before it. Vim knows that you cannot use a file name just after a ":set" command, but you can use an option name. Again, if you repeat typing the , Vim will cycle through all matches. There are quite a few, it's better to type more characters first: > :set isk Gives: > :set iskeyword Now type "=" and press : > :set iskeyword=@,48-57,_,192-255 What happens here is that Vim inserts the old value of the option. Now you can edit it. What is completed with is what Vim expects in that place. Just try it out to see how it works. In some situations you will not get what you want. That's either because Vim doesn't know what you want, or because completion was not implemented for that situation. In that case you will get a inserted (displayed as ^I). LIST MATCHES When there are many matches, you would like to see an overview. Do this by pressing CTRL-D. For example, pressing CTRL-D after: > :set is results in: > :set is incsearch isfname isident iskeyword isprint :set is Vim lists the matches and then comes back with the text you typed. You can now check the list for the item you wanted. If it isn't there, you can use to correct the word. If there are many matches, type a few more characters before pressing to complete the rest. If you have watched carefully, you will have noticed that "incsearch" doesn't start with "is". In this case "is" stands for the short name of "incsearch". (Many options have a short and a long name.) Vim is clever enough to know that you might have wanted to expand the short name of the option into the long name. THERE IS MORE The CTRL-L command completes the word to the longest unambiguous string. If you type ":edit i" and there are files "info.txt" and "info_backup.txt" you will get ":edit info". The 'wildmode' option can be used to change the way completion works. The 'wildmenu' option can be used to get a menu-like list of matches. Use the 'suffixes' option to specify files that are less important and appear at the end of the list of files. The 'wildignore' option specifies files that are not listed at all. More about all of this here: |cmdline-completion| ============================================================================== *20.4* Command line history In chapter 3 we briefly mentioned the history. The basics are that you can use the key to recall an older command line. then takes you back to newer commands. There are actually five histories. The ones we will mention here are for ":" commands and for "/" and "?" search commands. The "/" and "?" commands share the same history, because they are both search commands. The three other histories are for expressions, debug mode commands and input lines for the input() function. |cmdline-history| Suppose you have done a ":set" command, typed ten more colon commands and then want to repeat that ":set" command again. You could press ":" and then ten times . There is a quicker way: > :se Vim will now go back to the previous command that started with "se". You have a good chance that this is the ":set" command you were looking for. At least you should not have to press very often (unless ":set" commands is all you have done). The key will use the text typed so far and compare it with the lines in the history. Only matching lines will be used. If you do not find the line you were looking for, use to go back to what you typed and correct that. Or use CTRL-U to start all over again. To see all the lines in the history: > :history That's the history of ":" commands. The search history is displayed with this command: > :history / CTRL-P will work like , except that it doesn't matter what you already typed. Similarly for CTRL-N and . CTRL-P stands for previous, CTRL-N for next. ============================================================================== *20.5* Command line window Typing the text in the command line works differently from typing text in Insert mode. It doesn't allow many commands to change the text. For most commands that's OK, but sometimes you have to type a complicated command. That's where the command line window is useful. Open the command line window with this command: > q: Vim now opens a (small) window at the bottom. It contains the command line history, and an empty line at the end: +-------------------------------------+ |other window | |~ | |file.txt=============================| |:e c | |:e config.h.in | |:set path=.,/usr/include,, | |:set iskeyword=@,48-57,_,192-255 | |:set is | |:q | |: | |command-line=========================| | | +-------------------------------------+ You are now in Normal mode. You can use the "hjkl" keys to move around. For example, move up with "5k" to the ":e config.h.in" line. Type "$h" to go to the "i" of "in" and type "cwout". Now you have changed the line to: :e config.h.out ~ Now press and this command will be executed. The command line window will close. The command will execute the line under the cursor. It doesn't matter whether Vim is in Insert mode or in Normal mode. Changes in the command line window are lost. They do not result in the history to be changed. Except that the command you execute will be added to the end of the history, like with all executed commands. The command line window is very useful when you want to have overview of the history, lookup a similar command, change it a bit and execute it. A search command can be used to find something. In the previous example the "?config" search command could have been used to find the previous command that contains "config". It's a bit strange, because you are using a command line to search in the command line window. While typing that search command you can't open another command line window, there can be only one. ============================================================================== Next chapter: |usr_21.txt| Go away and come back Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: