VIM Mode - Quality of Life Improvements

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).

See also: VIM Mode - Quality of Life Improvements

Well then Ctrl-V shouldn’t be working either.

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.

1 Like

I completely agree.

For those who want the Ctrl+C combination to work with clipboard in Vim mode - you can temporary unmap keybinding in your current session.

Run CodeMirror.Vim.unmap('<C-c>') in console. You can do remapping similar way.

3 Likes

@mrjackphil’s great tip emphasizes the need to Support loading Vim commands from configuration (vimrc-style).
Otherwise, like he says, this is a temporary hack that needs to be repeated on every session.

2 Likes

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!

1 Like

I believe (but I could be wrong, of course) what testing API would be available soon. I’ll adapt this workaround for it.

2 Likes

Thank you so much, I’ll keep an eye for it once the API is available. I appreciate your hard work!

1 Like

I would add that currently using standard vim navigation I can not move cursor behind the last symbol in the line.

I guess thats normal vim. You can press a to get in insert mode right from the cursor.

1 Like

thank you for the tip. I’m new in vim. However I’ve checked this in Neovim and it works as expected

1 Like

in Neovim and it works as expected

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:
image

Neovim with a block cursor:
image

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.

2 Likes

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.

best,
ilya

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.

2 Likes

I managed to cofigure vim mode to work really nice in obsidan, I’ve taken notes on some fixes for Linux and Mac.

What is it that’s not working in your obsidian vim mode, I might be able to help.

Does holding down one of the hjkl keys not work for you?

holding down one of the hjkl keys

@santi if you’re replying to kohane27 typing “jk”, I presume they are mapping the key sequence “jk” to <ESC> in insert mode in Vim, which is a common ergonomic trick. It’s not about navigating or repeatedly pressing j or k.

2 Likes

Hey @rigmarole yeah forgot to tag @kohane27 on my reply

Got you, thanks for the clarification. I thought jk was referring to pressing and holding j or k

I wasn’t familiar with that way of using escape. I’ve tried fd and currently I useCAPSLK

but what I can recommend is this volcano plug in (linked below) for setting up an .obsidian.vimrc to configure it

I currently have this settings

nmap j gj
nmap k gk

and it works great so far.

2 Likes

@santi

Apologies for my lack of clarity! Yes I meant remapping jk for Escape in Vim.

@rigmarole thanks for clearing that up!

1 Like