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.
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
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!
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
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:
Oh, wow, thank you!
I’m a newbie with tinkering things
Love the app and yt channel, btw!
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!
Great!