Expanding variables

0 views
Skip to first unread message

Matteo Riva

unread,
Nov 8, 2009, 7:52:13 AM11/8/09
to vim...@googlegroups.com
If I have these lines in a script:

let filename = something
new filename

new takes the literal string 'filename' instead of expanding it and
using its value. How can I tell :new to expand the variable instead?

Thanks

Christian Brabandt

unread,
Nov 8, 2009, 7:56:55 AM11/8/09
to vim...@googlegroups.com
Hi Matteo!

It's because :new is an ex command and expects a filename and not an
expression. Therefore you have to use exe to evaluate an expression.
:exe ":new " . filename

regards,
Christian
--
• Modern PCs are horrible. ACPI is a complete design disaster in every way.
But we're kind of stuck with it. If any Intel people are listening to this
and you had anything to do with ACPI, shoot yourself now, before you
reproduce.
Linus Torvalds

Tim Chase

unread,
Nov 8, 2009, 8:05:49 AM11/8/09
to vim...@googlegroups.com

You can use exec:

:exec 'new '.filename

-tim


Reply all
Reply to author
Forward
0 new messages