What are the rules that :file arguments are escaped?
The argument to :file
is undergoing expand()
function. expand()
expands wildcards and all special keywords. All special characters %
#
<
, modifiers :p
:h
, sequences of <...>
and characters triggering filename expansion *
[
**
?
need to be escaped.
How to pass for example a filename with newline?
Use the function fnameescape()
to escape the argument.
execute "file ".fnameescape("/tmp/[some file]")
The following does nothing:
It does nothing, because you have set wildignore+=/tmp/*
. This causes the glob expression /tmp/[some file]
to expand to nothing, becuase /tmp/
is ignored, so :file /tmp/[some file]
becomes just :file
.