Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to add something like

let coffee_compiler = '~/repos/coffee-script/bin/coffee'

to my .vimrc, but vim won't expand the ~ (obviously since it's not my shell).

How can I make this work without including my username? (I am sharing the vimrc file across multiple hosts, so hard-coding the username is a no-no.)

share|improve this question
up vote 4 down vote accepted

There are two ways to solve this:

The built-in expand() function handles special characters and wildcards like the shell:

let coffee_compiler = expand('~/repos/coffee-script/bin/coffee')

Or, since ~ corresponds to the HOME environment variable, you can concatenate its value:

let coffee_compiler = $HOME . '/repos/coffee-script/bin/coffee'
share|improve this answer

You should be able to use $HOME for this:

let coffee_compiler = "$HOME/repos/coffee-script/bin/coffee"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.