Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
<Insert>
key, you can toggle between inserting and overstriking characters.tcsh-style
:cnoremap <C-A> <Home> :cnoremap <C-F> <Right> :cnoremap <C-B> <Left> :cnoremap <Esc>b <S-Left> :cnoremap <Esc>f <S-Right>(<> notation <>; type all this literally)
cmdline-too-long
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.cmdline-history
history
The command-lines that you enter are remembered in a history table. You can
recall them with the up and down cursor keys. There are actually five
history tables:
c_CTRL-V
CTRL-V Insert 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 mapping. This works the same
way as in Insert mode (see above, i_CTRL-V).
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: Under Windows CTRL-V
is often mapped to paste text.
Use CTRL-Q
instead then.
c_CTRL-Q
CTRL-Q Same as CTRL-V
. But with some terminals it is used for
control flow, it doesn't work then.CTRL-V
, but do not try to include the CTRL
modifier into the key.c_<Left>
c_Left
<Left>
cursor left. See 'wildmenu' for behavior during wildmenu
completion mode.
c_<Right>
c_Right
<Right>
cursor right. See 'wildmenu' for behavior during wildmenu
completion mode.
c_<S-Left>
<S-Left>
or <C-Left>
c_<C-Left>
cursor one WORD left
c_<S-Right>
<S-Right>
or <C-Right>
c_<C-Right>
cursor one WORD right
CTRL-B or <Home>
c_CTRL-B
c_<Home>
c_Home
cursor to beginning of command-line
CTRL-E or <End>
c_CTRL-E
c_<End>
c_End
cursor to end of command-line. See 'wildmenu' for behavior
during wildmenu completion mode.c_<LeftMouse>
<LeftMouse>
Move the cursor to the position of the mouse click.c_<MiddleMouse>
<MiddleMouse>
Paste the contents of the clipboard (for X11 the primary
selection). This is similar to using CTRL-R *
, but no CR
characters are inserted between lines.<BS>
Delete the character in front of the cursor.
c_<Del>
c_Del
<Del>
Delete the character under the cursor (at end of line:
character before the cursor).
c_CTRL-W
CTRL-W Delete the word before the cursor. This depends on the
'iskeyword' option.
c_CTRL-U
CTRL-U 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 vimrc::cnoremap <C-U> <C-E><C-U>
{char1}
<BS>
{char2}
or c_digraph
CTRL-K {char1}
{char2}
c_CTRL-K
enter digraph (see digraphs). When {char1}
is a special
key, the code for that key is inserted in <> form.{register}
c_CTRL-R
c_<C-R>
Insert the contents of a numbered or named register. Between
typing 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. Command-line completion through
'wildchar' is not triggered though. And characters that end
the command line are inserted literally (<Esc>
, <CR>
, <NL>
,
<C-C>
). A <BS>
or CTRL-W
could still end the command line
though, and remaining characters will then be interpreted in
another mode, which might not be what you intended.
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 small (less than a line) delete
'.' the last inserted text
c_CTRL-R_=
'=' the expression register: you are prompted to
enter an expression (see expression)
(doesn't work at the expression prompt; some
things such as changing the buffer or current
window are not allowed to avoid side effects)
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.
Note that when you only want to move the
cursor and not insert anything, you must make
sure the expression evaluates to an empty
string. E.g.:<C-R><C-R>=setcmdpos(2)[-1]<CR>
CTRL-R
CTRL-R
to set the
position afterwards.CTRL-F
c_CTRL-R_CTRL-F
c_<C-R>_<C-F>
CTRL-R CTRL-P
c_CTRL-R_CTRL-P
c_<C-R>_<C-P>
CTRL-R CTRL-W
c_CTRL-R_CTRL-W
c_<C-R>_<C-W>
CTRL-R CTRL-A
c_CTRL-R_CTRL-A
c_<C-R>_<C-A>
CTRL-R CTRL-L
c_CTRL-R_CTRL-L
c_<C-R>_<C-L>
Insert the object under the cursor:
CTRL-F
the Filename under the cursor
CTRL-P
the Filename under the cursor, expanded with
'path' as in gf
CTRL-W
the Word under the cursor
CTRL-A
the WORD under the cursor; see WORD
CTRL-L
the line under the cursorCTRL-W
the part of
the word that was already typed is not inserted again.c_CTRL-R_CTRL-R
c_<C-R>_<C-R>
c_CTRL-R_CTRL-O
c_<C-R>_<C-O>
CTRL-R CTRL-R
{register CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}
CTRL-R CTRL-O
{register CTRL-F CTRL-P CTRL-W CTRL-A CTRL-L}
Insert register or object under the cursor. Works like
c_CTRL-R but inserts the text literally. For example, if
register a contains "xy^Hz" (where ^H is a backspace),
"CTRL-R a" will insert "xz" while "CTRL-R CTRL-R
a" will
insert "xy^Hz".CTRL-\
e {expr}
c_CTRL-\_e
Evaluate {expr}
and replace the whole command line with the
result. You will be prompted for the expression, type <Enter>
to finish it. It's most useful in mappings though. See
expression.
See c_CTRL-R_= for inserting the result of an expression.
Useful functions are getcmdtype(), getcmdline() and
getcmdpos().
The cursor position is unchanged, except when the cursor was
at the end of the line, then it stays at the end.
setcmdpos() can be used to set the cursor position.
The sandbox is used for evaluating the expression to avoid
nasty side effects.
Example::cmap <F7> <C-\>eAppendSome()<CR> :func AppendSome() :let cmd = getcmdline() .. " Some()" :" place the cursor on the ) :call setcmdpos(strlen(cmd)) :return cmd :endfunc
c_CTRL-Y
CTRL-Y When there is a modeless selection, copy the selection into
the clipboard.
If there is no selection CTRL-Y
is inserted as a character.
See 'wildmenu' for behavior during wildmenu completion mode.CTRL-[
c_CTRL-[
c_<Esc>
c_Esc
<Esc>
When typed and 'x' not present in 'cpoptions', quit
Command-line mode without executing. In macros or when 'x'
present in 'cpoptions', start entered command.
Note: If your <Esc>
key is hard to hit on your keyboard, train
yourself to use CTRL-[
.
c_META
c_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 a
command-line mode mapping.
c_CTRL-C
CTRL-C quit command-line without executingc_<Up>
c_Up
<Up>
recall older command-line from history, whose beginning
matches the current command-line (see below). See 'wildmenu'
for behavior during wildmenu completion mode.
c_<Down>
c_Down
<Down>
recall more recent command-line from history, whose beginning
matches the current command-line (see below). See 'wildmenu'
for behavior during wildmenu completion mode.c_<S-Up>
c_<PageUp>
<S-Up>
or <PageUp>
recall older command-line from history
c_<S-Down>
c_<PageDown>
<S-Down>
or <PageDown>
recall more recent command-line from historyc_CTRL-^
CTRL-^
Toggle the use of language :lmap mappings and/or Input
Method.
When typing a pattern for a search command and 'imsearch' is
not -1, VAL is the value of 'imsearch', otherwise VAL is the
value of 'iminsert'.
When language mappings are defined:
CTRL-^
, the new state is not used again
for the next command or Search pattern.
c_CTRL-]
CTRL-]
Trigger abbreviation, without inserting a character.<Up>
and <Down>
keys take the current command-line as a search string.
The beginning of the next/previous command-lines are compared with this
string. The first line that matches is the new command-line. When typing
these two keys repeatedly, the same string is used again. For example, this
can be used to find the previous substitute command: Type ":s" and then <Up>
.
The same could be done by typing <S-Up>
a number of times until the desired
command-line is shown. (Note: the shifted arrow keys do not work on all
terminals){name}
] [{first}
][, [{last}
]]
List the contents of history {name}
which can be:
c[md] or : command-line history
s[earch] or / or ? search string history
e[xpr] or = expression register history
i[nput] or @ input line history
d[ebug] or > debug command history
a[ll] all of the above{first}
and/or {last}
are given, the respective
range of entries from a history is listed. These numbers can
be specified in the following form:
:history-indexing
A positive number represents the absolute index of an entry
as it is given in the first column of a :history listing.
This number remains fixed even if other entries are deleted.
(see E1510):history / 6,12
:history all -2
:history all -2,:keepp[atterns]
{command}
:keepp
:keeppatterns
Execute {command}
, without adding anything to the search
history and, in case of :s or :&, without modifying the
last substitute pattern or substitute string.c_CTRL-D
CTRL-D List names that match the pattern in front of the cursor.
When showing file names, directories are highlighted (see
highlight-groups). Names where 'suffixes' matches are moved
to the end.
The 'wildoptions' option can be set to "tagfile" to list the
file of matching tags.
c_CTRL-I
c_wildchar
c_<Tab>
'wildchar' option
A match is done on the pattern in front of the cursor. The
match (if there are several, the first match) is inserted
in place of the pattern. (Note: does not work inside a
macro, because <Tab>
or <Esc>
are mostly used as 'wildchar',
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 'wildmode' option.
c_<S-Tab>
<S-Tab>
Like 'wildchar' or <Tab>
, but begin with the last match and
then go to the previous match.
c_CTRL-N
CTRL-N After using 'wildchar' which got multiple matches, go to next
match. Otherwise recall more recent command-line from history.
c_CTRL-P
CTRL-P After using 'wildchar' which got multiple matches, go to
previous match. Otherwise recall older command-line from
history.
c_CTRL-A
CTRL-A All names that match the pattern in front of the cursor are
inserted.
c_CTRL-L
CTRL-L A match is done on the pattern in front of the cursor. If
there is one match, it is inserted in place of the pattern.
If there are multiple matches the longest common part is
inserted in place of the pattern. If the result is shorter
than the pattern, no completion is done.
/_CTRL-L
When 'incsearch' is set, entering a search pattern for "/" or
"?" and the current match is displayed then CTRL-L
will add
one character from the end of the current match. If
'ignorecase' and 'smartcase' are set and the command line has
no uppercase characters, the added character is converted to
lowercase.
c_CTRL-G
/_CTRL-G
CTRL-G When 'incsearch' is set, entering a search pattern for "/" or
"?" and the current match is displayed then CTRL-G
will move
to the next match (does not take search-offset into account)
Use CTRL-T
to move to the previous match. Hint: on a regular
keyboard T is above G.
c_CTRL-T
/_CTRL-T
CTRL-T When 'incsearch' is set, entering a search pattern for "/" or
"?" and the current match is displayed then CTRL-T
will move
to the previous match (does not take search-offset into
account).
Use CTRL-G
to move to the next match. Hint: on a regular
keyboard T is above G.<Tab>
(CTRL-E
when in Vi compatible mode; in
a previous version <Esc>
was used). In the pattern standard wildcards are
accepted when matching file names.CTRL-N
you cycle through the matches, eventually
ending up back to what was typed. If the first match is not what you wanted,
you can use <S-Tab>
or CTRL-P
to go straight back to what you typed.<C-L>
<C-D>
(Where X is the command key to use, <C-L>
is CTRL-L
and <C-D>
is CTRL-D
)
This will find the longest match and then list all matching files.complete-script-local-functions
When completing user function names, prepend "s:" to find script-local
functions.suffixes
For file name completion you can use the 'suffixes' 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 'suffixes' option are ignored.
The default is ".bak,~,.o,.h,.info,.swp,.obj", which means that files ending
in ".bak", "~", ".o", ".h", ".info", ".swp" and ".obj" are sometimes ignored.CTRL-N
or CTRL-P
. All files are included, also the ones with
extensions matching the 'suffixes' option.:e *.c$This will not match a file ending in ".cpp". Without the "$" it does match.
<S-Tab>
for CTRL-P
in an xterm, put this command in
your .cshrc:xmodmap -e "keysym Tab = Tab Find"And this in your vimrc:
:cmap <Esc>[1~ <C-P>
complete-set-option
When setting an option using :set=, the old value of an option can be
obtained by hitting 'wildchar' just after the '='. For example, typing
'wildchar' after ":set dir=" will insert the current value of 'dir'. This
overrules file name completion for the options that take a file name.:quote
:comment
'"' 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::set ai "set 'autoindent' optionIt is not possible to add a comment to a shell command ":!cmd" or to the ":map" command and a few others (mainly commands that expect expressions) that see the '"' as part of their argument:
:bar
:\bar
'|' can be used to separate commands, so you can give multiple commands in one
line. If you want to use '|' in an argument, precede it with '\'.:execute 'r !ls' | '[There is one exception: When the 'b' flag is present in 'cpoptions', with the ":map" and ":abbr" commands and friends
CTRL-V
needs to be used instead of
'\'. You can also use "<Bar>" instead. See also map_bar.:!ls | wc view the output of two commands :r !ls | wc insert the same output in the text :%g/foo/p|> moves all matching lines one shiftwidth :%s/foo/bar/|> moves one line one shiftwidth :map q 10^V| map "q" to "10|" :map q 10\| map \ l map "q" to "10\" and map "\" to "l" (when 'b' is present in 'cpoptions')You can also use
<NL>
to separate commands in the same way as with '|'. To
insert a <NL>
use CTRL-V
CTRL-J
. "^@" will be shown. Using '|' is the
preferred method. But for external commands a <NL>
must be used, because a
'|' is included in the external command. To avoid the special meaning of <NL>
it must be preceded with a backslash. Example::r !date<NL>-joinThis reads the current date into the file and joins it with the previous line.
:| print current line (like ":p") :3| print line 3 (like ":3p") :3 goto line 3A colon is allowed between the range and the command name. It is ignored (this is Vi compatible). For example:
:1,$:s/pat/stringWhen the character '%' or '#' is used where a file name is expected, they are expanded to the current and alternate file name (see the chapter "editing files" :_% :_#).
CTRL-V
. Note that the ":next" command uses spaces to separate file names.
Escape the spaces to include them in a file name. Example::next foo\ bar goes\ to school\starts editing the three files "foo bar", "goes to" and "school ".
:_!
The '!' (bang) character after an Ex command makes the command behave in a
different way. The '!' should be placed immediately after the command, without
any blanks in between. If you insert blanks the '!' will be seen as an
argument for the command, which has a different meaning. For example:
:w! name write the current buffer to file "name", overwriting
any existing file
:w !name send the current buffer as standard input to command
"name":,
:;
When separated with ';' the cursor position will be set to that line
before interpreting the next line specifier. This doesn't happen for ','.
Examples:4,/this line/
5;/that line/
:range
{address}
{number}
an absolute line number E1247
. the current line :.
$ the last line in the file :$
% equal to 1,$ (the entire file) :%
't position of mark t (lowercase) :'
'T position of mark T (uppercase); when the mark is in
another file it cannot be used in a range
/{pattern}[/] the next line where {pattern}
matches :/
also see :range-pattern below
?{pattern}[?] the previous line where {pattern}
matches :?
also see :range-pattern below
\/ the next line where the previously used search
pattern matches
\? the previous line where the previously used search
pattern matches
\& the next line where the previously used substitute
pattern matches:range-offset
Each may be followed (several times) by '+' or '-' and an optional number.
This number is added or subtracted from the preceding line number. If the
number is omitted, 1 is used. If there is nothing before the '+' or '-' then
the current line is used.
:range-closed-fold
When a line number after the comma is in a closed fold it is adjusted to the
last line of the fold, thus the whole fold is included.:3,4+2printOn this text:
:2,4-1printOn this text:
:range-pattern
The "/" and "?" after {pattern}
are required to separate the pattern from
anything that follows./pat1//pat2/ Find line containing "pat2" after line containing "pat1", without moving the cursor. 7;/pat2/ Find line containing "pat2", after line 7, leaving the cursor in line 7.The
{number}
must be between 0 and the number of lines in the file. When
using a 0 (zero) this is interpreted as a 1 by most commands. Commands that
use it as a count do use it as a zero (:tag, :pop, etc). Some commands
interpret the zero as "before the first line" (:read, search pattern, etc)..+3 three lines below the cursor /that/+1 the line below the next line containing "that" .,$ from current line until end of file 0;/that the first line containing "that", also matches in the first line. 1;/that the first line after line 1 containing "that"Some commands allow for a count after the command. This count is used as 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 count are the ones that use a range but do not have a file name argument (because a file name can also be a number). The count cannot be negative.
:s/x/X/g 5 substitute 'x' by 'X' in the current line and four following lines :23d 4 delete lines 23, 24, 25 and 26Folds and Range
E493
N:
:.,.+(count - 1)In words: The "count" lines at and after the cursor. Example: To delete three lines:
3:d<CR> is translated into: .,.+2d<CR>
v_:
{Visual}
: Starts a command-line with the Visual selected lines as a
range. The code :'<,'>
is used for this range, which makes
it possible to select a similar line from the command-line
history for repeating a command on different Visually selected
lines.:star
:star-visual-range
When Visual mode was already ended, a short way to use the
Visual area for a range is :*
.CTRL-R
command. For
example, "%" stands for the current file name, while CTRL-R
% inserts the
current file name right away. See c_CTRL-R.:_%
c_%
# Is replaced with the alternate file name. :_#
c_#
This is remembered for every window.
#n (where n is a number) is replaced with :_#0
:_#n
the file name of buffer n. "#0" is the same as "#". c_#n
## Is replaced with all names in the argument list :_##
c_##
concatenated, separated by spaces. Each space in a name
is preceded with a backslash.
#<n (where n is a number > 0) is replaced with old :_#<
c_#<
file name n. See :oldfiles or v:oldfiles to get the
number. E809
:!ls "%" :r !spell "%"To avoid the special meaning of '%' and '#' insert a backslash before it. Detail: The special meaning is always escaped when there is a backslash before it, no matter how many backslashes.
E499
E500
Note: these are typed literally, they are not special keys!
:<cword>
<cword>
<cword>
is replaced with the word under the cursor (like star)
:<cWORD>
<cWORD>
<cWORD>
is replaced with the WORD under the cursor (see WORD)
:<cexpr>
<cexpr>
<cexpr>
is replaced with the word under the cursor, including more
to form a C expression. E.g., when the cursor is on "arg"
of "ptr->arg" then the result is "ptr->arg"; when the
cursor is on "]" of "list[idx]" then the result is
"list[idx]".
:<cfile>
<cfile>
<cfile>
is replaced with the path name under the cursor (like what
gf uses)
:<afile>
<afile>
<afile>
When executing autocommands, is replaced with the file name
of the buffer being manipulated, or the file for a read or
write. E495
:<abuf>
<abuf>
<abuf>
When executing autocommands, is replaced with the currently
effective buffer number. It is not set for all events,
also see bufnr(). For ":r file" and ":so file" it is the
current buffer, the file being read/sourced is not in a
buffer. E496
:<amatch>
<amatch>
<amatch>
When executing autocommands, is replaced with the match for
which this autocommand was executed. E497
It differs from <afile>
when the file name isn't used to
match with (for FileType, Syntax and SpellFileMissing
events).
When the match is with a file name, it is expanded to the
full path.
:<sfile>
<sfile>
<sfile>
When executing a :source
command, is replaced with the
file name of the sourced file. E498
When executing a function, is replaced with the call stack,
as with <stack>
(this is for backwards compatibility, using
<stack>
or <script>
is preferred).
Note that filename-modifiers are useless when <sfile>
is
not used inside a script.
:<stack>
<stack>
<stack>
is replaced with the call stack, using
"function {function-name}
[{lnum}
]" for a function line
and "script {file-name}
[{lnum}
]" for a script line, and
".." in between items. E.g.:
"function {function-name1}
[{lnum}
]..{function-name2}[{lnum}
]"
If there is no call stack you get error E489
.
:<script>
<script>
<script>
When executing a :source
command, is replaced with the file
name of the sourced file. When executing a function, is
replaced with the file name of the script where it is
defined.
If the file name cannot be determined you get error E1274
.
:<slnum>
<slnum>
<slnum>
When executing a :source
command, is replaced with the
line number. E842
When executing a function it's the line number relative to
the start of the function.
:<sflnum>
<sflnum>
<sflnum>
When executing a script, is replaced with the line number.
It differs from <slnum>
in that <sflnum>
is replaced with
the script line number in any situation. E961
filename-modifiers
:_%:
::8
::p
::.
::~
::h
::t
::r
::e
::s
::gs
::S
%:8
%:p
%:.
%:~
%:h
%:t
%:r
%:e
%:s
%:gs
%:S
The file name modifiers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
"<afile>" or "<abuf>". They are also used with the fnamemodify() function.
These modifiers can be given, in this order:
:p Make file name a full path. Must be the first modifier. Also
changes "~/" (and "~user/" for Unix) 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 MS-Windows an 8.3 filename is expanded to the long name.
:8 Converts the path to 8.3 short format (currently only on
MS-Windows). Will act on as much of a path that is an
existing path.
:~ Reduce file name to be relative to the home directory, if
possible. File name is unmodified if it is not below the home
directory.
:. Reduce file name to be relative to current directory, if
possible. File name is unmodified if it is not below the
current directory.
For maximum shortness, use ":~:.".
:h Head of the file name (the last component and any separators
removed). Cannot be used with :e, :r or :t.
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 "/" for
Unix; "x:\" for Win32), that part is not removed.
When there is no head (path is relative to current directory)
the result is empty.
:t Tail of the file name (last component of the name). Must
precede any :r or :e.
:r Root of the file name (the last extension removed). When
there is only an extension (file name that starts with '.',
e.g., ".nvimrc"), it is not removed. Can be repeated to
remove several extensions (last one first).
:e 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) as much as possible are included.
:s?pat?sub?
Substitute the first occurrence of "pat" with "sub". This
works like the :s command. "pat" is a regular expression.
Any character can be used for '?', but it must not occur in
"pat" or "sub".
After this, the previous modifiers can be used again. For
example ":p", to make a full path after the substitution.
:gs?pat?sub?
Substitute all occurrences of "pat" with "sub". Otherwise
this works like ":s".
:S Escape special characters for use with a shell command (see
shellescape()). Must be the last one. Examples::!dir <cfile>:S :call system('chmod +w -- ' . expand('%:S'))Examples, when the file name is "src/version.c", current dir "/home/mool/vim":
:p /home/mool/vim/src/version.c :p:. src/version.c :p:~ ~/vim/src/version.c :h src :p:h /home/mool/vim/src :p:h:h /home/mool/vim :t version.c :p:t version.c :r src/version :p:r /home/mool/vim/src/version :t:r version :e c :s?version?main? src/main.c :s?version?main?:p /home/mool/vim/src/main.c :p:gs?/?\\? \home\mool\vim\src\version.cExamples, when the file name is "src/version.c.gz":
:p /home/mool/vim/src/version.c.gz :e gz :e:e c.gz :e:e:e c.gz :e:e:r c :r src/version.c :r:e c :r:r src/version :r:r:r src/version
extension-removal
:_%<
If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
name is removed (everything after and including the last '.' in the file
name). This is included for backwards compatibility with version 3.0, the
":r" form is preferred. Examples:% current file name %< current file name without extension # alternate file name for current window #< idem, without extension #31 alternate file number 31 #31< idem, without extension <cword> word under the cursor <cWORD> WORD under the cursor (see |WORD|) <cfile> path name under the cursor <cfile>< idem, without extensionNote: Where a file name is expected wildcards expansion is done. On Unix the shell is used for this, unless it can be done internally (for speed). Backticks work also, like in
:n `echo *.c`But expansion is only done if there are any wildcards before expanding the '%', '#', etc.. This avoids expanding wildcards inside a file name. If you want to expand the result of
<cfile>
, add a wildcard character to it.
Examples: (alternate file name is "?readme?")
command expands to:e # :e ?readme? :e `ls #` :e {files matching "?readme?"} :e #.* :e {files matching "?readme?.*"} :cd <cfile> :cd {file name under cursor} :cd <cfile>* :cd {file name under cursor plus "*" and then expanded}Also see `=.
filename-backslash
For filesystems that use a backslash as directory separator (Windows
filesystems), it's a bit difficult to recognize a backslash that is used
to escape the special meaning of the next character. The general rule is: If
the backslash is followed by a normal file name character, it does not have a
special meaning. Therefore "\file\foo" is a valid file name, you don't have
to type the backslash twice.command-line-window
In the command-line window the command line can be edited just like editing
text in any window. It is a special kind of window, because you cannot leave
it in a normal way.E11
E1188
The command-line window is not a normal window. It is not possible to move to
another window or edit another buffer. All commands that would do this are
disabled in the command-line window. Of course it _is_ possible to execute
any command that you entered in the command-line window. Other text edits are
discarded when closing the window.<CR>
Execute the command-line under the cursor. Works both in
Insert and in Normal mode.
CTRL-C Continue in Command-line mode. The command-line under the
cursor is used as the command-line. Works both in Insert and
in Normal mode. There is no redraw, thus the window will
remain visible.
:quit Discard the command line and go back to Normal mode.
":close", CTRL-W
c, ":exit", ":xit" and CTRL-\
CTRL-N
also
work.
:qall Quit Vim, unless there are changes in some buffer.
:qall! Quit Vim, discarding changes to any buffer.<CR>
are lost.:autocmd CmdwinEnter * map <buffer> <F5> <CR>q:
<Tab>
, and the command-line window is used
for an Ex command, then two mappings will be added to use <Tab>
for completion
in the command-line window, like this::inoremap <buffer> <Tab> <C-X><C-V> :nnoremap <buffer> <Tab> a<C-X><C-V>Note that hitting
<Tab>
in Normal mode will do completion on the next
character. That way it works at the end of the line.
If you don't want these mappings, disable them with:au CmdwinEnter [:>] iunmap <buffer> <Tab> au CmdwinEnter [:>] nunmap <buffer> <Tab>You could put these lines in your vimrc file.
autocmd CmdWinEnter [:>] syntax sync minlines=1 maxlines=1
:au CmdwinEnter : let b:cpt_save = &cpt | set cpt=. :au CmdwinLeave : let &cpt = b:cpt_saveThis sets 'complete' to use completion in the current window for i_CTRL-N. Another example:
:au CmdwinEnter [/?] startinsertThis will make Vim start in Insert mode in the command-line window.
cmdline-char
cmdwin-char
The character used for the pattern indicates the type of command-line:
: normal Ex command
> debug mode command debug-mode
/ forward search string
? backward search string
= expression for "= expr-register
@ string for input()
-
text for :insert or :append