How to stop the blinking cursor in VIM mode?

set guicursor+=n-v-c:blinkon0 not work
set guicursor+=a:blinkon0 not work

I don’t think this is possible, but you might want to give the vimrc plugin a try just in case. It probably has documentation on what CodeMirror supports in regards to vim.

I found this on Codemirror

cursorBlinkRate: number
Half-period in milliseconds used for cursor blinking. The default blink rate is 530ms. By setting this to zero, blinking can be disabled. A negative value hides the cursor entirely.

How to implement this?
Help stop this blinking)))

P.S.
Obsidian Vimrc Support Plugin installed

Hey AL_AL,

that’s a pretty good lead already. I managed to find a very, very hacky way of setting this option.

Since these are options specific to a CodeMirror object instance, I looked around on the website for a cheap and easy way to set this. Turns out there is the static method CodeMirror.defineInitHook which takes as argument a function and runs that function on each intialisation of a codemirror instance. This function receives as parameter the aforementioned instance.

So, a really hacky way would be to just do

CodeMirror.defineInitHook(function(instance) {
    instance.setOption('cursorBlinkRate', 0);
});

the big question is of course where to put that snippet of code.

I think a good way would be to put it in a really small standalone Obsidian plugin. There seems to be plenty of documentation on how to develop a plugin. I briefly tried checking out the obsidian sample plugin but I couldn’t get it to compile on first try and don’t feel like messing around with npm tonight.

Another really hackish way that seems to work is just put the snippet into some other plugin’s main.js. In this case, I used the vimrc plugin above and put the snippet in VimrcPlugin.prototype.onload.

Cheers,
Ben

Hi again,

I went a bit further and set up a super simple barebones plugin that disables cursors blink (as far as I can see).

If you’re familiar with git, you can clone it from here directly into <workspace>/.obsidian/plugins/. Unless you make any changes, you should be good to go, the compiled main.js comes with it.

Don’t forget to enable the plugin in the Obsidian settings.

Cheers,
Ben

3 Likes

This is working for me. Thanks @xnhp!

I just gave you a pull request to update the manifest.json so it shows as something other than “Sample Plugin” :slight_smile:

Nice, thank you aswell.

If you are interested in further styling your cursor, here’s how to change the colour of the vim block cursor (and get the current line highlighted).

I was just attempting to use this and while it does appear for me in my community plugins, for some reason, it didn’t work, even after disabling all other core and community plugins and using the default theme. If you have any suggestions for what I could be doing incorrectly, I would be open to any suggestions. Thank you!

I tried using the legacy editor and it works when using that. (for anyone else who comes here) I am guessing the new editor requires updated code?

1 Like

Just put this in a css snippet:

.CodeMirror-cursor, 
div.CodeMirror-cursor, 
.cm-fat-cursor,
.cm-animate-fat-cursor,
.cm-fat-cursor-mark, 
.cm-cursor{
 visibility: visible !important;
}

First seen here: https://forum.obsidian.md/t/options-to-modify-cursor-style/1091/4.

5 Likes

This works for me. Thanks a lot!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.