Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
<BS>
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
<Enter>
, you notice that "col" should be "cow". To correct
this, you type <Left>
five times. The cursor is now just after "col". Type
<BS>
and "w" to correct::s/cow/pig/Now you can press
<Enter>
directly. You don't have to move the cursor to the
end of the line before executing the command.<Left>
one character left
<Right>
one character right
<S-Left>
or <C-Left>
one word left
<S-Right>
or <C-Right>
one word right
CTRL-B
or <Home>
to begin of command line
CTRL-E
or <End>
to end of command line<S-Left>
(cursor left key with Shift key pressed) and <C-Left>
(cursor
left key with Control pressed) will not work on all keyboards. Same
for the other Shift and Control combinations.<BS>
deletes the character before the cursor. To delete a whole
word use CTRL-W
.CTRL-W
<Insert>
key toggles between inserting characters and replacing the
existing ones. Start with this text:<S-Left>
twice (or <Left>
eight
times, if <S-Left>
doesn't work). Now press <Insert>
to switch to overstrike
and type "great":<BS>
, because it would delete the
"t" (this is different from Replace mode). Instead, press <Insert>
to switch
from overstrike to inserting, and type the space:CTRL-C
or <Esc>
.<Esc>
is the universal "get out" key. Unfortunately, in the good old
Vi pressing <Esc>
in a command line executed the command! Since that
might be considered to be a bug, Vim uses <Esc>
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) <Esc>
also works
Vi compatible. Therefore, using CTRL-C
is a method that always works.<BS>
will cancel the
command. It's like deleting the ":" or "/" that the line starts with.:s[ubstitute]This means that the shortest form of ":substitute" is ":s". The following characters are optional. Thus ":su" and ":sub" also work.
:set autoindent :set aiYou can find the full list of long and short names here: option-list.
:edit bodyofthepaper.txtIt's easy to type this wrong. A much quicker way is:
:edit b<Tab>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.:edit i<Tab>Vim will beep, and give you:
:edit info.txtThe 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.txtThus, 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 iThen 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
------------------------><Tab>
you get::set iconHey, 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 iskeywordNow type "=" and press
<Tab>
::set iskeyword=@,48-57,_,192-255What 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).CTRL-D
. For example, pressing CTRL-D
after::set isresults in:
:set is incsearch isfname isident iskeyword isprint :set isVim 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.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".<Up>
key to recall an older command line. <Down>
then takes you back
to newer commands.<Up>
. There is a quicker way::se<Up>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
<Up>
very often (unless ":set" commands is all
you have done).<Up>
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 <Down>
to go back to
what you typed and correct that. Or use CTRL-U
to start all over again.:historyThat's the history of ":" commands. The search history is displayed with this command:
:history /CTRL-P will work like
<Up>
, except that it doesn't matter what you already
typed. Similarly for CTRL-N
and <Down>
. CTRL-P
stands for previous, CTRL-N
for next.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=========================| | | +-------------------------------------+
<Enter>
and this command will be executed. The command line window
will close.
The <Enter>
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.