output like for |:list|
# add line number
p output like for |:print|
The flags can be combined, thus "l#" uses both a line number and |:list| style
output.
==============================================================================
6. Ex special characters *cmdline-special*
Note: These are special characters in the executed command line. If you want
to insert special things while typing you can use the 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|.
Note: If you want to avoid the effects of special characters in a Vim script
you may want to use |fnameescape()|. Also see |`=|.
In Ex commands, at places where a file name can be used, the following
characters have a special meaning. These can also be used in the expression
function |expand()|.
% Is replaced with the current file name. *:_%* *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*
Note that these, except "#<n", give the file name as it was typed. If an
absolute path is needed (when using the file name from a different directory),
you need to add ":p". See |filename-modifiers|.
The "#<n" item returns an absolute path, but it will start with "~/" for files
below your home directory.
Note that backslashes are inserted before spaces, so that the command will
correctly interpret the file name. But this doesn't happen for shell
commands. For those you probably have to use quotes (this fails for files
that contain a quote and wildcards): >
:!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.
you type: result ~
# alternate.file
\# #
\\# \#
Also see |`=|.
*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*