Vim in multiple keyboard layout

Hi I am using Joplin editor on my fedora kde 36 laptop.
I use the vim option in the Joplin, it works great in English kayboard layout QWERTY, but when I switch to Hebrew it doesn't work anymore, is there a way to make it ignore keyboard layout and use the key code of each key?

1 Like

Please see vim mode is usable only with "eng"(latin) keyboard layout ยท Issue #6591 ยท laurent22/joplin ยท GitHub

I didnt see any solution for my problem, it seems that joplin devs uses some library for emulating vim and this library causes the issue, is there any workaround to solve this issue other use vim as external editor?.
also after going through the chain of refs to other issues it seems that it can be solved if there was some kind of vimrc file in joplin files folder and map the keys manually

1 Like

I just tested CodeMirror6's ViM emulation and it doesn't work (so upgrading to CodeMirror 6 wouldn't fix the issue).

It might be possible to customize vim emulation with a plugin through CodeMirror 6's ViM emulation API and Joplin's plugin API, but I don't think it's currently possible to load a vimrc-like file (but I think Joplin should add support for this).

To prevent users from having to wait for a new Joplin release, it might make sense to create a vimrc plugin (I may have time to work on this over the next few days).

3 Likes

thank you for the help.

I've created a plugin (GitHub repository)! It should show up in the plugin repository in the next day or two.

Screenshot of "custom CodeMirror .vimrc" plugin in plugin repository.

After installing, pressing ctrl+shift+P and searching for vimrc allows editing a very limited .vimrc-like file that supports map, noremap, imap, inoremap, etc:
screenshot of edit .vimrc in the command palette

2 Likes

Hello, thanks for the plugin. I have the same problem as you have. I've set up your plugin, but it seems that it is not working. I click cmd+shift+P see popup window with text, click okay and nothing happends.

(I've pushed an update with several bug fixes, including an issue with comment lines โ€” it seems to work fine in my version of Joplin that's built from source, but not in the standard version of Joplin...)

Here's my .vimrc-like file:

nmap ื™ h
nmap ื— j
nmap ืœ k
nmap ืš l

Please try again in a few hours (when v1.0.2 v1.0.3 is available on the Joplin plugin marketplace).

Thank you for reporting this!

1 Like

I set up the stable AppImage in my development environment and have fixed the issue.

In Joplin 2.8.8, lines in the .vimrc were read with \r\n separators. In Joplin 2.9.8 (the version I was testing with), lines were read with \n separators. My code was only handling \n separators. Version 1.0.3 should fix the issue by removing \rs before attempting to parse the .vimrc.

1 Like

That's working, thanks. Amazing plugin. I was struggling with this problem for months. Thank you a lot. :pray:

For people who will use this plugin it maybe not obvious how to set it:

  1. Install the plugin
  2. Restart the joplin
  3. press cmd/ctrl+shift+P
  4. type vimrc you will see the hint, press inter
  5. type your commands after the text in the pop-up window

Because the 5) item was not obvious for me.

1 Like

Thank you for this useful plugin.

I have encountered an error. The search does not work when I press the / button. The logs contain the following messages:

/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/keymap/vim.js:1215 Uncaught TypeError: Cannot read properties of undefined (reading 'length')
    at HistoryController.pushInput (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/keymap/vim.js:1215:19)
    at handleQuery (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/keymap/vim.js:1359:50)
    at Object.processSearch (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/keymap/vim.js:1434:15)
    at Object.processCommand (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/keymap/vim.js:1261:18)
    at /Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/keymap/vim.js:963:37
    at runInOp (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/lib/codemirror.js:3950:28)
    at CodeMirror.operation (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/lib/codemirror.js:8647:37)
    at /Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/keymap/vim.js:957:23
    at doHandleBinding (/Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/lib/codemirror.js:7161:14)
    at /Applications/Joplin.app/Contents/Resources/app.asar/node_modules/codemirror/lib/codemirror.js:7238:69

Dot (., repeat) also does not work.

Could you please help me to fix it?

1 Like

Thank you for reporting this! Let's try to fix it!

For me, with

nmap ื™ h
nmap ื— j
nmap ืœ k
nmap ืš l
nmap รฑ /
unmap <Ctrl+C>

as my vimrc, pressing / and รฑ to search both work. . also works.

(Note that re-mapping built-in mappings might not work โ€” the CodeMirror documentation (I think) says that unmap only works for user-defined commands).

What keyboard layout are you using? What version of Joplin? What is your vimrc-like configuration file?

Today after stopping and starting Joplin (not restarting) everything worked. It may have been a false alarm.

I'll keep watching for a while longer and let you know if the error reappears.

Thanks for the wonderful plugin, it makes life a lot easier.

1 Like

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