2

I just discovered that I am able to use ${ENVVAR}more_text in a vim installation on Unix, but not if installed on Windows.

In Unix, I did in a shell:

export ABC=/tmp/
echo foo>${ABC}foo
gvim

Then, in the newly opened gvim Window, I tried

:e ${ABC}foo

which opened /tmp/foo, as expected.

In Windows, however, I did (cmd.exe):

set ABC=c:\temp\
echo foo > %ABC%foo
gvim

then, in gvim

:e ${ABC}foo

which opened a (non existing) file literally named ${ABC}foo (which is not what I expected).

Is there a way to have vim expand the expression ${ABC} on Windows as well, or an equipotent alternative?

I realize, that for this simple example, I could define the environment variable without trailing slash and add the slash in the :e command while not using the braces at all. Yet, I want to achieve something more complex than that so that I fell I sort of need the ${ABC} construct.

Edit

As per murus comment: in Windows, after starting gvim, if I do echo $ABC, gvim prints c:\temp\.

3
  • If you do echo $ABC in Windows Vim, do you get any output?
    – muru
    Commented May 14, 2016 at 10:58
  • Yes, it prints c:\temp\ Commented May 14, 2016 at 11:10
  • 1
    Based on a loose interpretation of :h $HOME, ${…} is only for Unix. What if you do exe 'e' $ABC . "foo"?
    – muru
    Commented May 14, 2016 at 11:17

1 Answer 1

3

I tried to use backtick expansion, but that does not seem to be working on Windows. So I think the easiest solution is something like this: :exe ":e" $ABC."foobar.txt"

Your Answer

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

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