On Monday, July 20, 2015 at 5:38:10 PM UTC-4, Roland Eggner wrote:
...
> I reproduced with vim-7.4.529:
> 
> :e `=$HOME . '/.vimrc'`
> E15: Invalid expression: /home/roland . '/.vimrc'
> "`=/home/roland . '/.vimrc'`" [New DIRECTORY]
> :e `=expand('$HOME') . '/vimrc'`
> :ls
>   1 #    "`=/home/roland . '/.vimrc'`"  line 1
>   3 %a   "~/.vimrc"                     line 1

Hi Roland,

The variant with expand() works, because it happens to quote the
value of $HOME, in other words

    :e `= expand('$HOME') . '/.vimrc' `

replaces the back-ticked string with the result of VimL expression

    expand('/home/roland') . './vimrc'

It actually also works without the expand() call:

    :e `= '$HOME' . '/.vimrc' `
    [ backticks replaced with --> '/home/roland' . '/.vimrc' ]

I'd however expect this to open a .vimrc file in a literal
<Dollar>HOME directory.

> The usual solution for this type of error is insertion of a call to expand(),
> this works for me in this case too, thus I would not consider the issue as 
> bug.

>From my point of view this is a bug, because per Vim documentation
`={expr}` should accept VimL expressions, and

    $HOME . '/.vimrc'

is a perfectly legitimate expression.  The fact that the expand()
works is not relevant and in actuality is just a coincidence.
The expand() function does not do anything, it is the quoting of
the prematurely-expanded $HOME that matters.

...
> >     :let f = 'filename with special characters *#'
> >     :execute 'edit' fnameescape(f)
> >     :edit `=f`
> 
> For me the former has the advantages
> •  well documented
> •  works at any place, where strings are expected in ex-commands
> •  I use it frequently every day in vim scripts (rather rarely at the vim
>    commandline, because I load files mostly by loading session files, by a vim
>    command of the “gf” family, or by calling vim from another utility like 
> mutt,
>    git, hg, mc, zsh, …)
> 
> whereas the latter
> •  works only at places, where filenames are expected as arguments to
>    ex-commands
> •  to me the syntax looks obscure and against intuition


It is a matter of taste.  If Vim has the  `=  feature, it would
be nice to have it handle the environment variables as all the
other VimL expressions do.

Best regards,

Pavol

-- 
-- 
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.

Raspunde prin e-mail lui