Cory Echols wrote:
> Hi all,
>
> I can't get ex-command expansion of the '%' token to work with this
> vim tip: 
> http://vim.wikia.com/wiki/Display_shell_commands%27_output_on_Vim_window.
>
> I've put the vimscript from the tip into a file named "test.vim" and
> run vim with
>
> vim --noplugin -u test.vim -U NONE test.txt
>
> I would now expect ":Shell cat %" to display the text of "test.txt" in
> a split window.  (The tip wiki page implies that this should work).
> However it does not.  I get a split window containing only the text
> put into the window by the "setline()" call in the linked script.
>
> If I remove "silent" from the invocation of :read, I discover that the
> '%' is passed to the shell without being expanded by vim.  If I remove
> the call to "escape(a:cmdline, '%#')" I get:
>
> Error 499:  Empty file name for '%' or '#' only works with ":p:h"
>
> I *think* this means that vim is expanding '%' in the context of the
> new scratch buffer instead of the one I was in when issuing the
> ":Shell" command.
>
> The wiki page gives me the impression that others are having success
> with this, so I'm wondering if their options differ from mine.  I've
> been through the docs for the shell-related options and for :read, but
> they don't lead to any solutions.  Has anyone else gotten this to
> work?
>   
Perhaps RunView will do what you want...

http://vim.sourceforge.net/scripts/script.php?script_id=2511

If not:

* exe "Shell ".fnameescape(expand("%"))

The reason why "%" wasn't expanded: see the line
  execute 'silent $read !'.escape(a:cmdline,'%#')

That escapes all instances of % and/or # .

The help for the use of % (and #) in command lines is at   :help 
cmdline-special  .

Regards,
Chip Campbell


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to