obsidian-vimrc-support icon indicating copy to clipboard operation
obsidian-vimrc-support copied to clipboard

change doc about list of commands

Open hbt opened this issue 1 year ago • 0 comments

Please make sure this feature request is within the scope of this plugin.

  • [ X] I understand that if my request is about supporting some Vim feature, it probably belongs here.

Describe the feature that you'd like:

In reference to this in the README.md

The commands that can be used are whatever CodeMirror supports. I couldn't find a formal list anywhere but you can look for defaultExCommandMap in [the source code](https://github.com/codemirror/CodeMirror/blob/master/keymap/vim.js), or play around with trying commands in Obsidian's Vim mode.

obsidian commands can be listed using

dataviewjs
const getNestedObject = (nestedObj, pathArr) => {
    return pathArr.reduce((obj, key) =>
        (obj && obj[key] !== 'undefined') ? obj[key] : undefined, nestedObj);
}

function getHotkey(arr) {
    return arr.hotkeys ? [[getNestedObject(arr.hotkeys, [0, 'modifiers'])],
    [getNestedObject(arr.hotkeys, [0, 'key'])]].flat(2).join('+').replace('Mod', 'Ctrl') : '–';
}

let cmds = dv.array(Object.entries(app.commands.commands))
    .sort(v => v[1].id, 'asc');

dv.paragraph(cmds.length + " commands currently enabled.<br><br>");

dv.table(["Command ID", "Name in current locale", "Hotkeys"],
    cmds.map(v => [
    v[1].id,
    v[1].name,
    getHotkey(v[1]),
    ])
    );

Additional context:

Example with all cmds: obsidian.pdf

Thanks for your work on this plugin.

hbt avatar Jul 18 '22 15:07 hbt