I have a file that looks something like this
\usepackage{tex/Forkurs-1p-2p-laererutdanning-2018-V}
\usepackage{../Sty/hyper}
\begin{document}
\input{tex/Forkurs-1p-2p-laererutdanning-2018-V-frontmatter.tex}
\input{tex/Forkurs-1p-2p-laererutdanning-2018-V-del-1.tex}
\input{tex/Forkurs-1p-2p-laererutdanning-2018-V-del-2.tex}
\end{document}
I am trying to create two commands
nmap <leader>en
nmap <leader>ep
To increase and decrease the year in the file and swap H with V and V with H. Invoking <leader>en
should increase the year when the year is preceeded by an H. e.g YEAR-H
. While the command should swap H with V and V with H.
2018-V
2018-H
2019-V
2019-H
2020-V
2020-H
.
.
.
Similarly <leader>ep
should decrease the numbers when the number is preceeded by V. Always swap V with H and vice versa.
2018-V
2017-H
2017-V
2016-H
2016-V
2015-H
.
.
.
However I am not sure how to perform a conditional search replace from vim. Any suggestions?
EDIT: To clarify the increase function should work like this
IF H
Increase year
Toggle VH (Change H to V and V to H)
So only increase the year when the text contains YEAR-H
. Always swap H and V.
The decrease function should work similarly
IF V
Decrease year
Toggle VH (Change H to V and V to H)
So only decrease the year when the text contains YEAR-V
. Always swap H with V and vice-versa.