Vim-go: Set ENV var before running :GoTest

Created on 26 Sep 2017  路  1Comment  路  Source: fatih/vim-go

Behavior

My project requires to set some env var before running go test. How can configure vim-go to do something like source .env.dev && go test ... upon calling :GoTest in vim?

Most helpful comment

You can use the $ notation to set environment variables in Vim:

let $MY_ENV_VAR = "my value"

You can chain Vim commands with |:

:let $MY_ENV_VAR = "my value" | :GoTest

Of course, that's some typing so you may want to use a command:

:command! GoTestEnv let $MY_ENV_VAR = "my value" | :GoTest

(note: if you use a mapping then read :help map-bar).

If you want to source a file then you can use the :source command on a file that has a bunch of let $ENV = "value" commands.

>All comments

You can use the $ notation to set environment variables in Vim:

let $MY_ENV_VAR = "my value"

You can chain Vim commands with |:

:let $MY_ENV_VAR = "my value" | :GoTest

Of course, that's some typing so you may want to use a command:

:command! GoTestEnv let $MY_ENV_VAR = "my value" | :GoTest

(note: if you use a mapping then read :help map-bar).

If you want to source a file then you can use the :source command on a file that has a bunch of let $ENV = "value" commands.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielmanesku picture danielmanesku  路  4Comments

zhangjing picture zhangjing  路  3Comments

MattFlower picture MattFlower  路  4Comments

surest picture surest  路  3Comments

preslavmihaylov picture preslavmihaylov  路  3Comments