Loading ...
Sorry, an error occurred while loading the content.

56854Re: passing local variable to shell howto

Expand Messages
  • A. J. Mechelynck
    Mar 1, 2005
    • 0 Attachment
      Shaw Vrana wrote:
      > Hi All,
      > I'm trying to write a simple vim function that prompts me for a filename and
      > then calls an external shell script with the entered filename, and then loads
      > the file. Here's what I have so far.
      > fun! GetFile()
      > let myfilename = input("Filename? )
      > !my_script myfilename
      > e myfilename
      > endfun
      > This almost works, but it doesn't look like my_script is getting the value I
      > entered for myfilename, though it is being assigned the value, and my_script
      > is being called. I guess this is b/c I'm using the ! operator? How can I
      > call my_script with the myfilename input?
      > Any pointers or help pages greatly appreciated!
      > Thanks,
      > Shaw
      With the above, both the script and the ":e" command will get
      "myfilename" (i.e., the name, not the contents, of the Vim variable). Try

      exe "!my_script" myfilename
      exe "edit" myfilename


    • Show all 3 messages in this topic