Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/usr_20.txt`
d9ef94fd677dd50f2f2a22caa8c4825a25c9106e19d059f60000000100000eff

Which will result in the same command.  What happened?  The <Tab> 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<Tab>

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 <Tab> again, you get: >

	:edit intro.txt

Thus, if the first <Tab> 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 <Tab> 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:

	      <------------------- <Tab> -------------------------+
								  |
		  <Tab> -->		       <Tab> -->
	: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 <Tab> 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 <Tab>, Vim will cycle through all matches.
There are quite a few, it's better to type more characters first: >

	:set isk<Tab>

Gives: >

	:set iskeyword

Now type "=" and press <Tab>: >

	: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 <Tab> 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 <Tab> 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
<BS> to correct the word.  If there are many matches, type a few more
characters before pressing <Tab> 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

Title: Advanced Command Line Completion in Vim
Summary
This section elaborates on command-line completion in Vim, explaining context-sensitive completion where suggestions depend on the command (e.g., after ':set'). It details how Vim inserts the old option value when completing options with '=' and how <Tab> cycles through matches. It then explains how CTRL-D lists all matches, CTRL-L completes to the longest unambiguous string, and mentions the 'wildmode', 'wildmenu', 'suffixes', and 'wildignore' options for customizing completion behavior.