1

The following does nothing:

:file /tmp/[some file]

or:

:file "/tmp/[some file]"

The following set's the file to /tmp/[some file]:

:file /tmp/\[some file]

What are the rules that :file arguments are escaped? How to pass for example a filename with newline?

1
  • "filename with newline" raargh
    – romainl
    Aug 26 at 13:46

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.