Reputation: 5217
I had some latex tables, that needed some header formating:
\begin{tabular}{|l|l|l|}
\hline
Foo bar bla & blabar & sdf \\
\hline
[table content]
\end{tablular}
where all items in the first row should get a \textbf{}
tag.
\begin{tabular}{|l|l|l|}
\hline
\textbf{Foo bar bla} & \textbf{blabar} & \textbf{sdf} \\
\hline
[table content]
\end{tablular}
my macro goes like this:
^
qq
i
\textbf{<ESC>
f&
h
i
}<ESC>
ww
q
2@q
on the last item i dont get the closing bracket, because there is no more &
. how can i jump with vim to to next occurence of &
or \\
?
Upvotes: 1
Views: 430
Reputation: 195039
you could use :s
instead of macro:
s/\(.*\)\\\\/\='\\textbf{' . substitute(submatch(1),'&','} & \\textbf{','g') . "}\\\\"/
Upvotes: 1
Reputation: 196496
Instead of:
f&
you could do a search:
/\v [&\\]
which will land you on the space before &
and \
, ready to do:
i}
\v
means "very magic" and allows us to save some \
.
Upvotes: 2