docs: update docs now that some more motions are provided by default

This commit is contained in:
Aly Thobani 2024-07-17 10:15:57 -07:00
parent cd7d5e9293
commit 6789094e0b
2 changed files with 11 additions and 5 deletions

View file

@ -4,12 +4,11 @@ In this document I will collect some of my and user-contributed ideas for how to
If you have interesting snippets, please contribute by opening a pull request!
Note that these examples are included for demonstration purposes, and many of them are now provided by default in this plugin. Their actual implementations can be found under [`motions/`](https://github.com/esm7/obsidian-vimrc-support/blob/master/motions/), which you can also use as reference (either for your own custom motions, or if you wish to submit a PR for a new motion to be provided by this plugin).
## Jump to Next/Prev Markdown Header
## Jump to Next/Previous Markdown Heading
To map `]]` and `[[` to next/prev markdown header, I use the following.
In a file I call `mdHelpers.js`, put this:
In a file you can call `mdHelpers.js`, put this:
```js
// Taken from https://stackoverflow.com/questions/273789/is-there-a-version-of-javascripts-string-indexof-that-allows-for-regular-expr

View file

@ -75,6 +75,13 @@ Commands that fail don't generate any visible error for now.
CodeMirror's Vim mode has some limitations and bugs and not all commands will work like you'd expect.
In some cases you can find workarounds by experimenting, and the easiest way to do that is by trying interactively rather than via the Vimrc file.
Finally, this plugin also provides the following motions/mappings by default:
- `[[` and `]]` to jump to the previous and next Markdown heading.
- `zk` and `zj` to move up and down while skipping folds.
- `gl` and `gL` to jump to the next and previous link.
- `gf` to open the link or file under the cursor (temporarily moving the cursor if necessary—e.g. if it's on the first square bracket of a [[Wikilink]]).
## Installation
In the Obsidian.md settings under "Community plugins", click on "Turn on community plugins", then browse to this plugin.
@ -284,7 +291,7 @@ The `jsfile` should be placed in your vault (alongside, e.g., your markdown file
As above, the code running as part of `jsfile` has the arguments `editor: Editor`, `view: MarkdownView` and `selection: EditorSelection`.
Here's an example from my own `.obsidian.vimrc` that maps `]]` and `[[` to jump to the next/previous Markdown header:
Here's an example `.obsidian.vimrc` entry that maps `]]` and `[[` to jump to the next/previous Markdown heading. Note that `]]` and `[[` are already provided by default in this plugin, but this is a good example of how to use `jsfile`:
```
exmap nextHeading jsfile mdHelpers.js {jumpHeading(true)}