Skip to content

inkdropapp/inkdrop-vim

Repository files navigation

vim keybindings plugin for Inkdrop

Provides Vim modal control for Inkdrop, blending the best of Vim and Inkdrop.

Features

  • All common motions and operators, including text objects
  • Operator motion orthogonality
  • Visual mode - characterwise, linewise, blockwise
  • Incremental highlighted search (/, ?, #, *, g#, g*)
  • Search/replace with confirm (:substitute, :%s)
  • Search history
  • Sort (:sort)
  • Marks (,)
  • Cross-buffer yank/paste
  • Select next/prev item in note list bar (j / k)
  • Scroll markdown preview pane

Install

ipm install vim

Key customizations

You can customize keybindings in your init.js. For example,

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

:w, :write

Saves current note immediately to the disk.

:next, :n

Opens next note on the note list.

:prev

Opens previous note on the note list.

:preview, :p

Toggles HMTL preview.

:side-by-side, :side

Toggles side-by-side mode.

Define custom Ex commands

You can extend Ex commands by writing init.js. The following example defines :find command:

inkdrop.onEditorLoad(() => {
  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', {
        keyword: event.argString.trim()
      })
  })
})

Changelog

See the GitHub releases for an overview of what changed in each update.

About

Provides Vim modal control for Inkdrop, blending the best of Vim and Inkdrop

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •