Looking for a way to quickly write Q&A in Markdown using KM

I often write Q&As (series of questions followed by answers).

Of all the apps I know, only Scrivener specifically offers the possibility of quickly writing Q&As, but it's not convenient for other reasons (formatting).

I am trying to figure out how to write a macro which would allow me to quickly write Q&As in Markdown for Bear Notes.


  • the question would be a header , and would start in Markdown with by "#### " (4x hashtags followed by a space). The end of the question would simply entail pressing the enter key which is simple
  • the answer would be in italics which is "" on either side of the text comprising the answer. (note that there is no space before the ""
  • I have to insert a few (2) lines between each question/answer set

thanks in advance for your time and help

Maybe the new KM11 Action "Prompt for Snippet" could be the way to go:


It allows you to enter multiple lines of text.

1 Like

thanks very much @Zabobon
I am working on your solution. Thanks very much !

I just had a quick play and something like the below might work. I haven't really used this Action before and it seems that it needs a Trim Whitespace Filter to clean up the multi-lines.

Prompt for Snippet.kmmacros (3.7 KB)

Click to Show Image of Macro

1 Like

very smart to user insert text. I am working on the final macro.

I want Cmd-Enter to press the OK button. In the action below, how can I replace Return with Cmd Return?

I can't use just Return because I would lose the newline.

thanks very much


Does this work for you?

If Then Else.kmactions (971 B)

Keyboard Maestro Export

EDIT: Uploaded it as action instead of macro

1 Like

@Alexander @Zabobon
thank you both for your posts. Basically, when I am finished typing the question, I want to press Cmd Enter to press the OK button, and go on the to answer, and when I am finished typing the answer, I want to press Cmd Enter to press the OK button to go to the next question/answer but nothing works. I think that it is because no action are visible to KM while I am typing the question and answer.

Ah, now I think I might be understanding a little bit clearer what you are looking for.

I am on my way out now, but I'm having an idea that something like this might do what you need (but this might come from having asynchronously ran macros a bit on the top of my head these days, and I might be thinking this all wrong):

TestsForOthers Macros.kmmacros (15 KB)

Macro Images

Two macros, where one of them is run asynchronously and waiting for the key presses. I couldn't get it to work with Press-a-button either, so resolved to click found image.

I am in a bit of a hurry so have not built it fully the way I wanted. I would at the very lest want to add a way for the SUBMACRO to be canceled if the prompt in the calling macro is canceled, but couldn't in this moment get my head around how to ad an OR-condition in addition to the cmd- AND Enter-keys

1 Like

thanks very much @Alexander and have a nice day / evening (depending on your time zone). I will work on it.

1 Like

If you are entering a series of questions-and-answers, why not ask for both (no navigation required) in one prompt and repeat the process until you press the Cancel button?

Each set can be appended to a text file after the variables for each question and answer have been formatted for Markdown (your header and italics and spacing) by Keyboard Maestro.

So you'd enter the text of the question, hit Tab, enter the text of the answer and tap OK (or use a special key chord). That set would be added to a text file with the correct formatting and you'd have a blank form in front of you to add the next set. If you're done, you'd tap Cancel.

1 Like

Good idea. I am working on it and find that simpler solutions seem better, like working directly in markdown, a keyboard shortcut to insert text #### β†’ I write the question, followed by anot.her shortcut for the answer which types ** followed by the ← key to put the cursor between the two * and I type the answer.
My apologies to you, @Alexander and @Zabobon for making the issue more complex than it was.

1 Like

All good, and only interesting trying to solve these challenges! Also great to hear that you are on your way to finding a good and simpel solution!

I only cherry picked a very small portion of your challenge to work on, but as I weren’t then able to figure out how to solve how to cancel the Submacro if the Calling macro canceled I've kind of been walking around thinking about it ever since, haha. I am however pleased to say that I where finally able to reach closure here as I now had an epiphany of how to solve it!

Closure by functioning cancel

Prompt for snippet β€” cmd + return to press OK Macros (v11.0.1)

Prompt for snippet β€” cmd + return to press OK Macros.kmmacros (21 KB)

1 Like

Glad you resolved the situation to your satisfaction. But in the interests of anyone who might need a similar solution, I put this together:

Q&A Helper Macro (v11.0.1)

Q&A Helper.kmmacros (9.5 KB)

It puts up this window for text entry:

You can cycle through the two fields and the two buttons using the tab key.

When you hit OK, the pair of text fields are stripped of any extra whitespace (like returns) and formatted for Markdown before being added to a running variable that keeps accumulating pairs until you hit the Cancel button.

When you Cancel, you are prompted for a new file (by default on your Desktop but you can change that in the action), all the pairs are written to the file and the file is opened using the default app for Text files (again, you can change that to something that reads Markdown).

The advantage of this approach is that it automates the formatting task and lets you enter just the questions and answers, never leaving the keyboard (tab to the buttons).