I have the following paragraph in a plain text file that I am viewing (and editing) in Vim:
The synthesis and secretion of estrogens is stimulated by follicle-stimulating hormone (FSH), which is, in turn, controlled by the hypothalamic gonadotropin releasing hormone (GnRH). High levels of estrogens suppress the release of GnRH (bar) providing a negative-feedback control of hormone levels.
I am creating cloze deletion flashcards out of the text in this text file (ie. fill in the blank questions) which I will then feed to a home-made flashcard program I've written. My format for a cloze deletion is as follows:
The synthesis and secretion of [estrogens] is stimulated by [follicle-stimulating hormone]
This would produce two flashcards (when the text file is parsed by my flashcard program):
The synthesis and secretion of [...] is stimulated by follicle-stimulating hormone
The synthesis and secretion of [estrogens] is stimulated by [...]
I would like to automate the creation of these flashcards using Vim. The manual option would be to write a '[' to the beginning of each cloze deletion and a ']' at the end, but this is tedious and I'd like to use Vim's automation abilities. Ideally, I would like to be able to:
- select a region of text to clozeify
- execute a macro on this text
This macro would:
- prepend '[' to the selection
- append ']' to the selection
and exit.
How would I achieve this using Vim? When I try to use Ctrl-R in Visual Selection Mode it doesn't seem to work.
Essentially, the replacement I would like to do is:
:%s/(CONTENT OF VISUAL SELECT)/[(CONTENT OF VISUAL SELECT)]/g