directories deep.
Note there are some commands where this works slightly differently, see
|file-searching|.
Example: >
:n **/*.txt
Finds files:
aaa.txt ~
subdir/bbb.txt ~
a/b/c/d/ccc.txt ~
When non-wildcard characters are used right before or after "**" these are
only matched in the top directory. They are not used for directories further
down in the tree. For example: >
:n /usr/inc**/types.h
Finds files:
/usr/include/types.h ~
/usr/include/sys/types.h ~
/usr/inc/old/types.h ~
Note that the path with "/sys" is included because it does not need to match
"/inc". Thus it's like matching "/usr/inc*/*/*...", not
"/usr/inc*/inc*/inc*".
*backtick-expansion* *`-expansion*
On Unix and a few other systems you can also use backticks for the file name
argument, for example: >
:next `find . -name ver\\*.c -print`
:view `ls -t *.patch \| head -n1`
Vim will run the command in backticks using the 'shell' and use the standard
output as argument for the given Vim command (error messages from the shell
command will be discarded).
To see what shell command Vim is running, set the 'verbose' option to 4. When
the shell command returns a non-zero exit code, an error message will be
displayed and the Vim command will be aborted. To avoid this make the shell
always return zero like so: >
:next `find . -name ver\\*.c -print \|\| true`
The backslashes before the star are required to prevent the shell from
expanding "ver*.c" prior to execution of the find program. The backslash
before the shell pipe symbol "|" prevents Vim from parsing it as command
termination.
This also works for most other systems, with the restriction that the
backticks must be around the whole item. It is not possible to have text
directly before the first or just after the last backtick.
*`=*
You can have the backticks expanded as a Vim expression, instead of as an
external command, by putting an equal sign right after the first backtick,
e.g.: >
:e `=tempname()`
The expression can contain just about anything, thus this can also be used to
avoid the special meaning of '"', "|", '%' and '#'. However, 'wildignore'
does apply like to other wildcards.
Environment variables in the expression are expanded when evaluating the
expression, thus this works: >
:e `=$HOME .. '/.vimrc'`
This uses $HOME inside a string and it will be used literally, most likely not
what you intended: >
:e `='$HOME' .. '/.vimrc'`
If the expression returns a string then names are to be separated with line
breaks. When the result is a |List| then each item is used as a name. Line
breaks also separate names.
Note that such expressions are only supported in places where a filename is
expected as an argument to an Ex-command.
*++opt* *[++opt]*
The [++opt] argument can be used to set some options for one command, and to
specify the behavior for bad characters. The form is: >
++{optname}
Or: >
++{optname}={value}
Where {optname} is one of: *++ff* *++enc* *++bin* *++nobin* *++edit*
ff or fileformat overrides 'fileformat'
enc or encoding overrides 'fileencoding'
bin or binary sets 'binary'
nobin or nobinary resets 'binary'
bad specifies behavior for bad characters
edit for |:read|: keeps options as if editing a file
p for |:write|: creates the file's parent directory
{value} cannot contain whitespace. It can be any valid value for the options.
Examples: >
:e ++ff=unix
This edits the same file again with 'fileformat' set to "unix". >
:w ++enc=latin1 newfile
This writes the current buffer to "newfile" in latin1 format.
The message given when writing a file will show "[converted]" when
'fileencoding' or the value specified with ++enc differs from 'encoding'.
There may be several ++opt arguments, separated by whitespace. They must all
appear before any |+cmd| argument.
*++p*
The "++p" flag creates the parent directory of the file if it does not exist.
For example if you edit "foo/bar/file.txt",