158 15
Sign in to rate

Syntax Highlighting for Code

0.82MB. Updated 2018-10-07.
The author has shared 65 other item(s).


       Allows you to insert syntax-highlighted code snippets into your notes: CHANGELOG Version 2.0.2 – 2018-10-07 Fixed You can view all past releases here. USAGE
  1. Open the Add Note window in Anki.
  2. Compose your code snippet in your favorite text editor.
  3. Copy the code to the clipboard (e.g. Ctrl+C)
  4. Move the cursor to to the field you want to insert your code snippet into
  5. In the top right corner of the editing window there should be a new Thunderbolt icon with a dropdown.
  6. Choose the language your snippet is written in, and click the Thunderbolt / use it's associated hotkey (default: Alt+S).
  7. Anki will copy your syntax highlighted snippet to the field
Alternatively, you can compose your code directly in Anki, highlight it, and then click the lightning button. But generally it is much more convenient to use a dedicated code editor with monospaced fonts and proper syntax highlighting. The add-on will automatically remember the last programming language you chose, even after restarting Anki. CONFIGURATION Basic Currently there are four configuration options, available from Anki's main screen through ToolsSyntax Highlighting Options: Please note that changes in the configuration will only affect new notes. Advanced Syntax Highlighting also comes with a number of advanced options. These can be edited by either using Anki 2.1's inbuilt add-on configuration screen (ToolsAdd-ons → select Syntax Highlighting → click on Config) or by manually editing the corresponding config keys in syntax_highlighting/meta.json in Anki's add-on folder (Anki 2.0) [the config.json file contains the default values and should not be modified.] The following options may be customized: These advanced settings do not sync and require a restart to apply. HELP AND SUPPORT Please do not use reviews for bug reports or support requests. I don't get notified of your reviews, and properly troubleshooting an issue through them is nearly impossible. Instead, please either use the issue tracker (preferred), add-on support forums, or just message me at ankiglutanimate@gmail.com. Constructive feedback and suggestions are always welcome! CREDITS AND LICENSE Copyright © 2012-2015 Tiago Barroso Copyright © 2015 Tim Rae Copyright © 2018-2019 Aristotelis P. (Glutanimate) Syntax Highlighting is based on Syntax Highlighting for Code by Tiago Barroso. All credit for the original idea and implementation goes to him. A major thanks is also due to Tim Rae, who extended the original add-on with CSS support. The present fork and update to Anki 2.1 was made possible through the generous support of a fellow Anki user who would like to remain anonymous. Licensed under the GNU AGPLv3, extended by a number of additional terms. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. For more information on the license please see the LICENSE file accompanying this add-on. The source code is available on GitHub. Pull requests and other contributions are welcome! MORE RESOURCES Make sure to check out my socials for the latest add-on updates and news: @Glutanimate | / Glutanimate New: Receive notifications about new add-on releases via @AnkiUpdates Want to hire me to work on add-on for you? Get in touch at ankiglutanimate@gmail.com SUPPORT MY WORK If you like Syntax Highlighting, please give it a thumbs up and share it with your friends, so that more people can enjoy it! A kind request: Writing, supporting, and maintaining Anki add-ons like these takes a lot of time and effort. If Syntax Highlighting has been a valuable asset in your studies, please consider using one of the buttons below to support my efforts by pledging your support on Patreon, or by buying me a coffee. Each and every contribution is greatly appreciated and will help me maintain and improve Syntax Highlighting as time goes by!              Pro-tip: Lots of exclusive add-ons and other goodies await on my Patreon page. Make sure to check them out!


As add-ons are programs downloaded from the internet, they are potentially malicious. You should only download add-ons you trust.

Supported Anki versions:

To download this add-on, please copy and paste the following code into Anki 2.1:


If you were linked to this page from the internet, please open Anki on your computer, go to the Tools menu and then Add-ons>Browse & Install to paste in the code.

All Anki 2.1.x Add-Ons


on 1664032777
Unfortunately this add-on caused a noticeable delay in loading the WYSIWYG editor when using the browser or adding/editing a new card, perhaps because it's loading a big python library on the initialization of the editor. Not sure of course, just a theory.

Have resorted to pasting highlighted HTML in from an external source, which is less convenient but does the job for now.
on 1661720547
Worked great for python. Didn't see options for other code though.
on 1661615898
Good job, thx!
on 1661074871
Great!!!!If it has the dark mode it would be amazing!!!!!
on 1660200814
Anki 2.1.54 (88e539aa) Python 3.10.5 Qt 6.3.1 PyQt 6.3.1
Platform: Linux
Flags: frz=False ao=True sv=2
Add-ons, last update check: 2022-08-11 11:30:25
⁨Syntax Highlighting for Code⁩

Caught exception:
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/anki/config.py", line 43, in get_immutable
return from_json_bytes(self.col._backend.get_config_json(key))
File "/usr/lib/python3.10/site-packages/anki/_backend/generated.py", line 1004, in get_config_json
raw_bytes = self._run_command(5, 0, message.SerializeToString())
File "/usr/lib/python3.10/site-packages/anki/_backend/__init__.py", line 146, in _run_command
raise backend_exception_to_pylib(err)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/aqt/webview.py", line 42, in cmd
return json.dumps(self.onCmd(str))
File "/usr/lib/python3.10/site-packages/aqt/webview.py", line 149, in _onCmd
return self._onBridgeCmd(str)
File "/usr/lib/python3.10/site-packages/aqt/webview.py", line 624, in _onBridgeCmd
return self.onBridgeCmd(cmd)
File "/usr/lib/python3.10/site-packages/aqt/toolbar.py", line 168, in _linkHandler
File "/usr/lib/python3.10/site-packages/aqt/toolbar.py", line 183, in _addLinkHandler
File "/usr/lib/python3.10/site-packages/aqt/main.py", line 1135, in onAddCard
aqt.dialogs.open("AddCards", self)
File "/usr/lib/python3.10/site-packages/aqt/__init__.py", line 129, in open
instance = creator(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/aqt/addcards.py", line 49, in __init__
File "/usr/lib/python3.10/site-packages/aqt/addcards.py", line 74, in setupEditor
self.editor = aqt.editor.Editor(
File "/usr/lib/python3.10/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/usr/lib/python3.10/site-packages/anki/hooks.py", line 89, in decorator_wrapper
return repl(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/anki/hooks.py", line 80, in repl
old(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/aqt/editor.py", line 128, in __init__
File "/usr/lib/python3.10/site-packages/aqt/editor.py", line 179, in setupWeb
righttopbtns = runFilter("setupEditorButtons", righttopbtns, self)
File "/usr/lib/python3.10/site-packages/anki/hooks.py", line 45, in runFilter
arg = func(arg, *args)
File "/home/pluveto/.local/share/Anki2/addons21/1463041493/main.py", line 319, in onSetupButtons21
previous_lang = get_default_lang(mw)
File "/home/pluveto/.local/share/Anki2/addons21/1463041493/main.py", line 84, in get_default_lang
addon_conf = mw.col.conf['syntax_highlighting_conf']
File "/usr/lib/python3.10/site-packages/anki/config.py", line 62, in __getitem__
val = self.get_immutable(key)
File "/usr/lib/python3.10/site-packages/anki/config.py", line 45, in get_immutable
raise KeyError from exc
on 1658348337
on 1656952436
I love using this add on on my cards so I can see the code on my decks. It helps when you're a software engineer and need to remember a lot of syntax for different languages.
on 1650530729
Very useful since it allows one to use code like syntax in an Anki card. Recommended!
on 1649160328
Great for self-taught programmers!
on 1647549983
Works pretty well.
on 1645473690
on 1645191877
Really great. Makes it easy to format code on copy/paste. Should be part of Anki by default imo.
on 1644922469
Does what it should do :)
on 1642488568
The Add-On requires an update since 2018. Anki now has a Dark Mode.
on 1642170818
works well so far
on 1641585862
on 1641137611
works well, not quite as expected, but functioning, still.
on 1640822475
on 1640799886
It's awesome
on 1638929490
This is pretty convenient for adding occasional snippets of code.

R is not included among that otherwise extensive list of languages, but S is a very similar language so it works well enough for snippets.
on 1637502258
It makes my code cleaner in the cards!!!!
on 1637435557
Great add on
on 1637185093
It saves my days... Writing a lot of code notes I need the right tool for formatting code in different languages
on 1636305987
Great add-on. Does anyone know how to limit the width of the code block that it formats it properly so that it prevents horizontal scrolling and keeps code more compact?

I tried using max-width in styles and it won't override its default properties.
on 1634653713
I really love this add on.
on 1633273832
Obrigado, bro. Que a força esteja sempre com você.
on 1632472728
it works!
on 1630327456
This solution was posted earlier, I provide a bit more details and fix foreground color too.

Fix for the line colors in a dark theme (assuming the monokai theme was applied):

1. Tools -> "Syntax Highlighting for Code" -> View Files:

2. Then open: libs/pygments/formatters/html.py, and search for the occurence of `linenodiv`, that has a `background-color` property.

3, Replace that color and also add a foreground color:
background-color: #272822; color: #616063;

Your full style property must be (at least on August 2021):
style="background-color: #272822; color: #616063; padding-right: 10px"

4. Restart Anki!
on 1629801924
Good, but let use edit the font size, or add more syntax colors.
on 1626618307
DUDE. I've been looking for this for so long. Can't figure out why quizlet or any of the other big players don't support simple syntax highlighting! Vielen Dank!
on 1625743276
Godsend!! 😋😋

It makes Computer Science cards creation way easier and nicer on the eye, if you want to include a code block.
on 1625713964
thanks, i needed this
on 1625478080
I fixed the following problem by unchecking "Copy with syntax highlighting" in my vs code, now it works all good.
Previous problem:
Do not indent at all after pasting C++ code(already formatted and indented in vs code). Very annoying. Using macOS Big Sur version 11.2.1 and Anki 2.1.4.
on 1624998076
Great app
on 1624817237
The best way to write code on our flashcards
on 1623853170
not working well for R
No matter selecting Rd or Rconsole nearly no syntax highlighting
on 1623103493
on 1622560008
I use it all the time. Thanks!
on 1621905273
Great, thank you!
on 1621845954
Thank you for the addon!
Perfect to add code examples to your cards.
on 1620614744
on 1618712664
The perfect way to get code to display just as in a common editor.

A little fiddly in that you can't edit it too easily; and can't copy and paste it properly. But as long you're sure you've typed in the code exactly as you want it before you hit Alt-S to format it, it does exactly what you'd want it to: the right layout, the right font, the right colours, bold emphasis where valuable, etc.

I might prefer it if it *didn't* include the line numbers. Sometimes I want to include bits that aren't necessarily part of the same program, etc; or just a single line to learn the syntax for a particular function; etc; and the numbering is a little distracting. And I suspect it's the line number element that makes it so you can't edit it, copy-paste, etc. But it's such a minor thing overall.

(nb. I'm only just learning to code, so experienced programmers might think differently, but for the little Python and C++ that I'm familiar with, the formatting seems just right.)
on 1618673693
on 1617776320
Automatically detects highlighted code!
on 1616374331
on 1616079528
I have used it for 3 years,very nice
on 1614787427
I was looking for something like this.
on 1614072752
Great Add On!

For Anki Night Mode User who has problems with the line number and the color:

In the Add-On Files go to libs\pygments\formatters\html.py:
Search for: class="linenodiv" there shoud be an entry 'style="background-color: #32399c ...." --> I changed the default value to #32399c. Voila with that you changed the background of the line numbers :)

Hope it helped, cheers guys
on 1613128379
Broken again as of today. Didnt install anything new though.
on 1611495262
on 1611459069
Good,but not perfect

It depend on another plugin,so it's not perfect.but good enough,
on 1611084868
Love that this works on anki 2.1.
on 1609378879
Great, exactly what I needed with the flexibility to configure how I want. Thank you! Now, how about some inline highlighting?
on 1607766869
Very cool! Makes formatting code effortless.
on 1606967318
To people having troubles with dark mode there's a workaround. See this document's Advanced section and follow the instructions to set the style to monokai. This gives you a dark background color, though the line numbers are still white on off-white (for the Mac app at least).
on 1606941986
Great language support, does exactly what it advertises.
on 1606919049
Thanks. I frequently add codeblocks and this add-on has been very helpful in creating those cards.
on 1606736087
very nice, thank you!
on 1606567374
Awesome! However, the theme of the line numbers (light theme) doesn't change when the theme is changed to a dark theme.
on 1606069623
Conflict with Hierarchial Tag !!!!!!!!!!!!! Please update
on 1604324093
Excellent plugin !!
on 1604263087
Love this addon. I definitely prefer using the css template and being able to change the appearance of all my cards just by tweaking the code under styling, so thanks a lot for including that option!
on 1602955604
Pretty good, but I wish there were support for inline formatted code within a larger block of non-code text, which is useful for writing explanations clearly.
on 1602206222
Thank you!
on 1602093695
Highlighting for what seems like every language you could think of representing various domains, even obscure languages like brainfuck.
on 1600844213
Thanks for the super useful addon. I really appreciate it.

EDIT: Is there a way to prevent the plugin from center aligning the code in the card? It looks perfect right now, I like the syntax highlighting very much, but sometimes I want the code to be at the left side of the card.
on 1600767313
on 1600288695
on 1596353743
Excellent - I have been looking for something like this. really helpful. Thank you so much
on 1596115986
Great add-on.

Aside: if it helps anyone else, I've finally figured out how to get hotkeys working on a mac.
You need to insert the symbol version of the keys, rather than the text version.
So instead of typing Shift+Command+E, you need to type ⇧⌘E. This drove me crazy for a wee while!
on 1594829254
I had to take screenshots from my code snippets in order to insert highlighted code in my cards, which takes time. Liked this addon. Thanks to the author
on 1593776565
It's great, the only problem is with night mode.
on 1593155108
Code color not working for Swift
on 1592311975
Perfect for helping to remember Python one-liners I want to stop Googling. Great work!
on 1591383081
It works great!
on 1590397070
Really helpful.
on 1589506725
on 1589475741
Works great, love it.
on 1589173190
on 1587708054
Color doesnt work.
on 1587667293
Works as described
on 1587190985
Works perfect w/ Anki 2.1.8 on Ubuntu
on 1586748814
works on the lastest version for the current time.
on 1586632407
it works!!
on 1586362907
"Updated 2018-10-07" but works fine in Anki 2.1.15
on 1586189731
Great addon. Any chance that we get a different colour scheme for dark mode?
on 1585505645
It's a great addon.
For those looking for a way to add just plain text and have it easily aligned, select "Text only" from the drop down menu. It took me ages to find that, because I didn't know what it would come under lol.
on 1585211816
on 1583498489
works perfectly.
on 1582851255
Just worked out of the box!
on 1582556085
Excellent add-on to study code. Works for me with Anki 2.1 on Linux.
on 1576645405
i really needed sth like this.
on 1575208271
now code looks like it should and it work even with cloze in it
on 1574001361
nice!It's very useful.
By the way,how can I do to change the font to 'Consolas'?
on 1573211060
It's a good add-on. Only thing when I import decks from Quizlet indentation is ugly. It's not an issue of this add-on but rather Quizlet it removes them(indentation is a paid privilege I guess). I have to paste to vscode then format and then paste again, time consuming. Maybe there's a better aproach.
on 1573132294
A must for flashcards with code. I was struggling to get left alignment working for code in my answers then discovered this addon. Not only did it solve my alignment problem but it makes the code look like code.
on 1572170874
on 1572103712
Me ajuda muito para aprender uma linguagem nova.
on 1571319387
great add-on.

It works well with the add-on "Night Node" for me if you use the option "Use CSS classes" and follow the description in the section "Configuration".
on 1571055659
I like the addon, have been using it for quite some time. I'm not a power user of the addon, the only thing I have done to it is turned off line numbers. Other than that I use default. It is easy to use but there are some minor inconveniences.

For example if I want to activate the plugin and then type my code in, I can't really do that because on activation it pastes in whatever I have in my clipboard. I have to errase it and only then start typing the code. It's ok, it never meant to be used like that anyway, I should always type the code in my text editor first with proper indentation and then paste it in Anki.

If I want to highlight assembly it might be difficult to find the language I need. There is some kind of assembly langauge but it doesn't seem to be x86_64 (AT&T or Intel). Actually choosing any kind of language is difficult because you have a giant select list. A search would be better, but I don't know if Anki would allow to do something like that.

Overall it does what I need, my cards with code look pretty and readable.
on 1571041173
It is awesome! My anki version is 2.1.11. It works well. Highlight then click, it's done! Thank you very much.
on 1569634507
Wonderful work here! I like the shortcuts so you can just style and move on quickly.

I do have one question: any support for dark mode color schemes?
on 1567567617
Great addition for those wanting to learn programming languages
on 1567520603
this is great! works for my simple python highlighting. :D
on 1566136205
Very cool!
on 1566019285
this plug-in is awesome! thanks for the great tool guys!
on 1565283743
on 1561363033
Love it! Does the job.
on 1561307722
It actually works! Easy to install and supports Anki 2.1. Awesome work! Easy to setup and well explained unlike all the others. Up and running in minutes.
on 1559991771
I can insert code snippets quite effectively, very useful.
on 1559318478
Works great!
on 1559132835
Awesome. Super useful
on 1558704418
Very useful
on 1558106922
Works pretty well, thanks!
on 1557464296
Worked flawlessly with Python code
on 1557267502
Works well.
on 1556585473
Excelent addon for develops
on 1552583862
Looks great and I appreciate the huge list of language options!
on 1547608273
beautiful !
thank you
on 1546381988
Everything works fine (Anki 2.1.x).

Except not compatible with Night Mode (some text is white on white in night mode, like line numbers).
on 1546216628
Exactly what I needed.
on 1546189993
good idea
on 1545231392
Simple and does what it means to do - thanks!
on 1544797248
gets the job done!
on 1544013475
এটা দারুন, প্রোগ্রামারদের জন্যে কাজের জিনিস। Its really usefull.
on 1543396135
on 1543010018
This is amazing...love how you can choose between which languages you want to highlight.
on 1542205496
Works well
on 1541337997
Provides good syntax highlighting for code within cards
on 1541258915
Excellent stuff!
Thank you.
on 1541130027
simple and perfect
on 1540446972
Once I realised Alt-S is the way to apply the styling (not simply selecting your language in the drop down) and the centering can be removed in config this got the thumbs up!
on 1539094116
Great !
on 1538930093
Great!! Thanks for updating the Plugin so it works with Liquid Syntax. Once I updated the plugin and did another copy and paste it worked. No missing lines of text. I guess Liquid can be awkward because of it's particular syntax. I've removed the negative vote and criticism and gave it a thumbs up. I will be happy to make a small donation sometime in the future. It's a great plugin for those learning to code like me.

If I discover any other minor issues how do I contact you.. Via this method or do you have a website/email?
Comment from author
Happy to hear that things are working fine now. Thanks for the rating! GitHub would be best, as replying here is rather cumbersome: https://github.com/glutanimate/syntax-highlighting/issues
on 1538862923
Unconditionally loved it.
on 1538619940
on 1538503385
Love this add-on. Very useful and tons of languages supported. Thanks for the awesome work!!
on 1537926338
This is great add-on. All you have to do is highlight your code, and press the lightning button to format it and add syntax highlighting. I made some flashcards for ES6+ features/syntax and my code snippets are now beautiful.
Personally, I disabled line numbers, disabled centering, and used CSS classes (copy and paste the CSS in the link and add it to your note template).
on 1527638400
Fix this problem:
Comment from author
Hi there! Thanks for taking the time to link to the hotfix. For what it's worth, with the latest release of the add-on this is no longer required as all issues previously reported in the review section should be fixed.
on 1523318400
Works great after applying ferstar's fix.
on 1523232000
Работает после замены файла code_highlight_addon.py скачанного с https://gist.github.com/ferstar/61dbec4e74bcc725172ec46e546c65e1
on 1514073600
worked after I added this code to line 125 of code_highlight_addon/code_highlight_addon.py
mw.col.conf.setdefault('syntax_highlighting_conf', default_conf)
on 1511481600
Working after applying ferstar's fix. Thanks!
on 1501027200
great addon, little problem but easy to fix

here is my solution:

vist https://gist.github.com/ferstar/61dbec4e74bcc725172ec46e546c65e1

download it as "code_highlight_addon.py"

replace the stock one

on 1499472000
Doesn't work anymore!

This addon was a great one,but it doesn't work anymore. Shows error when Anki starts! :(
on 1493164800
on 1489708800
I applied two tips from the comments below and it works

1. Remove all add-ons
2. Add this add-on FIRST 162313389
This add-on can be referenced here: https://ankiweb.net/shared/info/162313389
3. Then I add this add-on: 1463041493
4. Select Tools/Add-ons/Open Add-ons Folder from the Anki menu and close Anki
5. go inside "code_highlight_addon" folder
6. edit code_highlight_addon.py in text editor

In code_highlight_addon.py, add right after the line (approx line 238):
def highlight_code(self):

this line:

mw.col.conf['syntax_highlighting_conf'] = default_conf

so it seems like:
def highlight_code(self):
mw.col.conf['syntax_highlighting_conf'] = default_conf

save, restart anki, enjoy
on 1487462400
Was good, but not any more

This was a useful add on until it stopped working. There are work around, but they seem to create more issues than they fix.
Comment from author
Hi there! Please feel free to give the latest version of Syntax Highlighting a try. I've recently taken over maintenance of the add-on and most if not all issues reported in the review section should be fixed now.
on 1487376000
works like a charm after changing one line of code

Follow the "Fixing KeyError" review, simply add one line to its source python code. All work now for both ubuntu and mac.
on 1486598400
on 1484438400
on 1479513600
on 1476835200
on 1476144000
on 1474675200
Fixing KeyError

In code_highlight_addon.py, simply add this line right after
def highlight_code(self):
mw.col.conf['syntax_highlighting_conf'] = default_conf

This will still allow you to save your line number and centering options.

If you get a pygments error, follow the instructions of the previous reviews (either install the supplementary buttons addon first, or edit code_highlight_addon.py with the pygments path)

4 stars because it requires manual fixing.
on 1472169600
The add on don't work

An error occurred in an add-on.
Please post on the add-on forum:

Traceback (most recent call last):
File "C:\Users\rafael\Documents\Anki\addons\ankihabitica.py", line 621, in score_backlog
ah.habitica.grab_scorecounter('Anki Points')
File "C:\Users\rafael\Documents\Anki\addons\AnkiHabitica\habitica_class.py", line 332, in grab_scorecounter
if self.missing[habit]:
KeyError: 'Anki Points'
on 1466380800
Getting it to work

If you are are having trouble getting this code to work, here is what I did:

1. Removed all add-ons
2. Added this add-on FIRST 162313389
This add-on can be referenced here: https://ankiweb.net/shared/info/162313389
3. Then I added this add-on: 1463041493
on 1465603200

I fixed the pygments error mentioned below, but still have this one...

An error occurred in an add-on.
Please post on the add-on forum:

Traceback (most recent call last):
File "/home/<user>/Documents/Anki/addons/code_highlight_addon/code_highlight_addon.py", line 125, in setupUi
if mw.col.conf['syntax_highlighting_conf']['linenos']:
KeyError: 'syntax_highlighting_conf'
Comment from author
Hi there! Thanks for the issue report. I know it's been a while, but please feel free to give the latest version of Syntax Highlighting a try. I've recently taken over maintenance of the add-on and most if not all issues reported in the review section should be fixed now.
on 1462924800
on 1461974400
Not working as others mentioned

Gives the following error message when started

An error occurred in an add-on.
Please post on the add-on forum:

Traceback (most recent call last):
File "C:\cygwin\home\dae\win\build\pyi.win32\anki\outPYZ1.pyz/aqt.addons", line 41, in loadAddons
File "c:\pyi\iu.py", line 436, in importHook
File "c:\pyi\iu.py", line 521, in doimport
File "C:\Users\prave_000\Documents\Anki\addons\Syntax Highlighting for Code.py", line 2, in <module>
import code_highlight_addon.code_highlight_addon
File "c:\pyi\iu.py", line 436, in importHook
File "c:\pyi\iu.py", line 521, in doimport
File "C:\Users\prave_000\Documents\Anki\addons\code_highlight_addon\code_highlight_addon.py", line 221, in <module>
from pygments import highlight
File "c:\pyi\iu.py", line 455, in importHook
ImportError: No module named pygments
Comment from author
Hi there! Thanks for the issue report. I know it's been a while, but please feel free to give the latest version of Syntax Highlighting a try. I've recently taken over maintenance of the add-on and most if not all issues reported in the review section should be fixed now.
on 1461369600
on 1459296000
Great add-on when it worked.

ANKI Version 2.0.33
Qt 4.8.4 PyQt 4.10

Traceback (most recent call last):
File "C:\cygwin\home\dae\win\build\pyi.win32\anki\outPYZ1.pyz/aqt.addons", line 41, in loadAddons
File "c:\pyi\iu.py", line 436, in importHook
File "c:\pyi\iu.py", line 521, in doimport
File "C:\Users\jrodarte\Documents\Anki\addons\Syntax Highlighting for Code.py", line 2, in <module>
import code_highlight_addon.code_highlight_addon
File "c:\pyi\iu.py", line 436, in importHook
File "c:\pyi\iu.py", line 521, in doimport
File "C:\Users\jrodarte\Documents\Anki\addons\code_highlight_addon\code_highlight_addon.py", line 221, in <module>
from pygments import highlight
File "c:\pyi\iu.py", line 455, in importHook
ImportError: No module named pygments
Comment from author
Hi there! Thanks for the issue report. I know it's been a while, but please feel free to give the latest version of Syntax Highlighting a try. I've recently taken over maintenance of the add-on and most if not all issues reported in the review section should be fixed now.
on 1453680000

You can use the Power format pack addon as an alternative, since it also allows you to highlight code using pygments.
on 1453334400
Good News

I'm running Anki 2.0.20 on Ubuntu 14.04. I added this add-on to my installation and it's working perfectly, as advertised.
Here's a screenshot of it in action (the snippet is Python):
on 1452643200
Bad News

I used this addon for about a year and loved it. Then it broke.

I (and several other users) posted the errors. No help. No responses at all.

Then the addon disappeared from the Anki repository for about a month. No explanation. Nothing. Then it suddenly reappeared. It still doesn't work.

Don't waste your time.

For what it's worth, I write about one product review every ten years. That should tell you how annoyed I am right now.

UPDATE: 1/12/16 -- Used the advice of other reviewers, edited code_highlight_addon.py per the instructions. No help at all. Still doesn't work.

Using Linux Mint 17.2 with Cinnamon desktop.
Comment from author
Hi there! I know it's been a while, but please feel free to give the latest version of Syntax Highlighting a try. I've recently taken over maintenance of the add-on and most if not all issues reported in the review section should be fixed now.
on 1450828800
It used to work perfectly, but I'm having minor issues on Ubuntu 14.04

So as one of the other users mentioned, the
center = False

tweak prevented the error from being reported, but the behavior was the opposite as expected. Setting it to
center = True

doesn't center it so it's good to go again.

Thank you for your plugin!
on 1450569600
on 1449964800
Two review answers fixed the problem

I also had the two mentioned problems but just fixed them like the people suggested. It works, thanks to author and the users. :)
on 1448150400

If you get the pygments error, do what the review posted at 2015-11-15 says to do.

If you get the Keyerror: center error, then open code_highlight_addon.py in a text editor, and edit this line:

center = mw.col.conf['syntax_highlighting_conf']['center']

To this:

center = False

You can also set this to True if you prefer to have the code centered in your anki cards.
on 1447804800
I have used it before it is broken...

This is error in my Mac:

Traceback (most recent call last):
File "Documents/Anki/addons/code_highlight_addon/code_highlight_addon.py", line 244, in highlight_code
center = mw.col.conf['syntax_highlighting_conf']['center']
KeyError: 'center'
on 1447545600
Here's a Fix

This is a great plugin, but currently broken for some folks.

To fix it:

1. Remove the add-on and restart Anki (if it's installed)
2. Install the add-on, but don't quit Anki yet
3. From menu, choose Tools -> Add-ons -> Open Add-ons Folder, then in that folder open up the "code_highlight_addon" folder and then open code_highlight_addon.py in a text editor. There's a line in there that says this:

sys.path.insert(0, os.path.join(addons_folder(), "code_highlight_addon/libs/pygments"))

add this line underneath it (with matching indendation):

sys.path.insert(0, os.path.join(addons_folder(), "code_highlight_addon/libs"))

4. Save the file and close it
5. Restart Anki

This worked for me on a Mac, hopefully it will fix the plugin for you until the author can donate some more time to fixing it :).
on 1447459200
Looks good, but doesn't seem to work anymore

As of Nov 2015, it doesn't look like this works.

I get loading errors concerning 'pygments'. I tried with Python 3.5 and 2.7, and I tried forcing pygments to version 1.6, as one of the other reviewers suggested, but it makes no difference. Won't load.
Comment from author
Hi there! I know it's been a while, but please feel free to give the latest version of Syntax Highlighting a try. I've recently taken over maintenance of the add-on and most if not all issues reported in the review section should be fixed now.
on 1447027200
Great plugin

Make sure to keep pygments at version 1.6, other wise you might get some errors concerning bytes