Vim mode plugin

Original post:

Hi, @craftzdog I noticed a new version of Inkdrop has been released. I’m wondering if the change you mentioned to allow for vim support is included. Thanks, Chris

Hi!

Yes, you can enable vim keybindings with following code:

require('codemirror/keymap/vim')
var cm = inkdrop.getActiveEditor().codeMirror
cm.setOption('keyMap', 'vim')

But it conflicts default Inkdrop keybindings, so there’re still some tasks to do.
At the moment, you need to disable keybindings such as editor:go-char-left, editor:go-line-up, etc.
I included vim support to the next roadmap.

Finally available!

https://app.inkdrop.info/plugins/vim

Thanks @Christopher_Collier

1 Like

Feature request for the vim-plugin:

  • Would be nice to have some statusline setting to show it all the time. So that I will know which mode (in addition to cursor) I’m in and column/row, location percentage etc.
  • Support for relative line numbering
  • Some quick toolbarbutton/shortcut to switch plugin on/off

These of course are not so much required but might add some more value. So through some setting, that it is not enabled by default to not disturb existing users.
I might try to implement these at sometime, but currently having hard to find time for anything else than my blog-project at nights :sweat_smile:

And are there some other that might be useful to others?

Regarding relative line numbers, I found a snippet to accomplish it:

It does not rely on vim itself.
It looks simple to create a separate plugin for that feature.

Adding a toolbar button is easy. Here is an example code:

But as you may know, I’m working on refurbishing the UI. So, please note that it will have a breaking change on this.

Hope that helps!

1 Like

Thanks @craftzdog for those links!

I can take a better look of implementing few of these after the UI is refurbished.

Hi, did you end up looking at it?

Having this feature on the app would be awesome.

@anon54513259 What are you talking about?

Apologies if it wasn’t clear.

I was referring to @skipadu implementing relative line numbering for the vim plugin on the app :slight_smile:

It’s easy. Create init.js liks so:

inkdrop.onEditorLoad((editor) => {
  const { cm } = editor

  function showRelativeLines(cm) {
    const lineNum = cm.getCursor().line + 1;
    if (cm.state.curLineNum === lineNum) {
      return;
    }
    cm.state.curLineNum = lineNum;
    cm.setOption('lineNumberFormatter', l => 
      l === lineNum ? lineNum : Math.abs(lineNum - l));
  }
  cm.on('cursorActivity', showRelativeLines)
})

Result:

1 Like

Oh, wow, thank you!

I’m a newbie with tinkering things :sweat_smile:

Love the app and yt channel, btw!

1 Like

Hey @craftzdog, I have tried this solution but it doesn’t work. I followed instructions on how to create an init script for MacOS and pasted the code in there you provided. Inkdrop version 5.8.1. Please let me know if you need more details.

Do you get any errors in the Developer Console?

Hi @craftzdog, thank you for your response. I want to apologize for missing the Line Numbers option in Preferences > Editing, but I’ve enabled it now, and it’s working perfectly!

1 Like

Great!