Search code examples
vimspork

Configure vimrc based on environment variables


Is it possible to configure vimrc command mapping based on env variables?

For example, I'm using vim-ruby-test plugin which provides the following config:

let g:rubytest_cmd_test = "ruby %p"

I want to set the command differently based on whether i'm running tests using spork or not:

With Spork:

$ TESTDRB=y mvim .
let g:rubytest_cmd_test = "testdrb %p"

Without Spork:

$ mvim .
let g:rubytest_cmd_test = "ruby %p"

Solution

  • if $TESTDRB == 'y'
        let g:rubytest_cmd_test = 'ruby %p'
    endif
    " etc