Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set vimrc tags to use shell environment variables

Tags:

shell

vim

vi

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
like image 613
user2019842 Avatar asked Jan 28 '13 22:01

user2019842


1 Answers

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
like image 145
Kent Avatar answered Sep 26 '22 13:09

Kent