Jim
Jim

Reputation: 11379

Is there a way to append a folder to the PATH environment variable in vimrc?

I'm running portable python and portable gvim. When I run gVimPortable, I want it to append python to the PATH environment variable. This is the command I would run in a command prompt:

path=%path%;C:\portable\PortablePython_1.1_py2.5.4

Is there a way to automate this in the vimrc file or some other way?

Upvotes: 11

Views: 3304

Answers (1)

jamessan
jamessan

Reputation: 42647

You can change environment variables inside Vim using the :let command.

let s:portablepy = 'C:\portable\PortablePython_1.1_py2.5.4'
" Add PortablePython's path to $PATH if running on Windows and PortablePython exists
if (has('win32') || has('win64')) && isdirectory(s:portablepy)
    let $PATH .= ';' . s:portablepy
endif

Upvotes: 12

Related Questions