I would like to the present working directory (:pwd
) be changed across all tabs and subwindows at the same time. I tried:
let PreferredPWD=expand('%:p:h') " The desired working directory
" Need to replace PreferredPWD with its string.
" None of the following work:
tabdo windo cd PreferredPWD
cd(PreferredPWD)
cd &PreferredPWD
cd =PreferredPWD
cd $PreferredPWD
How does one replace the variable name with its contents?
Afternote
The following uses register a to work around my ignorance of how to replace a variable name with the variable content, but I'd still be interested in how such replacement is done in VimScript.
let @a=expand('%:p:h')
tabdo windo cd <Ctrl+R><Ctrl+A>