I have a LaTeX
file with a bunch of commands of the form \label{<word>}
where the <word>
represents a string that contains special characters, namely á é í ó ú ý ð þ æ ö
. I'm looking for a quick way to change the special characters into a corresponding ASCII character(s): a e i o u y dh th ae oe
. To give an example, I want to change \label{orðabók}
to \label{ordhabok}
.
If I wanted just to change, for example, all þ's to th, I would visually select the word inside the \label{}
, exit to normal mode and then use
:s/\%Vþ/th/ge
And I could give two such commands at the same time using |
, e.g.
:s/\%Vþ/th/ge|s/\%Vð/dh/ge
I guess I could just string together all ten commands, but I was hoping for a more elegant way. In particular, I would like to not have to write the \%V
and the g
every time.
A follow-up question: I have to do this for every \label{}
command in a very long file, and I plan to make a macro or commmand that automates it. My plan was to make a macro that searches for the next occurance of \label{
, visually selects the word inside the {}
, and performs the substitutions I described above. Then I would just count the \label
commands and run the macro that many times. If I get help with the first question, then I know how to implement this. But is there another method that would be faster for a very long file?