< More Posts

Spaced Recall in Vim

Published 25 October 2020 at Yours, Kewbish. 1605 words. Subscribe via RSS.

Introduction

Even though we don’t really have midterms, and quizzes and tests flow pretty regularly throughout the year, it’s that time of year again - when it all starts sinking in that, no, it’s not just an unexpected spike in homework: it’s just that this is the baseline of homework, and this is how it’ll be for the rest of the year. Fun! In addition to that, I also have to worry about UBC applications and other things, but those aren’t strictly academic matters. In essence, it’s been a very busy couple of weeks, and it’s likely not to be much less busy for a while. That probably also explains why I’m focusing on writing a lot more about productivity and studying and general learning things - I’m trying to force myself to remember these things as well.

Studying is, admittedly, rather fun for me. (This was probably why people still call me a nerd.) It makes one feel rather productive, even though it’s essentially just regurgitating facts and informations, and trying to force your brain to understand. I feel like no one really teaches people how to study - it’s one of those things that you figure out as you go along.

However, there’s recently (I say ‘recently’ because that’s when it started taking over productivity forums, but it’s been around for a whle) been a bit of a focus on the magical thing that seems to be spaced repetition. Though it’s not entirely magical either.It’s a way to reinforce learning at specific intervals when the information is beginning to sink itself into oblivion in the back of your mind, and keep the material fresh.

The most common way people seem to implement spaced repetition is through flashcards, or its digital version, Anki. Both seem to have a bit of a cult following, but it’s for a good cause. I’m pretty sure everyone knows how to make flashcards. It’s not that difficult: one fact or one testing bit on the front, the answer on the back.

Making good flashcards, however, is a bit more difficult. Each tested fact should be one atomic piece of knowledge, and ideally, a concept should be explored from different notecards and linked together. This serves to reinforce the act of producing connections between pieces of knowledge, and understanding how they work together.

The real hidden power that flashcards and spaced repetition tend to bring is the differences and science behind increasing and decreasing the testing interval. This is achieved through splitting the large set of cards into a number of levels based on one’s familiarity with the card and its knowledge. When one card is reviewed, it bumps up one level if you’ve satisfactorily understood it and got it correct, and goes all the way back to level one if you’ve got it wrong. Each level is reviewed depending on how familiar one is with the card. Level one is every testing session, level two is every other testing session, level three is every four testing sessions, and so on. Most people have something like seven levels (I prefer four or five, but that’s just because I don’t have a lot of things to remember), and once a card in the last category moves on, it’s cut from the deck, and your understanding of the topic assumed solid enough.

A bunch of people who can probably explain the science and rationale behind this better than I can have also written about this topic in various forms: Nicky Case’s brilliant web comic, Michael Nielsen’s Augmenting Long Term Memory essay, and this subpart of a research paper by Nielsen and Andy Matuschak.1

Active Recall

Before I jump into the actual implementation of spaced repetition in Vim, I’d like to briefly touch on one more thing: active recall. This is a bit less finicky and rigid than the spaced repetition systems, and I’ve used this for a while. Essentially, active recall is the act of testing yourself on knowledge every testing session. It’s been found to increase what you remembered, and while is rather tiring and boring at times, actually works to strengthen your knowledge.

I used to get a whiteboard and just make a short outline of everything I’d need to remember for the test (I used to only study for tests - insert gifted student burnout statement.). I’d write everything I remembered about those topics, and then I’d check everything. I usually rewrote mistakes in another colour, and focused on memorizing those mistakes. Then, rinse and repeat. When focusing on working on the mistakes, as spaced repetition also does, it forces you to actively work to fix those mistakes, which is much better than just rereading a paper and hoping you remember how the exact reaction mechanism works.

Now Featuring Vim

I really don’t know why I feel the need to seemingly constantly write about Vim, but here we are.

To implement spaced repetition in Vim, I didn’t want to separate testing from notes. I’d have to maintain two files in this case, which would be a bit tricky and annoying if I needed to update something. As well, that’d be extra friction in starting to study, which I wanted to reduce, not increase. Starting to study a new topic was supposed to be effortless, after all. Instead, I kept everything in my notes file, and just added an extra level indicator, which looked something like (an actual example, by the way):

- Serbian terrorists [Black Hand + Young Bosnia] => Gavrilo Princip shot Franz Ferdinand [l2]

That little [l2] indicates that that point, and all its subpoints, are at level 2 in the spaced repetition framework. [l2] isn’t something I’d ever need to write as an identifier for anything else, or write as part of my notes, so it’s pretty safe to just use that format and grep for it overall. When I’d do a repetition or active recall study session, I’d go through each of the top-level points, and try to remember and regurgitate everything from the subpoints. This brings together both active recall and spaced repetition systems, which I found worked really well.

Now, to Vim-ify the testing method, instead of doing things manually, I modified what’s in Edwin Wenink’s article on studying in Vim to get this command, which I added to my .vimrc:

nnoremap <expr> <leader>nq ':vimgrep /\[l' .nr2char(getchar()). '\]/ %<CR>'

This remaps the \nq command in Normal mode to look for all occurances of the levels. I originally used a \d regex for just any level, but I found the getchar() bit, which lets me use something like \nq1 to start a session for level one. This starts a vimgrep session2 in the current file, which is fine, as I have all my notes for one topic in the same file. I can move between questions with :cn and :cp, and since the questions show up at the bottom of the screen, I can’t look at the subpoints.

To raise and lower levels for each group of subpoints, I’ve come up with two commands:

nnoremap <leader>ll :s/\[l\d\]/\[l1\]/ <CR>
nnoremap <leader>rl :s/\[l\zs\d/\=submatch(0)+1/ <CR>

ll is a mnemonic for lower level, and this complicated regex essentially substitutes any occurances of [l*digit*] with [l1], since we’ll be resetting the card all the way back down to one.

rl stands for raise level, and this regex matches all digits preceded by [l, which should be all the card level indicators. This then does a bit of fancy submatch maths to add one to the level. Fun!

Of course, if you plan to have multiple level indicators per line (not entirely sure how that would come into play or how that would work; maybe if you had categories or something?), you might want to do a global search on the line by appending \g to any of these lines.3

Conclusion

Is this slightly overcomplicated? Could I not have just copy pasted questions from Quizlet or something into a file and just attempted to solve mock tests instead? Should I have just used Anki instead of spending roughly fifteen minutes Googling as to why the remap wasn’t working when I accidentally used /nq instead of \nq? Yes, probably wouldn’t be as fun, and maybe. Anyway, it’s been a fun area of memory work to explore, and in the process of attempting to improve my study work, I’ve gone through more papers than I’d have expected to, which probably sounds boring, but I promise, it’s rather engaging, in fact.

On an extremely unrelated note, I’m not far off my goal of 50k words this year on this blog, and this post itself has contributed its weekly total towards that. I hope to be able to properly get everything done and maybe do a bit of editing for the rather cringe posts that may or may not have appeared in the spring of this year when (or if, I should say) I get some time over winter break. It’s almost the holidays, and that’s probably something nice to look forward to amongst all the work and studying that needs to be done. Well, off to edit a lab.


  1. They made for fun productive procrastination readings, where I didn’t want to properly rework something, so instead, I read these. Yes, I read for fun, and generally, I learn something, so that’s that. ↩︎

  2. Not entirely sure what to call it, but I’ll assume session is the term. ↩︎

  3. See, the time I spent playing Regex Crosswords wasn’t wasted. Maybe it was, because without it, I wouldn’t have decided to make this complicated remapping scheme, but here we are. ↩︎

Cite me

MLA: Ma, Emilie. "Spaced Recall in Vim." Yours, Kewbish. n.p., 25 Oct. 2020. Web.

APA: Ma, E. (2020, October 25). Spaced Recall in Vim [Web log post]. Retrieved from https://kewbi.sh/blog/posts/201025/

UBC citation style.

- Yours, Kewbish


< More Posts