Tuesday, February 1, 2011

Re: value of a variable within a expression

Reply to message «value of a variable within a expression»,
sent 04:04:51 02 February 2011, Wednesday
by Jonas Geiregat:

> !stylus < '%:p' > s:nfile
>
> This doesn't work and really runs !stylus < whatever_is_the_current_file >
> s:nfile.
>
> I've tried everything from echo s:nfile to let s:nfile within the
> expression.
You should use :execute in such cases:
execute '!stylus < '.shellescape(expand('%:p'), 1).
\' > '.shellescape(s:nfile, 1)
Note that using «'%:p'» is not sufficient to escape filename: try it when
filename contents odd number of a single quotes.

Original message:
> Hello,
>
> You have to excuse me if this is a silly question. But as you might have
> guessed I'm new to vim.
>
> I've defined a variable s:nfile and want to use it in the following
> expression.
>
> !stylus < '%:p' > s:nfile
>
> This doesn't work and really runs !stylus < whatever_is_the_current_file >
> s:nfile.
>
> I've tried everything from echo s:nfile to let s:nfile within the
> expression.
>
> Thanks in advance,
>
> Jonas Geiregat.

No comments:

Post a Comment