Hi, everyone! Does anyone know a way to combine different shortcuts? When editing my cards, sometimes I need to apply 3 different elements, which requires me to type a lot of shortcuts. When I want to underline, change color and apply bold, I need to type Cmd+b, cmd+u and Cmd+k (shortcut I customized to change color). Is there a way to create a single shortcut to make all these changes at once? Thank you!
If you never use italic you could maybe add this to the styling section of your notes:
i {
text-decoration: underline;
font-weight: bold;
color: blue;
font-style: normal;}
Or you could also try using this addon: Custom Styles (font color, background colour, classes) - AnkiWeb
Keyboard Maestro comes to mind for automation and to avoid repetition.
Thank you! Is this how itâs done?
Thank you! Is there a free tool?
Yes! Now if you select a portion of text and click Cmd+I
such text should be displayed as âbold, blue and underlinedâ instead of italic
(only while reviewing, in the editor it will still be displayed as italic)
Is there a free tool?
I donât know. Since Keyboard Maestro fills, tags and formats the content of some of my Anki notes, I never looked at alternatives. I doubt there are equivalent programs for Mac.
It WORKED!
editor:
reviewing:
Thank you so much, you saved me a lot of time
Just a question, I can keep creating combinations, right? Like⊠if I want to create shortcut only for blue+bold (no underline), how would it be?
In theory you can, in practice there are some limitations to it.
Besides <i></i>
, you can also modify the way <b></b>
, <u></u>
and their combinations (e.g. <b><i></i></b>
) are displayed, but thatâs the end of it (as far as I know).
That means there are only three â1 clickâ combinations you can create and, if my math is right, only six â2 clicksâ combinations.
This also comes at the price of losing these tagsâ standard function: for example, with the css code I have given you you lost the <i></i>
tagâs standard function to make the text be displayed as italic.
If you want to add many combinations, I strongly suggest checking the addon I linked above! It allows to create how many â1 clickâ combinations as you want.
It is very powerful, but you have to configure it yourself.
I suggest using âclassesâ to format your text.
E.g. you could create a class named âblue+boldâ and add this to the âstyling of classâ section of addonâs configuration menu:
font-weight:bold
color:blue
You could also leave âstyling of classâ empty and instead add this to the styling section of your notes:
.blue+bold{
font-weight:bold;
color:blue
}
It does not really make a difference, except that in this case, to modify the way the âblue+boldâ class is displayed, you have to modify the noteâs template and not this addonâs configurations. This allows the styling to be note-type specific and also means you can modify it from mobile.
[The addon comes with a lot of pre-set styles, backgrounds etc.
They are all already assigned to a shortcut. So if some shortcut you create doesnât work it might be because of overlapping. This can be solved by deleting/disabling such pre-sets or changing their shortcuts]
Ask if you need help on how to configure the addon
Hey @jcznk, Iâve installed the add-on and added an entry for blue-bold, with the code you sent me. But then a warning appears saying: This add-on will NOT work with these note types:
-
BĂĄsico
-
BĂĄsico (cartĂŁo invertido opcional)
-
BĂĄsico (digite a resposta)
-
BĂĄsico (e cartĂŁo invertido)
-
BĂĄsico-21a7c
-
OmissĂŁo de Palavras
I do use these note types and therefore I need to have the extension working with them. What can I do? Thanks!
And another question, I read the text on the download page, and itâs a little scary. What I understood is that if I do something (I donât know what), I might loose all the editing I do, and that I shouldnât use the add-on if I have no coding knowledge, which is my case. Is there any thing I have to do other than installing the add-on and adding the code you posted here?
- For many functions of this addon to work, a small piece of code needs to be added to the top of the styling section of your note types:
@import url("_editor_button_styles.css");
You can add it manually, or you can click on the âyesâ button and the addon will update all your note-types for you.
I used such function a lot of times and never had any problems, nor have I heard of any, but itâs always a good idea to do a backup before batch-editing the templates.
[This piece of code is actually not needed if you plan to use the addon to only add classes, editing the way they are displayed by adding code to the styling section of your notes (the .blue+bold{font-weight:bold; color:blue}
method I talked about in the last post)
Keep in mind, though, that this means you need to edit each note-typeâs styling section one by one.
(If you donât add @import url("_editor_button_styles.css");
the addon will keep notifying you that it wonât work until you update your templates, which is not true if you plan to only use this method. That said, I would still add such piece of code, as it can always be useful, e.g. it gives you access to all the pre-set styles etc.)]
- About the âlosing editingâ part: there are a couple of things that need to be understood, but they are fairly simple.
The way this addon works, at least the methods I explained to you, is that it allows you to add a custom class to some portion of text, then editing the way this class is displayed (either via note-templatesâ styling section or this addonâs configurations).
E.g.
- you might have this text: â
This is an example
â. - You use this addon to add the âblue+boldâ class to the word âexampleâ.
- The html code of this text will now be: â
This is an <span class="blue+bold">example</span>
â.
Now, while you are in the reviewer, Anki will see that the word âexampleâ is wrapped in the âblue+boldâ class, and will display it as blue and bold.
In Anki, classes work a little bit differently than tags (<i></i>
,<b></b>
, etc.).
The most notable difference is probably that if you copy and paste some text, the tags will be kept but the classes will be lost.
E.g. if I have some text whose html is âThis is <b>an</b> <span class="blue+bold">example</span>
â, after you copy and paste it, the textâs html will be âThis is <b>an</b> example
â: the âboldâ tag is kept, while the âblue+boldâ class is gone. So thereâs the risk you might lose some of your styling, if youâre not careful.
This is easily preventable by copy-pasting the html code instead of the âplainâ text. To do this, you first need to open the html editor (I donât know the shortcut for mac, but you can access it by clicking on the</>
button in the card editor)
If you limit your usage of this addon to the methods I explained to you, there should not be much else to understand, I believe
THANK, @jcznk . I thought something wrong happened here, uninstalled Anki and downloaded again the 1.1.50 version. I installed again the add-on, and got this error message:
InformaçÔes de Depuração:
Anki 2.1.50 (6718e678) Python 3.9.7 Qt 6.2.3 PyQt 6.2.3
Platform: Mac 11.6.5
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-03-31 06:27:11
ExtensĂ”es possivelmente envolvidas: âšCustom Styles font color background colour classesâ©
Caught exception:
Traceback (most recent call last):
File â/Users/gabrieldias/Library/Application Support/Anki2/addons21/1899278645/main_window.pyâ, line 35, in on_settings
dialog = MainConfDialog(getconfig())
File â/Users/gabrieldias/Library/Application Support/Anki2/addons21/1899278645/confdialog/init.pyâ, line 52, in init
self.init_tables()
File â/Users/gabrieldias/Library/Application Support/Anki2/addons21/1899278645/confdialog/init.pyâ, line 216, in init_tables
self.set_table(self.bo.tw_active, self.active)
File â/Users/gabrieldias/Library/Application Support/Anki2/addons21/1899278645/confdialog/init.pyâ, line 222, in set_table
widget.setSelectionBehavior(QTableView.SelectRows)
AttributeError: type object âQTableViewâ has no attribute âSelectRowsâ
Is this a problem that will prevent me from using the add-on? Thanks!
I actually donât know, sorry!
Maybe the addon has not been ported to Anki 2.1.50 yet
You should probably contact the author of the addon and ask them
I will do it, thanks!
I thought about this a bit better and I realized that the best option for you should be to use âinline stylesâ, not classes.
They have two advantages: 1. the text appears stylized in the editor too, not just in the reviewer 2. you can copy-paste the text without the styles being lost.
This would be an example of an inline styleâs html: <span style="font-weight:bold; color:blue">text</span>
Unfortunately, I cannot seem to use the addon to add inline styles, even though it theoretically offers such function. The same configurations that worked in Anki 2.1.22 do not seem to function in Anki 2.1.49.
I contacted addonâs author about it, so letâs see
To achieve this without an external program, you can group shortcuts using AppleScript and wrapping it with the (unfortunately named) Shortcuts app thatâs bundled with MacOS. See here for a shortcut that activates the three shortcuts keys your mentioned:
https://www.icloud.com/shortcuts/828dc43001d24dd0b4c37a0bda84de8d
Once installed you can then assign the shortcut to its own shortcut key in System Preferences > Keyboard > Shortcuts > Services (at the bottom of the list)
@jcznk I downgraded to 2.1.49 (I was using the 2.1.50 beta version). And I changed all my notes to the same type (Basic) -I had cards of many different types (I donât know why, but I feel this standardization had a positive effect on Anki) . The blue+bold+underline styling is working fine (with the code you sent me). This is already enough for me to keep my studies without wasting too much time. Now the only solution I need is this way to create more combinations (like blue+bold, or red+boldâŠ). In case you find some interesting tool, please let me know. But donât bother wasting your time to find solutions, right know I have the basic means to keep studying.
Thank you! I appreciate how much you guys here are always willing to help.
It says that âThis app is available only on the App Store for iPhone and iPad.â Do you know an app for Macbook?
Hey @jcznk do you see any reason why âĂșnica interrupçãoâ is black? I applied Cmd+b, but the color didnât change (I repeated the code you sent me, using âbâ. Thanks!
I tried your code and it seems to works fine.
In your case thereâs probably some inline code that is interfering with it. Probably some html that says that those two words (and possibly some other portion of text) are black.
Something like: This is <font color="#0000ff">an</font> example
Such inline pieces of code are sometimes added when copy-pasting text, especially from sources other than Anki. They get the precedence over whatâs specified in the note template.
Try these:
- select the entire text, then set its color to black (pure black, the one with the hex code #000000). Since #000000 is Ankiâs default, doing this should remove all inline code about color and is usually enough to fix the problem
- if it doesnât fix it, try removing all formatting (eraser button), then add again the bold/italic tags and check if it works
- if none of these work, please open the html editor and post a screenshot here