Ingo Karkat wrote:
On 11-Mar-2014 15:14 +0100, Ben Fritz wrote:
<snip>
Isn't this situation what shellescape() is designed for?
That's not saying shellescape() will work, but I think it's supposed
to work, unlike using a bare % which should always work for internal
Vim commands but will only work by accident in external commands.
No, shellescape() would be used in a mapping / command, like this:
shellescape(expand('%'), 1). With the 1 flag (for use with :!), a
literal % is properly escaped to \% so that Vim's special handling does
not apply.
% is handy for interactive use, like :!perl %
shellescape() is for use in a shell command argument being passed to the
shell. The documentation even shows an example of using a filter.
fnameescape() is for internal-vim use involving filenames (ie. avoid
having % have magic with exe when you don't want it to).
% is replaced with the current file name, just as it is typed. (see :he
_%).
So, if the current filename contains spaces, that's what you can expect
to see with the expansion.
The right way to do what the OP wants:
:exe "w !diff ".shellescape(expand("%"))
Regards,
Chip Campbell
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.