Anki

Anki is a system to create, maintain and review flash cards. It can be used to create and store flash cards in separate decks. It is available as an offline program and also online at AnkiWeb. Probably my favorite feature is that I can create and store my decks in its online store and also sync them up to my offline Anki client.

  • I highly recommend creating a login at AnkiWeb and creating your decks and cards there.

  • To review on your computer, install the Anki tool:

$ sudo apt install anki
  • Open up Anki and click the Sync (⟳) icon. You will be asked for your AnkiWeb login and after that your decks will be synced.

  • In case you are curious, your decks are stored in a single SQLite database file named collection.anki2 in the Documents/Anki/User 1/ directory in your home.

Tried with: Anki 2.0.32 and Ubuntu 16.04

Advertisements

How to add source code to flashcard in Anki

Syntax Highlighting for Code is an addon for Anki which enables you to add source code or pseudo-code to a flash card question or answer section. This is necessary for source code because Anki centers all text and that makes any source code text you add to a flash card impossible to understand!

This addon also automatically adds the appropriate syntax highlighting colors to the text. There is a huge variety of languages that it supports for this highlighting.

  • This addon depends on Pygments. Note that installing the latest version from PyPI using Pip caused errors with the bytes package. So, I installed the older version from Ubuntu repositories:
$ sudo apt install python-pygments
  • This addon used to be available from the Anki addons webpage with the code 491274358. It is no longer available there. But, we can install it from its source code. First, we get the code:
$ git clone https://github.com/tmbb/SyntaxHighlight.git
  • Copy the contents of the above directory to the Anki addons directory. On my system, this is the directory ~/Documents/Anki/addons

  • Close down Anki and start it up again.

  • Before you add any source code to a flashcard, indent it correctly in an external editor. Copy it to the system clipboard.

  • In the Add dialog, you will find a yellow lightning button and a languages dropdown beside it. Choose the language for syntax highlighting from dropdown. Click the lightning button and the source code from your system clipboard is processed through Pygments and the output HTML code is pasted to the flashcard. You can see that it looks great! 🙂

  • This addon adds line numbers to the code by default. To turn it off, go to Tools -> Syntax Highlighting. Switch it off in the options.

Tried with: Anki 2.0.33 and Ubuntu 14.04