Use the following QuickAdd user script!
- Create
recenter.js
in your vault.
// recenter.js
module.exports = ({ app }) => {
const editor = app.workspace.activeEditor?.editor;
if (!editor) return;
editor.scrollIntoView(
{
from: editor.getCursor('from'),
to: editor.getCursor('to')
},
true
);
}
- Create a Macro choice using this user script (detailed instruction here):
Don’t forget to click the thunder icon to make this macro runnable as a standalone command:
- Set a hotkey for this macro.
You can find more information about the Editor interface of the Obsidian API here: