@ not working as vim command with Swiss keyboard

Steps to reproduce

Expected result

  • the key @ in vim command mode replays a recorded vim macro (e.g. @a replays the recorded macro of register a)

Actual result

  • Typing @ is not recognised as a command, but inserted into the text at the current position.

Environment

  • Operating system: macOS Monterey Version 12.6
  • Debug info:
SYSTEM INFO:
	Obsidian version: v0.16.3
	Installer version: v0.14.6
	Operating system: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 21.6.0
	Login status: logged in
	Catalyst license: insider
	Insider build toggle: on
	Live preview: on
	Legacy editor: off
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 1
	Restricted mode: on

Additional information

  • no

Download and reinstall obsidian.

  1. Does it happen in the sandbox vault?
  2. Does it happen in source mode?
  3. Does it happen here https://codemirror.net/5/demo/vim.html ?
  4. Does it happen here https://codemirror-vim--util.repl.co/ ?

I just tested in Windows and MacOS, and it’s working for me.

(You need to redownload and install because your installer is out of date, older than certain features that the auto-updater can’t self-install. That won’t necessarily fix this particular issue. But it might.)

As a tangential question, is not being able to self-update a bug/issue with the installer that will eventually be resolved, or is it an inherent weakness that will always have to be worked around by doing a manual download/install from time to time?

I have downloaded and installed Obsidian again with the latest installer. But the Problem is still here (@ is not recognized as a vim command).

SYSTEM INFO:
	Obsidian version: v0.16.3
	Installer version: v0.15.9
	Operating system: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 21.6.0
	Login status: logged in
	Catalyst license: insider
	Insider build toggle: on
	Live preview: on
	Legacy editor: off
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 1
	Restricted mode: on

Download and reinstall obsidian.
DONE, I have now Installer version: v0.15.9

  1. Does it happen in the sandbox vault? YES
  2. Does it happen in source mode? YES
  3. Does it happen here https://codemirror.net/5/demo/vim.html ? NO, here it’s fine and works as expected (I can replay a macro)
  4. Does it happen here https://codemirror-vim–util.repl.co/ ? NO, but something unexpected happens, as soon as I press @, an edit box labeled “Go to line:” opens below the editor.

I seems to have something to do with the keyboard. I am using a Swiss Keyboard (Schweiz, deutsch) and here I have to Press Option-G to write a @.

I change the keyboard to English and here it works as expected. If I press Shift-2 to write a @, it is recognized as a vim macro.

The key event test script Javascript Key Event Tester shows following differences:

Swiss keyboard (pressing Option-G):

keydown  keyCode=18        which=18        charCode=0        
keydown  keyCode=71  (G)   which=71  (G)   charCode=0        
keypress keyCode=64  (@)   which=64  (@)   charCode=64  (@)  
textInput data=@
@keyup    keyCode=71  (G)   which=71  (G)   charCode=0        
keyup    keyCode=18        which=18        charCode=0        

English keyboard (pressing Shift-2):

keydown  keyCode=16        which=16        charCode=0        
keydown  keyCode=50  (2)   which=50  (2)   charCode=0        
keypress keyCode=64  (@)   which=64  (@)   charCode=64  (@)  
textInput data=@
@keyup    keyCode=50  (2)   which=50  (2)   charCode=0        
keyup    keyCode=16        which=16        charCode=0            
1 Like

open a bug report here and explain how to repro with https://codemirror-vim–util.repl.co/

It is not possible to reproduce the error on https://codemirror-vim--util.repl.co as this environment is different from Obsidian and the two environments behave differently.

When I press Option-G on my Swiss keyboard in Obsidian, the @ character is written (instead of executing as a VIM command). However, when I press Option-G in https://codemirror-vim--util.repl.co, an edit box with the label “Go to line:” appears below the editor and no @ character is inserted into the text in the editor.

I think it should be relatively easy to reproduce the error in Obsidian:

  • Install Swiss keyboard under Apple menu > System Preferences > Keyboard > Input Sources (besides the existing English keyboard).
  • Activate Swiss Keyboard
  • in Obisidam with vim in command mode press Option-G
  • now the character @ is written instead of interpreted as a command

If this is something relegated to how obsidian handles hotkey in various languages, we are not going to fix this because solving this problem for all possible languages with the current API has proven impossible. We found a compromise that works for most people and we won’t change it until new APIs are available.

If this problem comes from a library upstream, in this case codemirror-vim, if they fix it, we will get the fix.

Without VIM, you can also check if Option-G triggers some command in obsidian and than disable that command/hotkey in settings. Maybe that’ll help.

It seems similar to this issue

But Alt is in the ignored keys, so this isn’t the same issue.

I can repro this with dead keys in normal mode, so the issue is probably that it doesn’t wait for the composition to happen. If that is how macos does it with option keys, I don’t know if that is the case. See this issue comment re dead keys.

I could test it on CodeMirror: Vim bindings demo (where Option-G does not seem to be mapped to “Go to line”).

Here it works fine and Option-G (on Swiss keyboard) is interpreted as a vim command.
Here I can record and replay macros without any problems.

I would expect to behave the same in Obsidian.
Because it seems to work in CodeMirror, is this a bug of Obsidian which could be fixed?

The link goes to the legacy editor vim test, not the cm6 one.

@Bonito Unfortunately, I was not able to solve it. Have you been by now?

I am still waiting for a solution. I think I have described simply and clearly above how to reproduce this bug (by switching to Swiss Keyboard). Unfortunately, I cannot correct this bug myself and have to rely on the help of others.

I see. I have created a github issue on the codemirror-vim repo (link). The (supposed) fix is to be included from upstream. @WhiteNoise did not give a precise estimate of time until inclusion, so we’ll just have to wait (link)

In case anyone is interested in a workaround:

  1. Enable vimrc support: https://github.com/esm7/obsidian-vimrc-support
  2. Create a file named .obsidian.vimrc in your vault directory and insert the following lines to add a remap for the @-character (I chose <Space>m for “macro”, but you can choose whatever you like):
" unmap space to act as leader key
unmap <Space> 

"remap @-key
nmap <Space>m @
  1. Then you can execute recorded macros in Obsidian with <Space>m {register}.
1 Like

should be fixed in 1.1.14. Let me know if it works.

1 Like

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