You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement and provide default mappings for some Obsidian-specific Vim motions/commands (#222)
* feat: define and expose obsidian-specific vim commands
jumpToNextHeading: g]
jumpToPreviousHeading: g[
* Implement jumpToPreviousLink motion
* Refactoring and implementing jumpToNextLink
* refactor: new jumpToPattern function that can be used for motions
* refactor: renamed file and removed unneeded exports
* fix: return last found index even if fewer than n instances found, instead of undefined
* feat: implement moveUpSkipFold and moveDownSkipFold
* refactor: extract out helper functions for defining obsidian vim actions
* refactor: split vimApi.ts into two files
* refactor: add comment
* refactor: update names, types, etc
* feat: followLinkUnderCursor action
* feat: jumpToLink now jumps to both markdown and wiki links
* refactor: rename fns
* refactor: add docstrings / change var names
* feat: implement looping around
* refactor: cleaner implementation of jumpToPattern
* Change mappings for next/prev heading to [[ and ]]
* Tiny fixes
* docs: update docs now that some more motions are provided by default
---------
Co-authored-by: Erez Shermer <[email protected]>
Copy file name to clipboardexpand all lines: JsSnippets.md
+3-4
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,11 @@ In this document I will collect some of my and user-contributed ideas for how to
4
4
5
5
If you have interesting snippets, please contribute by opening a pull request!
6
6
7
+
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).
7
8
8
-
## Jump to Next/Prev Markdown Header
9
+
## Jump to Next/Previous Markdown Heading
9
10
10
-
To map `]]` and `[[` to next/prev markdown header, I use the following.
11
-
12
-
In a file I call `mdHelpers.js`, put this:
11
+
In a file you can call `mdHelpers.js`, put this:
13
12
14
13
```js
15
14
// Taken from https://stackoverflow.com/questions/273789/is-there-a-version-of-javascripts-string-indexof-that-allows-for-regular-expr
Copy file name to clipboardexpand all lines: README.md
+8-1
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,13 @@ Commands that fail don't generate any visible error for now.
75
75
CodeMirror's Vim mode has some limitations and bugs and not all commands will work like you'd expect.
76
76
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.
77
77
78
+
Finally, this plugin also provides the following motions/mappings by default:
79
+
80
+
-`[[` and `]]` to jump to the previous and next Markdown heading.
81
+
-`zk` and `zj` to move up and down while skipping folds.
82
+
-`gl` and `gL` to jump to the next and previous link.
83
+
-`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]]).
84
+
78
85
## Installation
79
86
80
87
In the Obsidian.md settings under "Community plugins", click on "Turn on community plugins", then browse to this plugin.
@@ -283,7 +290,7 @@ The `jsfile` should be placed in your vault (alongside, e.g., your markdown file
283
290
284
291
As above, the code running as part of `jsfile` has the arguments `editor: Editor`, `view: MarkdownView` and `selection: EditorSelection`.
285
292
286
-
Here's an example from my own `.obsidian.vimrc` that maps `]]` and `[[` to jump to the next/previous Markdown header:
293
+
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`:
0 commit comments