[Tex/LaTex] Using \newcommand and \input

input

I like to use variables for my paths, so that if I migrate to another system/username, I don't have to change every path name. This does not seem to be working with the input command. I have the following in my main.tex file:

\newcommand{\rootFolder}{/home/user/Documents/tex}
....
\input{\rootFolder/foo/bar.tex}

But I get the following error.

1 || ** \rootFolder/foo/bar.tex:     
2 main.tex|86 error| Could not open "\rootFolder/foo/bar.tex"

My spider senses tell me it is not expanding \rootFolder. Can anyone tell me what I am doing wrong?

EDIT User Peter Grill asked me for a minimal working example (MWE) so here it is. Also, I should have mentioned that I am getting this error from inside Vim.

test.tex:

hello world

main.tex (local path):

\documentclass{article}
\begin{document}
\input{test.tex}
\end{document}

% Works Fine

main.tex (variable):

\newcommand{\rootFolder}{/home/user/Documents}

\documentclass{article}
\begin{document}
\input{\rootFolder/test.tex}
\end{document}

% Vim Error:
% 1 || ** \rootFolder/test.tex:                                                                                                                                      
% 2 main.tex|5 error| Could not open "\rootFolder/test.tex"

main.tex (edef):

\newcommand{\rootFolder}{/home/user/Documents}

\documentclass{article}
\begin{document}
\edef\ExpandedFileName{\rootFolder/test.tex}\input{\ExpandedFileName}
\end{document}

% Vim Error:
% 1 || ** \ExpandedFileName:                                                                                                                                      
% 2 main.tex|5 error| Could not open "\ExpandedFileName"

main.tex (no edef):

\newcommand{\rootFolder}{/home/user/Documents}

\documentclass{article}
\begin{document}
\ExpandedFileName{\rootFolder/test.tex}\input{\ExpandedFileName}
\end{document}

% Vim Error:
% 1 || ** \ExpandedFileName:                                                                                                                                      
% 2 main.tex|5 error| Could not open "\ExpandedFileName"
% pdflatex Error:
% Undefined control sequence.
% l.5     \ExpandedFileName{\rootFolder/test.tex}\input{\ExpandedFileN...

main.tex (expandafter):

\newcommand{\rootFolder}{/home/user/Documents}

\documentclass{article}
\begin{document}
\expandafter\input\expandafter{\rootFolder/test.tex}
\end{document}

% Vim Error:
% 1 test.tex|5 error| Don't use "\expandafter" in LaTeX documents

Best Answer

Looking at the output you show this is not a Tex error (and presumably LaTeX handles your code correctly) it is an error from Vim, by which I assume you are using the editor that isn't emacs:-) It looks like you are using a Vim mode that thinks it understands TeX syntax and is trying to do something useful, but actually it doesn't understand the full command usage.