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

Accessing Environmnetal Variable from a vim script

Expand Messages
  • R. shankar
    How do I access an environmental variable from a vim script ? Lets us assume that PLATFORM is an environment variable which can hold two values sun4os5 or
    Message 1 of 3 , Feb 27, 2005
      How do I access an environmental variable from a vim script ?

      Lets us assume that PLATFORM is an environment variable which can hold two values sun4os5 or linux.
      I want to have the script as given below -

      if $PLATFORM = sun4os5
      let cmd = .....
      else
      let cmd = .......
      end if

      How can I do this ?

      Regards,
      shankar
    • Otávio Corrêa Cordeiro
      Hi, Try ... Cya! [ ] s On Sun, 27 Feb 2005 17:47:35 +0530, R. shankar ... -- - Por que o Otávio nunca vai morrer de sede? - Porque no mundo existe muita água
      Message 2 of 3 , Feb 27, 2005
        Hi,

        Try

        :help variables
        :help has

        Cya!
        [ ]'s


        On Sun, 27 Feb 2005 17:47:35 +0530, R. shankar
        <shankar@...> wrote:
        > How do I access an environmental variable from a vim script ?
        >
        > Lets us assume that PLATFORM is an environment variable which can hold two values sun4os5 or linux.
        > I want to have the script as given below -
        >
        > if $PLATFORM = sun4os5
        > let cmd = .....
        > else
        > let cmd = .......
        > end if
        >
        > How can I do this ?
        >
        > Regards,
        > shankar
        >
        >


        --
        - Por que o Otávio nunca vai morrer de sede?
        - Porque no mundo existe muita água potávio

        Otávio C++
        Bacharel em Física
        ICQ #16458106
        GNU/Linux #268791 [http://counter.li.org/%5d
        Homepage: [http://otavio.geek42.org/%5d
      • Antoine J. Mechelynck
        ... Almost as you did. There are minor syntax differences (see :help eval ). So the following will work as a starting point: if $PLATFORM == sun4os5 echomsg
        Message 3 of 3 , Feb 27, 2005
          R. shankar wrote:
          > How do I access an environmental variable from a vim script ?
          >
          > Lets us assume that PLATFORM is an environment variable which can hold two values sun4os5 or linux.
          > I want to have the script as given below -
          >
          > if $PLATFORM = sun4os5
          > let cmd = .....
          > else
          > let cmd = .......
          > end if
          >
          > How can I do this ?
          >
          > Regards,
          > shankar
          >
          >
          >
          >
          >
          Almost as you did. There are minor syntax differences (see ":help
          eval"). So the following will work as a starting point:


          if $PLATFORM == "sun4os5"
          echomsg "sun4os5"
          elseif $PLATFORM == "linux"
          echomsg "linux"
          else
          echoerr "unknown platform <" . $PLATFORM . ">"
          endif

          HTH,
          Tony.
        Your message has been successfully submitted and would be delivered to recipients shortly.