Plugin: Hotkey in joplin


This plugin is simple but effective, with the ultimate goal of optimizing hotkeys.

When I used Joplin for a long time to take notes, I found that hotkey was quite lacking and very inefficient.

Currently, I only implement a hotkey for the head. You can quickly set the head content through ctrl+[Num].

However, we welcome everyone to implement various hotkeys together to improve the efficiency of writing.

屏幕录制2023-03-19 00.58.52

Name Description Default key binding
toggleTitleH1 Toggle # H1 title CmdOrCtrl+1
toggleTitleH2 Toggle ## H2 title CmdOrCtrl+2
toggleTitleH3 Toggle ### H3 title CmdOrCtrl+3
toggleTitleH4 Toggle #### H4 title CmdOrCtrl+4
toggleTitleH5 Toggle ##### H5 title CmdOrCtrl+5


For User

You can propose an issue to describe the hotkeys you want to have. For example:

Default key binding:CmdOrCtrl+1
- Add a "# " prefix to the selected line (or the line where the cursor is located)

For Developer

As a developer, you need to understand how to create a hotkey. You can refer to the API documentation

In the current project, you need to modify two places:

The method of editor.execCommand can be queried from this useCursorUtils.ts

  • defineExtension method
  • CodeMirror own method

Utils is a public method class in which you can implement desired functions:

// Utils.ts
import joplin from 'api';

export default class Utils {

	public static async replaceLineText(line, text) {
		const { curline, curCh } = await joplin.commands.execute('editor.execCommand', {name: "getLine", args: [line]});
		await joplin.commands.execute('editor.execCommand', { name: 'replaceRange' , args: [text, { line: line, ch: 0 }, { line: line, ch: curCh }] });


Then, you can add your hotkeys to index.ts and call the method you just added.

const hotKeyList = [
		name: "TitleH1",
		lable: "H1",
		iconName: "fas fa-music",
		enabledCondition: "noteIsMarkdown",
		menuItemLocation: MenuItemLocation.Edit,
		commandName: "supplyHeadText",
		args: [ "#" ]

Thanks for the plugin!

Can you explain how this is done? I looked at the repo but it wasn't clear to me.

I have updated this participation method. I think we need to continue to supplement this hotkey list to improve our efficiency

1 Like