how to set vimrc tags to use shell environment variables

shell, vi, vim

Solution

you should get username by `$USER` not `$USERNAME`

What is important is that in this particular case, you cannot use `set` to set this option because it only allows you to set it to a single literal value. However, with `let`, you can use Vimscript to obtain the value using a function, for example, or in your case, through concatenation (read more about about options here). Try this instead:

let &tags='/sandbox/'.$USER.'/tags'

To check if the `tags` was set correctly, you could execute:

:set tags?

Or, for the fully-qualified path:

:echo &tags

Problem

I tried but failed and need an expert help. In a .vimrc I have the following: `set tags=/sandbox/myNameIsSam/tags` This works just fine. Inside gvim, I can load the tags file and everything is awesome. However, I would like for each user to have their own project tags file. How and why is not important here. The below setting doesn't seem to do what I need. Can someone help? ``` let projectTagFile='/sandbox/'.$USERNAME.'/tags' set tags=projectTagFile ```

Original source