From e547d0c01e16262cbff6b91812518e84494d30a9 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Tue, 16 Aug 2022 15:23:18 +0200 Subject: [PATCH] Add cloze helpers --- .vim/ftplugin/pandoc/anki.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .vim/ftplugin/pandoc/anki.vim diff --git a/.vim/ftplugin/pandoc/anki.vim b/.vim/ftplugin/pandoc/anki.vim new file mode 100644 index 0000000..2e3f3c9 --- /dev/null +++ b/.vim/ftplugin/pandoc/anki.vim @@ -0,0 +1,22 @@ +" Anki helper functions + +" Convert cloze note to regular text +" +" * `AnkiRemoveAllClozes` all cloze notes in file +" * `AnkiRemoveSelectedClozes` all clozes in selected range +" +" E.g. +" +" ```markdown +" START +" Cloze +" In this sentence {{c1::this word}} was closed. +" END +" ``` +" +" ```markdown +" In this sentence this word was closed. +" ``` + +au FileType pandoc com! -range AnkiRemoveAllClozes :%s/{{c\d\+:://ge | :%s/}}//ge | :%s/START\nCloze\n//ge | :%s/END\n//ge +au FileType pandoc com! -range AnkiRemoveSelectedClozes :%s/\%V{{c\d\+:://ge | :%s/\%V}}//ge | :%s/\%VSTART\nCloze\n//ge | :%s/\%VEND\n//ge