Vim support for the new editor (Codemirror 6) - Neovim, libvim, or something else

I second this request. I think it may be impossible to use plugins/hotkeys and many other Onsidial features while in VIMR mode but, this still makes sense, especially if switching back and force will be as easy as toggling preview mode with Cmd/Ctrl+E . Main reason is being able to use keep the same screen layout without opening new windows as the external editor doesnā€™t know what part of the screen the current file occupies.

4 Likes

@macintacos when you say this should be a feature request rather than a plugin idea, do you know what kind of access to the codebase would be needed to implement this? For example, if this is gated on Obsidian devs not having bandwidth to implement this right now but also requires knowledge of the closed source, I wonder if thereā€™s some sort of hypothetical API that this could be implemented against s.t. if this were developed like a plugin against that API they would be able to take that work and integrate it into Obsidian directly w/o having exposed their source (assuming they have bandwidth to review but not to author). I honestly donā€™t know if this is a viable route, but it seems maybe worth exploring?

Perhaps itā€™d work as a plug-in - Iā€™m not sure if the editor that is currently being used by Obsidian could pass in Neovim as a backend, but Iā€™m not experienced enough to know. I mostly am saying that it should be a feature request simply because if this could work, it should be the default Vim implementation instead of a plug-in that users need to seek out.

I forget what editor technology Obsidian uses, perhaps that has a way to make this easily doable?

2 Likes

I totally realize that it may be out of scope for obsidian, but I would love to see a more ā€˜nativeā€™ vim experience.

Though a heavy vim user, I never use vim modes in apps because I cannot bring along things like easymotion and leader commands which have become second nature in my workflow.

5 Likes

Just want to voice that I am also really looking forward to this feature.

2 Likes

Warning, possibly unpopular opinion follows :stuck_out_tongue:
A significant amount of work was invested in that VSCode plugin, AFAIK more than any currently-existing Obsidian plugin. Maybe even more than all current plugins combined :wink: Itā€™s quite a significant project.
But it made sense because VSCode is a code editor, and there was a significant amount of users who want a full Vim experience while still using VSCode as their IDE rather than (Neo)vim.
Is there really even a remote justification for making such a project for Obsidian? Itā€™s a notes editor, not an IDE. And while its Vim experience leaves a lot to be desired, it is expandable* to some extent, and IMHO quite capable for a notes editor.
What might make sense is to offer such a project for CodeMirror 6, which is the future iteration for Obsidianā€™s underlying editor component. It is being used in many other products and has a big user base (most are online editors, but possibly enough desktop ones to make Neovim relevant).

* Iā€™m the author of this plugin

6 Likes

Iā€™m also in favor of this, though Iā€™m concerned with how VIM bindings would interfere with Obsidian hotkeys.

Thereā€™s other, non-IDE projects that have this setup. For example, thereā€™s a plugin for SublimeText that hooks directly to Neovim via APIs to give (as far as I can tell) the full VIM experience within SublimeText.

@esm90 I think thereā€™s totally a justification. Obsidian isnā€™t a development tool like VSCode, but part of a notes app is care and refactoring old notes in addition to writing new stuff. As someone whoā€™s into Vim to write a plugin for it, you understand the power and elegance of using it for writing and editing, and I would personally love to take advantage of all that a full-blown Vim client would have to offer.

As far as the CodeMirror 6 mention: I havenā€™t dug deeply, but from what I understand CodeMirror Vim bindings doesnā€™t have a maintainer, so Iā€™m concerned about the future of that implementation.

1 Like

Donā€™t get me wrong, Iā€™m completely in favor of making Obsidianā€™s Vim mode as powerful as possible. I would personally not be using Obsidian without it, and although it covers what I need most of the time (80% of my usage is just the basics anyway, and the Vimrc plugin covers 10% more), we Vim users are used to not be limited.
Given this, I hope someone will have the appetite to make a full-fledged Neovim integration, because Iā€™ll surely be amongst its users.
Also, I too am worried about the state of Vim bindings in CodeMirror 6, and this might eventually lead to someone (maybe even me, who knows) picking this up.

4 Likes

This: neovim-component - npm

looks like a pretty simple way to add this functionality. No idea about how well supported this is, or how easy it is use, but at first glance it looks pretty simple.

(I am also very much in support of something like this, for the record)

This has probably been discussed a bunch of times before, but Vim support is far from ideal.

Thereā€™s a plugin for making a custom vimrc, which helps a bit, but text editing is just not the same without a regular Vim config.

Now, I know this would probably be a lot of work to implement, and I wouldnā€™t bring this up if I hadnā€™t seen it done well somewhere else, but Onivim 2 (an electron-ish app ā€” it uses something else, but the point is that it uses web technologies) uses a Vim C library under the hood and itā€™s freaking fantastic!

It feels just like using Vim, for the most part. All the basic plugins, like vim-surround, for example, work great. So I thought Iā€™d bring this up to see if this would be a feasible thing to do in Obsidian.

What really got my attention, as Iā€™ve been following Onivimā€™s progress for quite a while, is that I think that app is developed by one person, so that got me wondering if this wouldnā€™t be easier to implement than I initially thoughtā€¦

It would be great if somebody picks this up and implements a bridge between libvim or neovim and CodeMirror 6.

3 Likes

Any clue whatā€™s the timeline? When is CM6 expected to take over CM5 in desktop Obsidian?

There wonā€™t be a take over, theyā€™ll coexist at least for a while.

1 Like

This sounds to me like a long-term project that has many uses, but Obsidian is not a major one of them anytime soon (Iā€™m assuming here that Vim mode on mobile is a niche).
But since there will be a switch eventually (CM6 is the future of CM, thatā€™s for sure), it certainly needs long-term attention. I might be able to do that but only in a few months when other big free-time projects get cleared up.

Bounty for vim mode in codemirror 6

3 Likes

I made this meme in hopes to capture the mixed feelings :joy:

I really hope thereā€™s a way in which the new ā€œLive Previewā€ WYSIWYG editor will somehow support vim-mode.

Iā€™m not a programmer unfortunately so I donā€™t know the extent of what it would take for that to happen.


What Iā€™d love to know is what do others think is the best way to make this happen.

Is a donation our only hope? and if so is it a good idea to encourage as many people interested to donate?


Mixed feelings

I personally have been looking forward to the new Obsidian Live Preview editor for so long. Iā€™ve been waiting to release educational content for Obsidian with high hopes on this editor.

The importance of Vim in Obsidian

I also believe that learning vim can benefits all types of writers, to write efficiently and in a much more fun way.

Teaching Vim in Obsidian (project now on standby)

Iā€™ve been working for months on an online course to teach people how to use Vim in Obsidian.

Iā€™ve been waiting for the new editor to release this course (of course I now have to wait for a solution :disappointed_relieved:)

The new ā€œLive Preview Editorā€

The new live editor is the future of Obsidian.

Eventhough I highly recommend to learn Vim in Obisidian, using the old editor is a bad idea, when the much superior live preview editor is exists. So I personally donā€™t think sticking to the old editor is the best way forward.


Finding solutions

I totally understand this goes beyond the control of the Obsidian devs. If anything Iā€™m super grateful for the new amazing ā€œlive previewā€ editor. but as you can image I have mixed feelings #happy-sad

I really hope that those of us who value Vim in Obsidian can find a way to make it happen in the new editor somehow.


If you guys think donating to the bountysource is the best way forward, then letā€™s do it. If not Iā€™d love to know what you guys think is the best way to bring Vim to the new Live Preview editor

Thanks :pray:

4 Likes

This CM6 vim mode experiment repo from the BountySource issue seems like the most up to date and promising effort thus far. Is there an up to date guide for integrating code for CM into Obsidian? I only just got started with Obsidian this last week, and donā€™t have the context of how CM fits in.

3 Likes

Following up on this, the recent changes in the repo (12 hours ago as of this post) have made great progress. Iā€™m able to build and run a barebones CM6 editor with this new experimental Vim mode now :tada:

In my very light testing I havenā€™t had any issues with basic Vim usage. What is typically the next step for including CM changes into Obsidian when a new beta is being worked on, like v0.13 is now?

PS: I donā€™t know who to ping about this, so Iā€™ll ping you given how Vim is blocking us from using Live Preview @santi :slight_smile:

6 Likes

thanks for keeping up with this post, Like you said I havenā€™t been able to move to Live Preview, due to the lack of vim.
Iā€™m not sure if I understood what you said correctly, did you manage to test vim in Obsidianā€™s live preview with the updates done in that CM6 repo?

Really hope thereā€™s a solution for us desperate vimers

3 Likes

licat is creating pulls against that cm6 vim mode experiment repo Add support for font family and font size on fat-cursor. by lishid Ā· Pull Request #1 Ā· nightwing/cm6-vim-mode-experiment Ā· GitHub

1 Like