obsidian-vimrc-support icon indicating copy to clipboard operation
obsidian-vimrc-support copied to clipboard

[BUG] Fails to run obcommand that has spaces

Open gabrielcarloto opened this issue 1 year ago • 2 comments

Please Review Before Posting!

  • [x] I checked that the bug does not happen in the CodeMirror Vim demo. If it does, please report it there and not here.
  • [x] I'm reasonably sure that this bug is indeed about the Vimrc file support and not a general Vim in Obsidian issue. If it's a general Vim issue, report it here.

Describe the bug:

I want to map a templater template to a key. I added it to the obsidian commands using the Template Hotkeys section in the templater settings. The command id is templater-obsidian:path/to/template.md. In my case, the templates folder has a space, therefore the id looks like this: templater-obsidian:path to/template.md. I added the following lines to my config:

exmap insert_template obcommand templater-obsidian:path to/template.md
nmap <Space>t :insert_template

When I press <Space>t, it only outputs in the console Error: obcommand requires exactly 1 parameter.

Is there a way to make it work (without having to rename the folder)? If not, I'd suggest adding support for "command:that has spaces" (edit: actually I don't know if this is how it would be done in a .vimrc).

Environment (please complete the following information):

  • OS: Windows 11
  • Vimrc plugin version: 0.9.0

gabrielcarloto avatar Feb 19 '23 20:02 gabrielcarloto

I don't think this can be easy fixed right now because it's a limitation of CodeMirror Vim and you can't customize the delimiters;

however, I found a way around it. You can use the Command Alias plugin, customize a new command, then find the new command id without space through :obcommand (the command id like this obsidian-command-alias-plugin: Alias: XXXXXXXXX) , map the new command directly.

jiyee avatar Feb 20 '23 01:02 jiyee

Never heard of that plugin. It works well, thank you!

gabrielcarloto avatar Feb 20 '23 13:02 gabrielcarloto