# Future-proof command

In my preamble I have:

\newcommand{\myvecb}[1]{\vb{#1}}

Suppose in some math context I use:

\myvecb{F}_y

while in some other I have:

\myvecb{F_T}

My problem

I have noticed that in the future I may want to change all \myvecb{F}_y to \myvecb{F_y} (or, in some other context, perhaps vice versa). Instead of doing everything manually (because a simple regex replace may too complicated for some reason), is it possible to define \myvecb command definition such that I can manipulate the stated-problem within the definition?

• Yes. \makeatletter \newcommand*\myvecb[1]{\@ifnextchar_{\myvecbaux{#1}}{\vb{#1}}} \def\myvecbaux#1_#2{\vb{#1_#2}} \makeatother. – Manuel Jul 6 '17 at 10:53
• @Manuel Thank you. Is your solution just for one character? (For instance I may have \myvecb{F}_{A|B}. – blackened Jul 6 '17 at 11:20
• Ah, add braces around #2 in \vb{#1_{#2}}. – Manuel Jul 6 '17 at 11:33
• Super easy with xparse, I think the new e type was made for this. – daleif Jul 6 '17 at 19:23

This checks if a _ is following and in that case it grabs the following _{..} and puts it as a subscript inside \vb{..}.
\makeatletter