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

Re: pattern substitution in vim script

Expand Messages
  • Benji Fisher
    ... --Benji Fisher
    Message 1 of 2 , May 2, 2002
      Dado Feigenblatt wrote:
      >
      > My $PYTHONPATH changes depending on the project I'm working on.
      > So I have this in my .vimrc
      >
      > set path+=$PYTHONPATH
      >
      > The path is getting set.
      > The problem is that $PYTHONPATH is a colon separated list and
      > path expects a comma separated list.
      >
      > I need to do something like
      >
      > set path+= `echo $PYTHONPATH | sed -e 's/:/,/g'`
      >
      > Any suggestion?
      > Thanks

      There are (at least) two ways:

      :let &path = &path . substitute($PYTHONPATH, ":", ",", "g")
      :execute "set path+=" . substitute($PYTHONPATH, ":", ",", "g")

      :help let-option
      :help substiture()
      :help :execute

      --Benji Fisher
    Your message has been successfully submitted and would be delivered to recipients shortly.