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

Piping Vim Variables to Shell Execution

Expand Messages
  • Alejandro Calbazana
    Hello, Can anyone help me with how to pipe a variable (in this case a ... Since the context of my project is already set up, I d hate to have to open a shell
    Message 1 of 4 , Aug 31, 2005
    • 0 Attachment
      Hello,

      Can anyone help me with how to pipe a variable (in this case a
      classpath) to shell execution. For example:

      :!echo expand('$CLASSPATH')

      :!java -cp expand('$CLASSPATH') MyClass

      Since the context of my project is already set up, I'd hate to have to
      open a shell and retype the classpath :)

      Thanks,

      Alejandro
    • David Rennalls
      ... Try creating the full command string and then passing it to :exe for e.g. ... - David
      Message 2 of 4 , Aug 31, 2005
      • 0 Attachment
        On 8/31/05, Alejandro Calbazana <acalbaza@...> wrote:
        > Hello,
        >
        > Can anyone help me with how to pipe a variable (in this case a
        > classpath) to shell execution. For example:
        >
        > :!echo expand('$CLASSPATH')
        >
        > :!java -cp expand('$CLASSPATH') MyClass
        >
        > Since the context of my project is already set up, I'd hate to have to
        > open a shell and retype the classpath :)
        >
        > Thanks,
        >
        > Alejandro

        Try creating the full command string and then passing it to :exe
        for e.g.
        :exe '!java -cp' . expand('$CLASSPATH') . ' MyClass'

        - David
      • Tony Mechelynck
        ... From: Alejandro Calbazana To: Sent: Wednesday, August 31, 2005 9:04 PM Subject: Piping Vim Variables to Shell
        Message 3 of 4 , Aug 31, 2005
        • 0 Attachment
          ----- Original Message -----
          From: "Alejandro Calbazana" <acalbaza@...>
          To: <vim@...>
          Sent: Wednesday, August 31, 2005 9:04 PM
          Subject: Piping Vim Variables to Shell Execution


          > Hello,
          >
          > Can anyone help me with how to pipe a variable (in this case a
          > classpath) to shell execution. For example:
          >
          > :!echo expand('$CLASSPATH')
          >
          > :!java -cp expand('$CLASSPATH') MyClass
          >
          > Since the context of my project is already set up, I'd hate to have to
          > open a shell and retype the classpath :)
          >
          > Thanks,
          >
          > Alejandro

          Since $CLASSPATH is an environment variable, what about

          :!java-cp $CLASSPATH MyClass

          (using some Unix shell, if a space is needed between the two) or

          :!java-cp ${CLASSPATH}MyClass

          (using bash shell, if no space is needed between the two) or

          :!java-cp \%CLASSPATH\%MyClass

          (using COMMAND.COM or CMD.EXE shell)?

          Warning: all the above are untested: try them first with :!echo


          Best regards,
          Tony.
        • Mikolaj Machowski
          ... HTH m.
          Message 4 of 4 , Aug 31, 2005
          • 0 Attachment
            Dnia środa, 31 sierpnia 2005 21:04, Alejandro Calbazana napisał:
            > Hello,
            >
            > Can anyone help me with how to pipe a variable (in this case a
            >
            > classpath) to shell execution. For example:
            > :!echo expand('$CLASSPATH')
            > :
            > :!java -cp expand('$CLASSPATH') MyClass
            >

            :help exe

            :exe "!java -cp ".expand('$CLASSPATH')." MyClass"

            HTH

            m.
          Your message has been successfully submitted and would be delivered to recipients shortly.