Vim HTML img tag to markdown


I was quite proud of myself for figuring this one out in only about 2 minutes, in Vim. Starting with an HTML img tag:

<img src="img/jetz_table.png" alt="Functional diversity measures" width="640">

And using this Vim regex:

s/<img src="\(.\{-}\)".*alt="\(.\{-}\)".*/![\2](\1)/g

To create this Markdown formatted image link:

![Functional diversity measures](img/jetz_table.png)

This was my first proper outing using \{-} for non-greedy matching, used on the double quotes ". It also uses capture groups \(.{-}\) -> \1.