When writing a beamer presentation with LaTeX, I organize my presentation into sections and subsections. Frequently, the title of the first frame (slide) in a subsection has the same name as the subsection. Let’s say I start off with the following structure:
GeSHi Error: GeSHi could not find the language tex (using path /home/robfelty/robfelty.com/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
For each subsection, I want to put in one frame, with the name of the subsection being the name of the frame. Regular expressions to the rescue! In vim, all I have to is use V to select each line with subsection, then I hit :, which allows me to operate on those lines only.
'<,'>
is automatically inserted after the colon, which stands for “from the beginning of the highlighted section to the end of it”. Then I use s to perform my substitution. \r inserts a new line.
:'<,'>s/{\(.*\)}/{\1}\r\\begin{frame}\r\\frametitle<presentation>{\1}\r\\end{frame}/
The result is:
GeSHi Error: GeSHi could not find the language tex (using path /home/robfelty/robfelty.com/wp-content/plugins/codecolorer/lib/geshi/) (code 2)
Pingback: Jürgen Fenn (juergenfenn) 's status on Thursday, 24-Sep-09 17:50:33 UTC - Identi.ca
Instead of selecting lines, you can also do
The advantage is that it will work even if you have other text between the lines with \subsection.
Pingback: hlavacek