Skip to content

Instantly share code, notes, and snippets.

@dmych
Created January 12, 2023 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmych/21dfcf31ccdba9b24dc81ea9c62fae1b to your computer and use it in GitHub Desktop.
Save dmych/21dfcf31ccdba9b24dc81ea9c62fae1b to your computer and use it in GitHub Desktop.
Go to the next/previous paragraph (e.g. empty line) using Templater scripts. Put all files to your Templater scripts folder, add both .md files to the Template Hotkeys and assign hot keys.

<%* tp.user.para(tp, false) %>

// Move cursor paragraph up or down
// Paragraph separator is an empty line (probably with spaces)
async function para(tp, backwards)
{
let editor = app.workspace.activeLeaf.view.editor;
let cur = editor.getCursor("from").line;
if (backwards) {
cur--;
while (cur > 0 && editor.getLine(cur).trim().length != 0) cur--;
}
else {
cur++;
while (cur < editor.lineCount() && editor.getLine(cur).trim().length != 0) cur++;
}
editor.setCursor(cur, 0);
}
module.exports = para;

<%* tp.user.para(tp, true) %>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment