A Few Tips on Using Anki for Learning To Code

David Ecklund
Mar 16 · 8 min read
Photo by Joshua Sortino on Unsplash

Recently a friend I study with told me that he was sharing some tips that I had offered him on how to use Anki with other classmates of ours on Launch School. For them and whoever else may benefit, here goes.

I am going to assume that we all know what Anki is, and that we have all used it, at least a bit. I will also assume that I am a more advanced user than you are, or that I have a style that you could learn from.

For context, I have used Anki to help me learn Russian and German to fluency, Italian and French to more basic levels of competence, as well as an assortment of other subjects to varying degrees, from world geography to metalearning. I am now using it to supplement and digest my studies at Launch School on the Ruby track.

The most important notion to take to heart in order to enjoy and profit from using Anki as a staple of your learning diet is that it is for memorization, not learning in general. In other words, if you need to master a concept from scratch, or learn a procedure, or problem solve, Anki is not your go-to tool. The ideal flash card takes no more than two seconds to understand what’s being asked, and no more than five seconds more to answer it. If I can’t find a way to fit what is essential for practicing a certain thing so that I will — even after having not encountered it for weeks — be able to grok the question within 10 seconds and answer it within 5 or so seconds after that, it is very likely not flash card fare.

So what kind of things do I use Anki for while learning to code? There are a couple main ways I create cards.

The first is I take a very small piece of code — say, 1–5 lines or so, usually including the output — and use cloze deletion. (To cloze delete, highlight the selection and press ctrl-shift-C. Here is a great, two-minute video showing the basics of cloze deletion (watch up to 2:20). See the Syntax Highlighting for Code add-on for how to copy and paste code nicely into Anki.) The key thing here is eliminating everything except what is necessary for the exact thing or things you want to memorize. Often the documentation of your programming language of choice can give exactly that kind of atomized usage case. I will sometimes take a cluster of use cases and cloze delete all instances of the method name (one card for all of them) and a half-dozen separate cards or so on that same note for the various elements of syntax and the outputs of each case.

Let’s take the example of the `String#count` method in Ruby.
Here I’ve cloze deleted 5 cards: 1 for the method name and 4 for the various return values.
Here is an example with the `String#scan` method with the arguments also cloze deleted.

In other instances, when I realize an error in my code that I would like to never make again, I extract the essential bit and leave in the error, perhaps with its faulty output. Now when the card comes up, I need to spot what is wrong and how to fix it in a few seconds. So satisfying.

On line 6, this should be `protected`, not `private`. I leave the error unmarked. (This example is a fair-sized chunk of code. If I found I couldn’t understand what’s being asked for within 10 seconds, I’d edit or delete it.)

The second is that I extract (often just copy&pasting) some piece of text from my study materials and cloze delete it. Definitions, statements clarifying the difference between things I tend to confuse, and facts I would like to memorize are all good candidates.

What was that called again?

There are many other ways to use Anki that I find worthwhile, but I would start with these. Less is more.

Before going on to an assortment of tips below, I would encourage you, if you want to use Anki on a regular basis, to always have the program up and running on your computer whenever you are studying. Be ready for when you run into anything worthy of spaced repetition. With a bit of practice, a flashcard can be composed and saved in a few seconds.


Make Anki the first thing in every study session, and don’t miss a day. If you find it difficult to stick to the habit, make the commitment to do five minutes of your most essential deck (usually the one you have been adding cards to most recently). With the pressure off, often you will find that once you’re in the flow of reviewing the cards, you complete them all.

When you create a deck, make sure in the deck options that the new card and review limits are both high enough to never stop any new cards from entering immediately into circulation. If you are making the cards (not getting them from some outside source), you don’t need them.

The Add-ons that I would recommend (in order of importance; click to read more):

Syntax Highlighting for Code is just what the name says. Must have.

GODMODE is an add-on I discovered recently that makes creating cloze deleted notes with multiple cards much more efficient if you need multiple blanks to be a part of the same card (use ctrl-S for that). Note that this removes the shortcut for cloze deleting mentioned earlier (ctrl-shift-C becomes ctrl-E) and one mentioned later (ctrl-delete becomes delete).

Mini Format Pack let’s you niceify your notes a bit more than Anki allows out of the box.

Speed Focus has a variety of options. I set it to make the “you’re taking too long” sound to 10 seconds, to flip the card in a total of 15 seconds, and to rate it as wrong or “again” in 5 after a card has been flipped. It really increases my productivity with Anki, largely because it helps me to recognize when a card (or a whole note) is not worth the time it takes to understand what’s being asked and then answer.

I make sure all of my deck options groups have the above settings for Speed Focus.

Image Occlusion is the Add-on that takes the most time to master, but it’s worth knowing about to consider if it’s worth the hour or so it will likely take to learn to use it. Basically, if you want to make and use image-based flash cards, you need this.

Keyboard shortcuts (PC):

Spacebar and 1,2,3, and 4. Do not — I repeat — do not use the mouse when flipping the card over or telling Anki how hard it was. If the spacebar don’t klak, you are not really an Anki nerd. I put my left thumb on the spacebar and three fingers of the same hand up on the 1,2, and 3 keys.

Ctrl-enter saves a new note you are creating as well as any edits you do. Shun messy mousework and use it. (I wonder how you will memorize all these shortcuts…)

Next, @ and Ctrl-delete (for PC). @ is for suspending a card and ctrl-del is for deleting the whole note. As you improve your judgment as to what is and is not a worthwhile note/card, assert that ability by culling the deck as needed. (One way to know that the note/card has got to go is that it takes you a long time to understand what is being asked and, after you do, the answer is obvious because you already use it all the time in your code.) Tossing out this dead wood will free you up to quickly make a card while you are studying material located elsewhere than Anki without needing to interrupt your study flow too much and without feeling chained forever to practicing a bloated and confused deck.

Also get used to using “e”. That’s the shortcut for editing a note. Like the two hotkey’s above, it’s really handy so that you don’t have to make the note absolutely perfect the first time. You’ll know better what is needed when you’re actually confronted with it afresh in an Anki session after forgetting it.

(“e” also serves as a back up “pause” button if you are using Speed Focus Mode and need more than the 15 seconds or whatever you set autofail to — use sparingly.)

Decks and tags

The other thing to watch out for is context-specific notes. If I have a note for the bash shell but it is mixed in with everything else, it can get confusing, e.g. when you’re talking about abbreviated arguments (-lah, etc). I use a hierarchical structure of decks (e.g. Launch School > Ruby > RB109, or Launch School > Git) to keep the contexts separate (not perfectly, but oh well). Others say that tags are much better. Could be.

Lists, sequences, and suchlike

If you are trying to remember a group or sequence of things as well as what each of those things are and/or how they work, I recommend creating two different kinds of Anki notes, one with the whole list (or a chunk of it if the list is long) and the other with the individual items. On the note with the list, cloze delete the items separately. That way, you can practice recalling each of them as well as their sequence, if that is important. On the separate notes put the name of the item and the other information (meaning, use, etc.) you want to memorize and cloze delete the name and each of those things separately. The key here is that the group note should not include all that extra information.

Thanks for reading.

Nerd For Tech

From Confusion to Clarification

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

David Ecklund

Written by

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store