On Fri, Jul 17, 2015 at 09:44:55AM +0200, Roland Eggner wrote:
...
> On 2015-07-16 Thursday at 18:52 +0000 [email protected] wrote:
...
> > What steps will reproduce the problem?
> >
> > vim -u NONE -i NONE -N
> > :e `=$HOME . '/.vimrc'`
> >
> > What is the expected output? What do you see instead?
> >
> > Vim should open the .vimrc file in my HOME directory. Instead I see the
> > following error:
> >
> > E15: Invalid expression: /Users/pjuhas . '/.vimrc'
...
> Your ex-command bears three problems. I will start with the innermost:
>
> (1) vim: E15 “invalid expression”:
> “expand()” should help.
Hi Roland,
Please see :help `= in a recent version of vim. The expression
between `= and the closing backtick should be evaluated as a Vim
expression and not as a shell command. The problem is that
$HOME . '/.vimrc'
is a valid Vim expression, thus the whole command should be the same
as :e /Users/pjuhas/.vimrc. If I do something similar using
a Vim variable instead of environment variable, ie,
:let h = $HOME
:e `=h . '/.vimrc'`
it works as expected. I think what happens is that $HOME gets
expanded before parsing the VimL expression; in other words the
expression parsed is "/Users/pjuhas . '/.vimrc'" instead of
"$HOME . '/.vimrc'".
> (2) shell: “cannot execute …“:
> Your shell probably cannot execute your .vimrc file,
...
I don't see this at all. Are you using a recent version of Vim?
> (3) vim: E172 “The ":edit" command only accepts one file name”:
> Using “:exe” should help:
...
This is an example of a bug in the expansion of `=<expression>`.
I am aware I could use exe or just :e ~/.vimrc.
Thanks,
Pavol
PS: The `= expression has an advantage that it is not further expanded
and can be safely and concisely used with any filenames. Compare:
:let f = 'filename with special characters *#'
:execute 'edit' fnameescape(f)
:edit `=f`
--
--
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.