Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

14 changes: 0 additions & 14 deletions .eslintrc.yml

This file was deleted.

44 changes: 21 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,26 @@ ipm install vim

## Key customizations

Default vim keymaps are defined [here](https://github.com/inkdropapp/inkdrop-vim/blob/master/keymaps/vim.json) and you can override them in your `keymap.cson` file.
You can customize keybindings in your [init.js](https://developers.inkdrop.app/guides/the-init-file).
For example,

CSS selectors for each mode:

- Not insert mode: `.CodeMirror.vim-mode:not(.insert-mode):not(.key-buffering) textarea`
- Normal mode: `.CodeMirror.vim-mode.normal-mode:not(.key-buffering) textarea`
- Insert mode: `.CodeMirror.vim-mode.insert-mode textarea`
- Replace mode: `.CodeMirror.vim-mode.replace-mode textarea`
- Visual mode: `.CodeMirror.vim-mode.visual-mode:not(.key-buffering) textarea`

You can check current keybindings on the _Keybindings_ pane on preferences window:

![Preferences](https://raw.githubusercontent.com/inkdropapp/inkdrop-vim/master/docs/preferences.png)
```js
function configureKeyBindings() {
const Vim = inkdrop.packages.getLoadedPackage('vim').mainModule.Vim

// Map keys
Vim.map('jj', '<Esc>', 'insert') // in insert mode
Vim.map('Y', 'y$') // in normal mode
// Unmap keys
Vim.unmap('jj', 'insert')
}

const editor = inkdrop.getActiveEditor()
if (editor) configureKeyBindings()
inkdrop.onEditorLoad(() => {
configureKeyBindings()
})
```

## Ex Commands

Expand Down Expand Up @@ -67,8 +74,8 @@ The following example defines `:find` command:

```js
inkdrop.onEditorLoad(() => {
var CodeMirror = require('codemirror')
CodeMirror.Vim.defineEx('find', 'f', (cm, event) => {
const Vim = inkdrop.packages.getLoadedPackage('vim').mainModule.Vim
Vim.defineEx('find', 'f', (cm, event) => {
inkdrop.commands.dispatch(document.body, 'core:find-global')
if (event.argString)
inkdrop.commands.dispatch(document.body, 'core:search-notes', {
Expand All @@ -78,15 +85,6 @@ inkdrop.onEditorLoad(() => {
})
```

## Options

![options](./docs/options.png)

### Seamlessly jump to note title

Whether moving focus seamlessly from the editor to the note title bar by `vim:move-up` command

## Changelog

See the [GitHub releases](https://github.com/inkdropapp/inkdrop-vim/releases) for an overview of what changed in each update.
See [CHANGELOG.md](https://github.com/inkdropapp/inkdrop-vim/blob/master/CHANGELOG.md) for older releases.
22 changes: 22 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import prettier from 'eslint-config-prettier'

export default [
{
ignores: []
},

prettier,

{
languageOptions: {
globals: {
inkdrop: 'readonly'
}
},
rules: {
'no-useless-escape': 0,
'prefer-const': 2,
'no-unused-vars': 0
}
}
]
169 changes: 1 addition & 168 deletions keymaps/vim.json
Original file line number Diff line number Diff line change
@@ -1,176 +1,9 @@
{
".CodeMirror.vim-mode": {},
".CodeMirror.vim-mode.normal-mode textarea": {
"escape": "vim:reset-normal-mode"
},
".CodeMirror.vim-mode:not(.insert-mode):not(.key-buffering) textarea": {
"h": "vim:move-left",
"left": "vim:move-left",
"backspace": "vim:move-left",
"l": "vim:move-right",
"right": "vim:move-right",
"space": "vim:move-right",
"k": "vim:move-up",
"up": "vim:move-up",
"j": "vim:move-down",
"down": "vim:move-down",
"g k": "vim:move-up-by-display-lines",
"g j": "vim:move-down-by-display-lines",
"g v": "vim:reselect-last-selection",

"w": "vim:move-to-next-word",
"W": "vim:move-to-next-whole-word",
"e": "vim:move-to-end-of-word",
"g e": "vim:move-to-previous-end-of-word",
"E": "vim:move-to-end-of-whole-word",
"g E": "vim:move-to-previous-end-of-whole-word",
"b": "vim:move-to-previous-word",
"B": "vim:move-to-previous-whole-word",
"}": "vim:move-to-next-paragraph",
"{": "vim:move-to-previous-paragraph",
"|": "vim:move-to-beginning-of-line",
"0": "vim:move-to-beginning-of-line-with-zero",
"^": "vim:move-to-first-character-of-line",
"_": "vim:move-to-first-character-of-line-and-down",
"$": "vim:move-to-last-character-of-line",
"g _": "vim:move-to-last-nonblank-character-of-line-and-down",
"-": "vim:move-to-first-character-of-line-up",
"+": "vim:move-to-first-character-of-line-down",
"enter": "vim:move-to-first-character-of-line-down",
"g g": "vim:move-to-start-of-file",
"ctrl-u": "vim:scroll-half-screen-up",
"ctrl-b": "vim:scroll-full-screen-up",
"ctrl-d": "vim:scroll-half-screen-down",
"ctrl-f": "vim:scroll-full-screen-down",
"ctrl-e": "vim:scroll-down",
"ctrl-y": "vim:scroll-up",
"z enter": "vim:scroll-cursor-to-top",
"z t": "vim:scroll-cursor-to-top-leave",
"z .": "vim:scroll-cursor-to-middle",
"z z": "vim:scroll-cursor-to-middle-leave",
"z -": "vim:scroll-cursor-to-bottom",
"z b": "vim:scroll-cursor-to-bottom-leave",
"z s": "vim:scroll-cursor-to-left",
"z e": "vim:scroll-cursor-to-right",
"z M": "editor:fold-all",
"z R": "editor:unfold-all",
"z c": "editor:fold-current-row",
"z o": "editor:unfold-current-row",
"shift-G": "vim:move-to-line",
"H": "vim:move-to-top-of-screen",
"L": "vim:move-to-bottom-of-screen",
"M": "vim:move-to-middle-of-screen",

"d": "vim:delete",
"D": "vim:delete-to-last-character-of-line",
"c": "vim:change",
"C": "vim:change-to-last-character-of-line",
"r": "vim:replace",
">": "vim:indent",
"<": "vim:outdent",
"=": "vim:auto-indent",
"J": "vim:join",

"y": "vim:yank",
"Y": "vim:yank-line",
"P": "vim:put-before",
"p": "vim:put-after",

"g ~": "vim:toggle-case",
"g U": "vim:upper-case",
"g u": "vim:lower-case",
"~": "vim:toggle-case-now",

"m": "vim:mark",
"`": "vim:move-to-mark-literal",
"'": "vim:move-to-mark",

"f": "vim:find",
"F": "vim:find-backwards",
"t": "vim:till",
"T": "vim:till-backwards",
";": "vim:repeat-find",
",": "vim:repeat-find-reverse",

"/": "vim:search",
"?": "vim:reverse-search",
"*": "vim:search-current-word",
"#": "vim:reverse-search-current-word",
"n": "vim:repeat-search",
"N": "vim:repeat-search-backwards",

"%": "vim:bracket-matching-motion",

":": "vim:ex-command"
},
".CodeMirror.vim-mode:not(.insert-mode):not(.key-buffering-command) textarea": {
"i": "vim:text-object-manipulation-inner",
"a": "vim:text-object-manipulation"
},
".CodeMirror.vim-mode.normal-mode.key-buffering-operator textarea": {
"enter": "vim:move-down",
"space": "vim:move-right",
"up": "vim:move-up",
"down": "vim:move-down",
"right": "vim:move-right",
"left": "vim:move-left"
},
".CodeMirror.vim-mode.normal-mode:not(.key-buffering):not(.visual-mode) textarea": {
"i": "vim:activate-insert-mode",
"I": "vim:insert-at-beginning-of-line",
"insert": "vim:activate-insert-mode",
"R": "vim:activate-replace-mode",
"v": "vim:activate-characterwise-visual-mode",
"V": "vim:activate-linewise-visual-mode",
"ctrl-v": "vim:activate-blockwise-visual-mode",
"ctrl-q": "vim:activate-blockwise-visual-mode",

"u": "vim:undo",
"ctrl-r": "core:redo",

"O": "vim:insert-above-with-newline",
"o": "vim:insert-below-with-newline",
"a": "vim:insert-after",
"A": "vim:insert-after-end-of-line",
"x": "vim:delete-right",
"X": "vim:delete-left",
"s": "vim:substitute",
"S": "vim:substitute-line",
".": "vim:repeat",

"ctrl-a": "vim:increase",
"ctrl-x": "vim:decrease",

"\"": "vim:register-prefix"
},
".CodeMirror.vim-mode.insert-mode textarea": {
"escape": "vim:exit-insert-mode",
"ctrl-w": "vim:delete-to-beginning-of-word"
},
".CodeMirror.vim-mode.replace-mode textarea": {
"escape": "vim:exit-insert-mode"
},
".CodeMirror.vim-mode.visual-mode textarea": {
"escape": "vim:exit-visual-mode"
},
".CodeMirror.vim-mode.visual-mode:not(.key-buffering) textarea": {
"\"": "vim:register-prefix",
"I": "vim:insert-at-start-of-target",
"A": "vim:insert-at-end-of-target",
"v": "vim:activate-characterwise-visual-mode",
"V": "vim:activate-linewise-visual-mode",
"o": "vim:reverse-selections",
"O": "vim:reverse-selections-at-same-line",
"x": "vim:delete-right",
"X": "vim:delete-left",
"s": "vim:substitute-visual",
"S": "vim:substitute-line-visual"
},
".note-list-bar": {
"k": "core:open-prev-note",
"j": "core:open-next-note"
},
".mde-preview": {
".mde-preview-container": {
"g g": "vim:move-to-start-of-file",
"ctrl-u": "vim:scroll-half-screen-up",
"ctrl-b": "vim:scroll-full-screen-up",
Expand Down
Loading