Would like to second the point about Neovim; I don’t think that we even need to necessarily embed the editor, Obsidian can probably do it in the same fashion that the VSCode neovim extension does it; by just using nvim as a “backend”: https://github.com/asvetliakov/vscode-neovim#how-it-works
I also commented on this thread about adding Neovim as a “plugin”, however I think we’d get 90% of “I wish Obsidian’s Vim mode could do X” requests by just doing it the way the VSCode extension does it and replacing vim keybindings with it entirely.
# abcdef
## abcdefg
text text text text text text
text text text text text text
text text text text text text.
fold the H2 heading (abcdefg)
place cursor on g in H2 heading
go up one line (press K)
go down one line (press J)
Expected result
The cursor should return to the char g or atleast return somewhere on the heading
Actual result
The fold is opened and the cursor jumps to the end of the last line. In the above example it jumps to the fullstop
Environment
Operating system: Ubuntu 20.04
Obsidian version: 8.0.0
Additional information
This is a minor issue, but in vim mode it is common to scroll in a file using the J and K keys (like using arrow keys in non-vim mode) and random folds opening as you scroll and jumping of the cursor interrupts the flow of editing a lot, especially if the fold has lots of text.
I suspect it might be due to the editor wanting to place the cursor at the end of the line as you scroll, but instead placing it at the end of the fold. In vim when going down from a longer line to a shorter line it jumps to the end of the line depending on where the cursor was initially, that might be whats affecting this.
This happens in a lot of random places in my files, the above example was just one i was able to reproduce. I also was not able to reproduce this in normal (non vim) mode.
I wouldn’t consider this a bug. This is always the case for IDEs with vim keybindings and you usually override what Ctrl+C does (see JetBrains, Atom, etc).
Yeah, maybe. You can still enter visual block mode with Ctrl+V from normal mode if you want. Either way, the ability to remap keys is the main point here.
wow @mrjackphil thank you for that tip on unmapping ctrl+c on console. It works perfectly.
Is there any way to make this into a volcano plug-in. So that in persists after restarting obsidian?
thank you!
In Neovim, when in Normal Mode, do you have a block cursor, or a line cursor? I am guessing that if you have a line cursor, it would appear that the cursor is to the right of the last character.
If you have a block cursor, which is what Obsidian uses in Vim mode, then it will appear to be over top of the last character in the line. A line cursor on the other hand, shows up as between characters, so at the end of a line, it shows to the right of the last character.
Obsidian:
Neovim with a block cursor:
I’ve configured my Vim so that when I’m in Normal Mode, I see a block cursor, which more precisely tells me where I am. “I am on the last character in the line”. When I’m in Insert Mode, I see a line cursor, which more precisely tells me where text will insert. (In my opinion/experience.)
This is how Obsidian works. When you go into Insert Mode, it goes back to a line cursor. So I experience no difference in how this behaves between Obsidian and Vim.
ok, ok. My experience with vim is very very limited. almost nothing. I just found that weird that using mouse you may put cursor behind the last symbol however using navigation keys you are not able to do so
EDT: Despite this minor thing, I’m enjoying this tool.
Oh yeah I see what you mean now. That seems to be a glitch, to me.
If you click with the mouse to the right of a line, the block cursor does move to empty space. You shouldn’t be able to do that with the mouse, either. As far as I can tell, that is actually the glitch. It works as expected (to me) with the keyboard.
If you’re like me who’s new to Obsidian and can’t write anywhere else without Vim keybindinds, my current solution is to add a shortcut to Open in Default App (which the extension .md is set to Vim).
After that, when you want to write, trigger the hotkey and write in the real Vim. I know it’s not pretty but it’s the only want I can write without typing jk over and over and over.