0

This question already has an answer here:

I have this user defined command:

command! PS silent! w | PlugSnapshot! ~/.vim/plugins/plugins.lock

How could I change it to take the filepath from a variable, something like this:

let PathToPluginsFolder =  ~/.vim/plugins
command! PS silent! w | PlugSnapshot! %%%PathToPluginsFolder%%%/plugins.lock

marked as duplicate by statox Jun 11 at 17:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @statox The question is different, and the answer could've been very different. – ruohola Jun 11 at 18:37
  • I don’t think these are different questions: these are two variations of “how can I use a variable in a vimscript expression?”. By marking this question as a duplicate I’m not arguing against its quality, I just want to make sure that future users can get an answer to their question and I also make sure that we keep together the related contents to give all the answers a better visibility. However you can vote to reopen the question and if the community agrees it will be reopened :) – statox Jun 11 at 20:48
2

Can simply use exec and . to build the command:

let PathToPluginsFolder =  ~/.vim/plugins
command! PS silent! exec ':w | PlugSnapshot! ' . PathToPluginsFolder . '/plugins.lock'

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