Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
CTRL-V
. To insert a <Nul>
character use "CTRL-V CTRL-@
" or "CTRL-V 000". On some systems, you have to
use "CTRL-V 003" to insert a CTRL-C
. Note: When CTRL-V
is mapped you can
often use CTRL-Q
instead i_CTRL-Q.<Esc>
or CTRL-[
End insert or Replace mode, go back to Normal mode. Finish
abbreviation.
Note: If your <Esc>
key is hard to hit, try CTRL-[
instead.
i_META i_ALT
ALT (META) may act like <Esc>
if the chord is not mapped.
For example <A-x>
acts like <Esc>
x if <A-x>
does not have an
insert-mode mapping.
i_CTRL-C <BS>
or CTRL-H
Delete the character before the cursor (see i_backspacing
about joining lines).
i_<Del> i_DEL
<Del>
Delete the character under the cursor. If the cursor is at
the end of the line, and the 'backspace' option includes
"eol" (the default), delete the <EOL>
; the next line is
appended after the current one.
i_CTRL-W <Tab>
or CTRL-I
Insert a tab. If the 'expandtab' option is on, the
equivalent number of spaces is inserted (use CTRL-V
<Tab>
to
avoid the expansion; use CTRL-Q
<Tab>
if CTRL-V
is mapped
i_CTRL-Q). See also the 'smarttab' option and
ins-expandtab.
i_CTRL-J i_<NL>
<NL>
or CTRL-J
Begin new line.
i_CTRL-M i_<CR>
<CR>
or CTRL-M
Begin new line.
i_CTRL-K {char1}
[char2]
Enter digraph (see digraphs). When {char1}
is a special
key, the code for that key is inserted in <> form. For
example, the string "<S-Space>" can be entered by typing
<C-K>
<S-Space>
(two keys). Neither char is considered for
mapping.{register}
i_CTRL-R CTRL-R
and
the second character, '"' will be displayed to indicate that
you are expected to enter the name of a register.
The text is inserted as if you typed it, but mappings and
abbreviations are not used. If you have options like
'textwidth', 'formatoptions', or 'autoindent' set, this will
influence what will be inserted. This is different from what
happens with the "p" command and pasting with the mouse.
Special registers:
'"' the unnamed register, containing the text of
the last delete or yank
'%' the current file name
'#' the alternate file name
"*" the clipboard contents (X11: primary selection)
'+' the clipboard contents
'/' the last search pattern
':' the last command-line
'.' the last inserted text
i_CTRL-R_- CTRL-R
="\<Up>"
Use CTRL-R
CTRL-R
to insert text literally.
When the result is a List the items are used
as lines. They can have line breaks inside
too.
When the result is a Float it's automatically
converted to a String.
When append() or setline() is invoked the undo
sequence will be broken.
See registers about registers.CTRL-R
{register}
i_CTRL-R_CTRL-R CTRL-R
, but the text is inserted literally, not as if typed.
This differs when the register contains characters like <BS>
.
Example, where register a contains "ab^Hc":CTRL-R a results in "ac". CTRL-R CTRL-R a results in "ab^Hc".
CTRL-R
CTRL-O
, see below.
The '.' register (last inserted text) is still inserted as
typed.
After this command, the '.' register contains the text from
the register as if it was inserted by typing it.CTRL-O
{register}
i_CTRL-R_CTRL-O P
.
The '.' register (last inserted text) is still inserted as
typed.
After this command, the '.' register contains the command
typed and not the text. I.e., the literals "^R^O" and not the
text from the register.
Does not replace characters in Replace-mode!CTRL-P
{register}
i_CTRL-R_CTRL-P CTRL-D
Delete all indent in the current line. The indent is
restored in the next line. This is useful when inserting a
label.CTRL-V
are not considered for
mapping.
For special keys, the CTRL modifier may be included into the
key to produce a control character. If there is no control
character for the key then its key-notation is inserted.
Note: When CTRL-V
is mapped (e.g., to paste text) you can
often use CTRL-Q
instead i_CTRL-Q.CTRL-V
.
Note: Some terminal connections may eat CTRL-Q
, it doesn't
work then. It does work in the GUI.CTRL-V
, but do not try to include the CTRL
modifier into the key.CTRL-X
mode. This is a sub-mode where commands can
be given to complete words or scroll the window. See
i_CTRL-X and ins-completion.CTRL-E
and CTRL-Y
'textwidth' is not used, to be
able to copy characters from a long line.CTRL-_
moves the cursor to the end of the typed text.CTRL-^
Toggle the use of typing language characters.
When language :lmap mappings are defined:
<BS>
, CTRL-W
, and CTRL-U
depend on the 'backspace' option
(unless 'revins' is set). This is a comma-separated list of items:CTRL-W
and
CTRL-U
stop once at the start position<EOL>
in front of the cursor.CTRL-V
the decimal, octal or hexadecimal value of a character can be
entered directly. This way you can enter any character, except a line break
(<NL>
, value 10). There are five ways to enter the character value:<C-V>
032. You can omit the leading zero, in
which case the character typed after the number must be a non-digit. This
happens for the other modes as well: As soon as you type a character that is
invalid for the mode, the value before it will be used and the "invalid"
character is dealt with in the normal way.<NL>
, which is used internally to represent the <Nul>
character. When writing
the buffer to a file, the <NL>
character is translated into <Nul>
. The <NL>
character is written at the end of each line. Thus if you want to insert a
<NL>
character in a file you will have to make a line break.
Also see 'fileformat'.CTRL-E
scroll window one line up.
When doing completion look here: complete_CTRL-ECTRL-Y
scroll window one line down.
When doing completion look here: complete_CTRL-YCTRL-X
is pressed, each CTRL-E
(CTRL-Y
) scrolls the window up (down) by
one line unless that would cause the cursor to move from its current position
in the file. As soon as another key is pressed, CTRL-X
mode is exited and
that key is interpreted as in Insert mode.CTRL-O
if you want to map a function key to a command.<Up>
cursor one line up<Down>
cursor one line down i_<Down> <Up>
cursor one line up, insert start column i_CTRL-G_<Up> CTRL-K
cursor one line up, insert start column i_CTRL-G_CTRL-K <Down>
cursor one line down, insert start column i_CTRL-G_<Down>
CTRL-G j cursor one line down, insert start column i_CTRL-G_j
CTRL-G CTRL-J
cursor one line down, insert start column i_CTRL-G_CTRL-J
<Left>
cursor one character left i_<Left> <Right>
cursor one character right i_<Right> <S-Left>
cursor one word back (like "b" command) i_<S-Left> <C-Left>
cursor one word back (like "b" command) i_<C-Left> <S-Right>
cursor one word forward (like "w" command) i_<S-Right>
<C-Right>
cursor one word forward (like "w" command) i_<C-Right>
<Home>
cursor to first char in the line i_<Home> <End>
cursor to after last char in the line i_<End> <C-Home>
cursor to first char in the file i_<C-Home> <C-End>
cursor to after last char in the file i_<C-End> <LeftMouse>
cursor to position of mouse click i_<LeftMouse> <S-Up>
move window one page up i_<S-Up> <PageUp>
move window one page up i_<PageUp> <S-Down>
move window one page down i_<S-Down> <PageDown>
move window one page down i_<PageDown> <ScrollWheelDown>
move window three lines down i_<ScrollWheelDown>
<S-ScrollWheelDown>
move window one page down i_<S-ScrollWheelDown> <ScrollWheelUp>
move window three lines up i_<ScrollWheelUp> <S-ScrollWheelUp>
move window one page up i_<S-ScrollWheelUp> <ScrollWheelLeft>
move window six columns left i_<ScrollWheelLeft>
<S-ScrollWheelLeft>
move window one page left i_<S-ScrollWheelLeft> <ScrollWheelRight>
move window six columns right i_<ScrollWheelRight>
<S-ScrollWheelRight>
move window one page right i_<S-ScrollWheelRight> CTRL-\
CTRL-O
like CTRL-O
but don't move the cursor i_CTRL-\_CTRL-O CTRL-O
command sometimes has a side effect: If the cursor was beyond the
end of the line, it will be put on the last character in the line. In
mappings it's often better to use <Esc>
(first put an "x" in the text, <Esc>
will then always put the cursor on it). Or use CTRL-\
CTRL-O
, but then
beware of the cursor possibly being beyond the end of the line. Note that the
command following CTRL-\
CTRL-O
can still move the cursor, it is not restored
to its original position.CTRL-O
command takes you to Normal mode. If you then use a command enter
Insert mode again it normally doesn't nest. Thus when typing "a<C-O>a" and
then <Esc>
takes you back to Normal mode, you do not need to type <Esc>
twice.
An exception is when not typing the command, e.g. when executing a mapping or
sourcing a script. This makes mappings work that briefly switch to Insert
mode.CTRL-O
is
too complicated.CTRL-G
u::inoremap <C-H> <C-G>u<C-H>This redefines the backspace key to start a new undo sequence. You can now undo the effect of the backspace key, without changing what you typed before that, with
CTRL-O
u. Another example::inoremap <CR> <C-]><C-G>u<CR>This starts a new undo block at each line break. It also expands abbreviations before this.
CTRL-G
U:inoremap <Left> <C-G>U<Left> inoremap <Right> <C-G>U<Right> inoremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ? \ repeat('<C-G>U<Left>', col('.') - 1) : \ (col('.') < match(getline('.'), '\S') ? \ repeat('<C-G>U<Right>', match(getline('.'), '\S') + 0) : \ repeat('<C-G>U<Left>', col('.') - 1 - match(getline('.'), '\S'))) inoremap <expr> <End> repeat('<C-G>U<Right>', col('$') - col('.')) inoremap ( ()<C-G>U<Left>This makes it possible to use the cursor keys in Insert mode, without starting a new undo block and therefore using . (redo) will work as expected. Also entering a text like (with the "(" mapping from above):
CTRL-O
splits undo: the text typed before and after it is undone
separately. If you want to avoid this (e.g., in a mapping) you might be able
to use CTRL-R
= i_CTRL-R. E.g., to call a function::imap <F2> <C-R>=MyFunc()<CR>When the 'whichwrap' option is set appropriately, the
<Left>
and <Right>
keys on the first/last character in the line make the cursor wrap to the
previous/next line.CTRL-G
j and CTRL-G
k commands can be used to insert text in front of a
column. Example:int i; int j;Position the cursor on the first "int", type "istatic
<C-G>
j ". The
result is:static int i; int j;When inserting the same text in front of the column in every line, use the Visual blockwise command "I" v_b_I.
<Tab>
, type CTRL-V
first
(use CTRL-Q
when CTRL-V
is mapped i_CTRL-Q).
The 'expandtab' option is off by default. Note that in Replace mode, a single
character is replaced with several spaces. The result of this is that the
number of characters in the line increases. Backspacing will delete one
space at a time. The original character will be put back for only one space
that you backspace over (the last one).<Tab>
inserts 'shiftwidth' positions at
the beginning of a line and 'tabstop' positions in other places. This means
that often spaces instead of a <Tab>
character are inserted. When 'smarttab'
is off, a <Tab>
always inserts 'tabstop' positions, and 'shiftwidth' is only
used for ">>" and the like.<Tab>
inserts 'softtabstop'
positions, and a <BS>
used to delete white space, will delete 'softtabstop'
positions. This feels like 'tabstop' was set to 'softtabstop', but a real
<Tab>
character still takes 'tabstop' positions, so your file will still look
correct when used by other applications.<BS>
will try to delete as much white space to
move to the previous 'softtabstop' position, except when the previously
inserted character is a space, then it will only delete the character before
the cursor. Otherwise you cannot always delete a single character before the
cursor. You will have to delete 'softtabstop' characters first, and then type
extra spaces to get where you want to be.<NL>
is typed, a line break is inserted and no character is deleted.<Tab>
characters. If you type a normal printing character in
its place, the number of characters is still the same, but the number of
columns will become smaller.<BS>
, CTRL-W
, or CTRL-U
), what
happens is that you delete the changes. The characters that were replaced
are restored. If you had typed past the existing text, the characters you
added are deleted. This is effectively a character-at-a-time undo.<Tab>
will replace one character with
several spaces. The result of this is that the number of characters in the
line increases. Backspacing will delete one space at a time. The original
character will be put back for only one space that you backspace over (the
last one).<Tab>
it may replace several normal characters, and if you
type a letter on top of a <Tab>
it may not replace anything at all, since the
<Tab>
will still line up to the same place as before.<NL>
still doesn't cause characters later in the file to appear to
move. The rest of the current line will be replaced by the <NL>
(that is,
they are deleted), and replacing continues on the next line. A new line is
NOT inserted unless you go past the end of the file.CTRL-T
and CTRL-D
. The characters
before the cursor are shifted sideways as normal, but characters later in the
line still remain still. CTRL-T
will hide some of the old line under the
shifted characters, but CTRL-D
will reveal them again.<BS>
etc will bring back the characters that were
replaced. This still works in conjunction with 'smartindent', CTRL-T
and
CTRL-D, 'expandtab', 'smarttab', 'softtabstop', etc.<Tab>
separated columns in tables, for
entering new data while keeping all the columns aligned.CTRL-N
and CTRL-P
, are done in CTRL-X
mode. This is a
sub-mode of Insert and Replace modes. You enter CTRL-X
mode by typing CTRL-X
and one of the CTRL-X
commands. You exit CTRL-X
mode by typing a key that is
not a valid CTRL-X
mode command. Valid keys are the CTRL-X
command itself,
CTRL-N (next), and CTRL-P
(previous).CTRL-E
to stop it and go back to the
originally typed text. The CTRL-E
will not be inserted.CTRL-Y
to stop completion and
accept the currently selected entry. The CTRL-Y
is not inserted. Typing a
space, Enter, or some other unprintable character will leave completion mode
and insert that typed character.CTRL-X
mode are not mapped. This allows for
:map <C-F> <C-X><C-F>
to work. The key that ends CTRL-X
mode (any key that
is not a valid CTRL-X
mode command) is mapped. Also, when doing completion
with 'complete' mappings apply as usual.:inoremap <C-]> <C-X><C-]> :inoremap <C-F> <C-X><C-F> :inoremap <C-D> <C-X><C-D> :inoremap <C-L> <C-X><C-L>As a special case, typing
CTRL-R
to perform register insertion (see
i_CTRL-R) will not exit CTRL-X
mode. This is primarily to allow the use of
the '=' register to call some function to determine the next operation. If
the contents of the register (or result of the '=' register evaluation) are
not valid CTRL-X
mode keys, then CTRL-X
mode will be exited as if those keys
had been typed.<Tab>
to either actually insert a <Tab>
if
the current line is currently only whitespace, or start/continue a CTRL-N
completion operation:function! CleverTab() if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$' return "\<Tab>" else return "\<C-N>" endif endfunction inoremap <Tab> <C-R>=CleverTab()<CR>Completing whole lines compl-whole-line
CTRL-L
Search backwards for a line that starts with the
same characters as those in the current line before
the cursor. Indent is ignored. The matching line is
inserted in front of the cursor.
The 'complete' option is used to decide which buffers
are searched for a match. Both loaded and unloaded
buffers are used.
CTRL-L
or
CTRL-P
Search backwards for next matching line. This line
replaces the previous matching line.CTRL-N
Search forward for next matching line. This line
replaces the previous matching line.CTRL-X
CTRL-L
After expanding a line you can additionally get the
line next to it by typing CTRL-X
CTRL-L
again, unless
a double CTRL-X
is used. Only works for loaded
buffers.CTRL-N
Search forwards for words that start with the keyword
in front of the cursor. The found keyword is inserted
in front of the cursor.CTRL-P
Search backwards for words that start with the keyword
in front of the cursor. The found keyword is inserted
in front of the cursor.CTRL-N
Search forward for next matching keyword. This
keyword replaces the previous matching keyword.CTRL-P
Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.CTRL-X
CTRL-N
or
CTRL-X
CTRL-P
Further use of CTRL-X
CTRL-N
or CTRL-X
CTRL-P
will
copy the words following the previous expansion in
other contexts unless a double CTRL-X
is used.CTRL-N
and CTRL-P
(unless there is only one
matching keyword).CTRL-X
CTRL-P
or CTRL-X
CTRL-N
to get the
word following the expansion in other contexts. These sequences search for
the text just expanded and further expand by getting an extra word. This is
useful if you need to repeat a sequence of complicated words. Although CTRL-P
and CTRL-N
look just for strings of at least two characters, CTRL-X
CTRL-P
and
CTRL-X CTRL-N
can be used to expand words of just one character.
e.g., to get:
México
you can type:
M^N^P^X^P^X^P
CTRL-N starts the expansion and then CTRL-P
takes back the single character
"M", the next two CTRL-X
CTRL-P
's get the words "é" and ";xico".CTRL-X
CTRL-P
or CTRL-X
CTRL-N
will search
for those lines starting with this word.CTRL-K
Search the files given with the 'dictionary' option
for words that start with the keyword in front of the
cursor. This is like CTRL-N
, but only the dictionary
files are searched, not the current file. The found
keyword is inserted in front of the cursor. This
could potentially be pretty slow, since all matches
are found before the first match is used. By default,
the 'dictionary' option is empty.
For suggestions where to find a list of words, see the
'dictionary' option.
'ignorecase', 'smartcase' and 'infercase' apply.CTRL-K
or
CTRL-N
Search forward for next matching keyword. This
keyword replaces the previous matching keyword.CTRL-P
Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.CTRL-T
Works as CTRL-X
CTRL-K
, but in a special way. It uses
the 'thesaurus' option instead of 'dictionary'. If a
match is found in the thesaurus file, all the
remaining words on the same line are included as
matches, even though they don't complete the word.
Thus a word can be completely replaced.CTRL-T
or
CTRL-N
Search forward for next matching keyword. This
keyword replaces the previous matching keyword.CTRL-P
Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.angry furious mad enragedPlacing the cursor after the letters "ang" and typing
CTRL-X
CTRL-T
would
complete the word "angry"; subsequent presses would change the word to
"furious", "mad" etc.func Thesaur(findstart, base) if a:findstart return searchpos('\<', 'bnW', line('.'))[1] - 1 endif let res = [] let h = '' for l in systemlist('aiksaurus ' .. shellescape(a:base)) if l[:3] == '=== ' let h = '(' .. substitute(l[4:], ' =*$', ')', '') elseif l ==# 'Alphabetically similar known words are: ' let h = "\U0001f52e" elseif l[0] =~ '\a' || (h ==# "\U0001f52e" && l[0] ==# "\t") call extend(res, map(split(substitute(l, '^\t', '', ''), ', '), {_, val -> {'word': val, 'menu': h}})) endif endfor return res endfunc if exists('+thesaurusfunc') set thesaurusfunc=Thesaur endifCompleting keywords in the current and included files compl-keyword
CTRL-I
Search for the first keyword in the current and
included files that starts with the same characters
as those before the cursor. The matched keyword is
inserted in front of the cursor.CTRL-N
Search forwards for next matching keyword. This
keyword replaces the previous matching keyword.
Note: CTRL-I
is the same as <Tab>
, which is likely to
be typed after a successful completion, therefore
CTRL-I
is not used for searching for the next match.CTRL-P
Search backward for previous matching keyword. This
keyword replaces the previous matching keyword.CTRL-X
CTRL-I
Further use of CTRL-X
CTRL-I
will copy the words
following the previous expansion in other contexts
unless a double CTRL-X
is used.CTRL-]
Search for the first tag that starts with the same
characters as before the cursor. The matching tag is
inserted in front of the cursor. Alphabetic
characters and characters in 'iskeyword' are used
to decide which characters are included in the tag
name (same as for a keyword). See also CTRL-].
The 'showfulltag' option can be used to add context
from around the tag definition.
CTRL-]
or
CTRL-N
Search forwards for next matching tag. This tag
replaces the previous matching tag.CTRL-P
Search backward for previous matching tag. This tag
replaces the previous matching tag.CTRL-F
Search for the first file name that starts with the
same characters as before the cursor. The matching
file name is inserted in front of the cursor.
Alphabetic characters and characters in 'isfname'
are used to decide which characters are included in
the file name. Note: the 'path' option is not used
here (yet).
CTRL-F
or
CTRL-N
Search forwards for next matching file name. This
file name replaces the previous matching file name.CTRL-P
Search backward for previous matching file name.
This file name replaces the previous matching file
name.CTRL-D
Search in the current and included files for the
first definition (or macro) name that starts with
the same characters as before the cursor. The found
definition name is inserted in front of the cursor.
CTRL-D
or
CTRL-N
Search forwards for next matching macro name. This
macro name replaces the previous matching macro
name.CTRL-P
Search backward for previous matching macro name.
This macro name replaces the previous matching macro
name.CTRL-X
CTRL-D
Further use of CTRL-X
CTRL-D
will copy the words
following the previous expansion in other contexts
unless a double CTRL-X
is used.CTRL-V
Guess what kind of item is in front of the cursor and
find the first match for it.
Note: When CTRL-V
is mapped you can often use CTRL-Q
instead of i_CTRL-Q.
CTRL-V
or
CTRL-N
Search forwards for next match. This match replaces
the previous one.CTRL-P
Search backwards for previous match. This match
replaces the previous one.CTRL-X
CTRL-V
Further use of CTRL-X
CTRL-V
will do the same as
CTRL-V
. This allows mapping a key to do Vim command
completion, for example::imap <Tab> <C-X><C-V>User defined completion compl-function
CTRL-U
Guess what kind of item is in front of the cursor and
find the first match for it.
CTRL-U
or
CTRL-N
Use the next match. This match replaces the previous
one.CTRL-P
Use the previous match. This match replaces the
previous one.CTRL-O
Guess what kind of item is in front of the cursor and
find the first match for it.
CTRL-O
or
CTRL-N
Use the next match. This match replaces the previous
one.CTRL-P
Use the previous match. This match replaces the
previous one.CTRL-S
suspends display in many Unix terminals. Use 's' instead. Type
CTRL-Q to resume displaying.CTRL-S
or
CTRL-X s Locate the word in front of the cursor and find the
first spell suggestion for it.
CTRL-S
or
CTRL-N
Use the next suggestion. This replaces the previous
one. Note that you can't use 's' here.CTRL-P
Use the previous suggestion. This replaces the
previous one.CTRL-N
Search forward for next matching keyword. This
keyword replaces the previous matching keyword.CTRL-P
Search backwards for next matching keyword. This
keyword replaces the previous matching keyword.CTRL-X
CTRL-N
or
CTRL-X
CTRL-P
Further use of CTRL-X
CTRL-N
or CTRL-X
CTRL-P
will
copy the words following the previous expansion in
other contexts unless a double CTRL-X
is used.local triggers = {"."}
vim.api.nvim_create_autocmd("InsertCharPre", {
buffer = vim.api.nvim_get_current_buf(),
callback = function()
if vim.fn.pumvisible() == 1 or vim.fn.state("m") == "m" then
return
end
local char = vim.v.char
if vim.list_contains(triggers, char) then
local key = vim.keycode("<C-x><C-n>")
vim.api.nvim_feedkeys(key, "m", false)
end
end
})
let matches = ... list of words ... return {'words': matches, 'refresh': 'always'}
fun! CompleteMonths(findstart, base) if a:findstart " locate the start of the word let line = getline('.') let start = col('.') - 1 while start > 0 && line[start - 1] =~ '\a' let start -= 1 endwhile return start else " find months matching with "a:base" let res = [] for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") if m =~ '^' .. a:base call add(res, m) endif endfor return res endif endfun set completefunc=CompleteMonths
fun! CompleteMonths(findstart, base) if a:findstart " locate the start of the word let line = getline('.') let start = col('.') - 1 while start > 0 && line[start - 1] =~ '\a' let start -= 1 endwhile return start else " find months matching with "a:base" for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") if m =~ '^' .. a:base call complete_add(m) endif sleep 300m " simulate searching for next match if complete_check() break endif endfor return [] endif endfun set completefunc=CompleteMonths
CTRL-N
or CTRL-P
.
2. A cursor key has been used to select another match. The match was not
inserted then, only the entry in the popup menu is highlighted.
3. Only part of a match has been inserted and characters were typed or the
backspace key was used. The list of matches was then adjusted for what is
in front of the cursor.CTRL-N
or CTRL-P
, you go to the first
state. This doesn't change the list of matches.CTRL-P
right after
starting the completion::imap <F7> <C-N><C-P>
<BS>
and CTRL-H
Delete one character, find the matches for the word before
the cursor. This reduces the list of matches, often to one
entry, and switches to the second state.
Any non-special character:
Stop completion without changing the match and insert the
typed character.<BS>
and CTRL-H
Delete one character, find the matches for the shorter word
before the cursor. This may find more matches.
CTRL-L Add one character from the current match, may reduce the
number of matches.
any printable, non-white character:
Add this character and reduce the number of matches.<PageUp>
Select a match several entries back, but don't insert it.
<PageDown>
Select a match several entries further, but don't insert it.
<Up>
Select the previous match, as if CTRL-P
was used, but don't
insert it.
<Down>
Select the next match, as if CTRL-N
was used, but don't
insert it.
<Space>
or <Tab>
Stop completion without changing the match and insert the
typed character.<Enter>
key depends on the state you are in:
first state: Use the text as it is and insert a line break.
second state: Insert the currently selected match.
third state: Use the text as it is and insert a line break.<Enter>
key inserts that match. If you typed
something else then <Enter>
inserts a line break.:inoremap <Down> <C-R>=pumvisible() ? "\<lt>C-N>" : "\<lt>Down>"<CR>You can use of
<expr>
in mapping to have the popup menu used when typing a
character and some condition is met. For example, for typing a dot:inoremap <expr> . MayComplete() func MayComplete() if (can complete) return ".\<C-X>\<C-O>" endif return '.' endfuncSee :map-<expr> for more info.
{filetype}
should be autoload/{filetype}complete.vim
in 'runtimepath'. Thus for "java" it is autoload/javacomplete.vim.% ctags -R -f ~/.config/nvim/systags /usr/include /usr/local/includeIn your vimrc file add this tags file to the 'tags' option:
set tags+=~/.config/nvim/systagsWhen using
CTRL-X
CTRL-O
after a name without any "." or "->" it is completed
from the tags file directly. This works for any identifier, also function
names. If you want to complete a local variable name, which does not appear
in the tags file, use CTRL-P
instead.CTRL-X
CTRL-O
after something that has "." or "->" Vim will attempt
to recognize the type of the variable and figure out what members it has.
This means only members valid for the variable will be listed.CTRL-X
CTRL-O
will add a "." or
"->" for composite types.CTRL-O
provides completion of various elements of (X)HTML files. It is
designed to support writing of XHTML 1.0 Strict files but will also work for
other versions of HTML. Features:<style>
tag and included CSS files
CTRL-X
CTRL-O
will close the last opened tag
<script>
tag of (X)HTML and in values of event attributes (including scanning
of external files).IE FF W3C Omni completion ~ +/- +/- + + ~ + + - + ~ + - - - ~ - + - - ~
/* @var $myVar myClass */ $myVar->
CTRL-X
CTRL-O
are sensitive to the context:let g:rubycomplete_buffer_loading = 1<- In context 1 above, Vim can parse the entire buffer to add a list of classes to the completion results. This feature is turned off by default, to enable it add
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
setlocal omnifunc=syntaxcomplete#CompleteYou can automate this by placing the following in your init.vim (after any ":filetype" command):
if has("autocmd") && exists("+omnifunc") autocmd Filetype * \ if &omnifunc == "" | \ setlocal omnifunc=syntaxcomplete#Complete | \ endif endifThe above will set completion to this script only if a specific plugin does not already exist for that filetype.
syntax listThe first thing you will notice is that there are many different syntax groups. The PHP language can include elements from different languages like HTML, JavaScript and many more. The syntax plugin will only include syntax groups that begin with the filetype, "php", in this case. For example these syntax groups are included by default with the PHP: phpEnvVar, phpIntVar, phpFunctions.
htmlArg,htmlTag,htmlTagName,javaScriptStatement,javaScriptGlobalObjectsTo pick up any JavaScript and HTML keyword syntax groups while editing a PHP file, you can use 3 different regexs, one for each language. Or you can simply restrict the include groups to a particular value, without using a regex string:
let g:omni_syntax_group_include_php = 'php\w\+,javaScript\w\+,html\w\+' let g:omni_syntax_group_include_php = 'phpFunctions,phpMethods'
let g:omni_syntax_group_include_{filetype} = 'regex,comma,separated'The PHP language has an enormous number of items which it knows how to syntax highlight. These items will be available within the omni completion list.
let g:omni_syntax_group_exclude_php = 'phpCoreConstant,phpConstant' let g:omni_syntax_group_exclude_php = 'php\w*Constant'Add as many syntax groups to this list by comma separating them. The basic form of this variable is:
let g:omni_syntax_group_exclude_{filetype} = 'regex,comma,separated'You can create as many of these variables as you need, varying only the filetype at the end of the variable name.
let g:omni_syntax_use_iskeyword = 0For plugin developers, the plugin exposes a public function OmniSyntaxList. This function can be used to request a List of syntax items. When editing a SQL file (:e syntax.sql) you can use the ":syntax list" command to see the various groups and syntax items. For example:
syntax listYields data similar to this:
echo OmniSyntaxList( [] )To retrieve only the syntax items for the sqlOperator syntax group:
echo OmniSyntaxList( ['sqlOperator'] )To retrieve all syntax items for both the sqlOperator and sqlType groups:
echo OmniSyntaxList( ['sqlOperator', 'sqlType'] )A regular expression can also be used:
echo OmniSyntaxList( ['sql\w\+'] )From within a plugin, you would typically assign the output to a List:
let myKeywords = [] let myKeywords = OmniSyntaxList( ['sqlKeyword'] )
CTRL-X
CTRL-O
will close the last opened tag
let g:xmldata_crippled = { \ "vimxmlentities": ["amp", "lt", "gt", "apos", "quot"], \ 'vimxmlroot': ['tag1'], \ 'tag1': \ [ ['childoftag1a', 'childoftag1b'], {'attroftag1a': [], \ 'attroftag1b': ['valueofattr1', 'valueofattr2']}], \ 'childoftag1a': \ [ [], {'attrofchild': ['attrofchild']}], \ 'childoftag1b': \ [ ['childoftag1a'], {'attrofchild': []}], \ "vimxmltaginfo": { \ 'tag1': ['Menu info', 'Long information visible in preview window']}, \ 'vimxmlattrinfo': { \ 'attrofchild': ['Menu info', 'Long information visible in preview window']}}This example would be put in the "autoload/xml/crippled.vim" file and could help to write this file:
<tag1 attroftag1b="valueofattr1"> <childoftag1a attrofchild> & < </childoftag1a> <childoftag1b attrofchild="5"> <childoftag1a> > ' " </childoftag1a> </childoftag1b> </tag1>In the example four special elements are visible:
:XMLns xhtml10s :XMLns xsl xsl:XMLent
{name}
:XMLent :XMLent xhtml10sUsage
<|Will complete to an appropriate XHTML tag, and in this situation:
<xsl:|Will complete to an appropriate XSL tag.
:echo xmlcomplete#GetLastOpenTag("b:unaryTagsStack")
<insert>
or i insert <Insert>
i Insert text before the cursor [count] times.
When using CTRL-O
in Insert mode i_CTRL-O the count
is not supported.<Esc>
. See mode-ins-repl for the other special characters in Insert mode.
The effect of [count] takes place after Insert mode is exited.<Space>
Insert an empty line above the cursor without leaving
Normal mode, repeat [count] times.{range}
is missing, the text will be
inserted after the current line.
Adding [!] toggles 'autoindent' for the time this
command is executed.{range}
is missing, the text will be
inserted before the current line.
Adding [!] toggles 'autoindent' for the time this
command is executed.:a|one two . :visualappends the following text, after the cursor line:
one two
<Esc>
in Insert mode.
Can be used in an autocommand, example::au BufEnter scratch stopinsert
{cmd}
and insert its standard output below
the cursor or the specified line. A temporary file is
used to store the output of the command which is then
read into the buffer. 'shellredir' is used to save
the output of the command, which can be set to include
stderr or not. {cmd}
is executed like with ":!{cmd}",
any '!' is replaced with the previous command :!.
See ++opt for the possible values of [++opt].{name}
".:read ++edit filenameThe effect is that the 'fileformat', 'fileencoding', 'bomb', etc. options are set to what has been detected for "filename". Note that a single empty line remains, you may want to delete it.
<EOL>
style for a file:
<CR>
<NL>
or <NL>
DOS format
"unix" <NL>
Unix format
"mac" <CR>
Mac format<CR>
in front of an <NL>
is ignored and a CTRL-Z
at the end of the file is ignored.<NL>
in the file is internally represented by a
<CR>
. This is to avoid confusion with a <NL>
which is used to represent a
<NUL>
. See CR-used-for-NL.<EOL>
(see file-formats). However, the 'fileformat' option will not be
changed, the detected format is only used while reading the file.
A similar thing happens with 'fileencodings'.:r !uuencode binfile binfileThis command reads "binfile", uuencodes it and reads it into the current buffer. Useful when you are editing e-mail and want to include a binary file.
{RO}
the file is write protected
[fifo/socket] using a stream
[fifo] using a fifo stream
[socket] using a socket stream
[CR missing] reading with "dos" 'fileformat' and a
NL without a preceding CR was found.
[NL found] reading with "mac" 'fileformat' and a
NL was found (could be "unix" format)
[long lines split] at least one line was split in two
[NOT converted] conversion from 'fileencoding' to
'encoding' was desired but not
possible
[converted] conversion from 'fileencoding' to
'encoding' done
[READ ERRORS] not all of the file could be read