Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obcommand inserts name of command instead of executing it #255

Open
2 tasks done
tprotopopescu opened this issue Dec 18, 2024 · 2 comments
Open
2 tasks done

obcommand inserts name of command instead of executing it #255

tprotopopescu opened this issue Dec 18, 2024 · 2 comments

Comments

@tprotopopescu
Copy link

tprotopopescu commented Dec 18, 2024

Please Review Before Posting!

  • I checked that the bug does not happen in the CodeMirror Vim demo. If it does, please report it there and not here.
  • 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:

obcommands no longer execute the command but instead insert the name of the command. If in insert mode then the name of the command ':mycommand' is inserted, in normal mode the command line is opened and the name of the command inserted there.

To Reproduce:

Add the following to obsidian.vimrc file:

exmap highlighttext obcommand editor:toggle-highlight imap === :highlighttext nmap '= :highlightext

In insert mode typing '===' should toggle highlight, instead it inserts the text ':highlighttext'.

In normal mode typing " '= " should toggle highlight, instead it opens the vim command line and inserts the text 'highlighttext'.

Environment (please complete the following information):

  • OS: Linux (opensuse 15.6)
  • Vimrc plugin version: 0.10.2
  • Obsidian: 1.7.7
  • Installer: 1.6.7

Additional context:

Add any other context about the problem here.

Reproduced in a sandbox vault with only vimrc plugin installed. I can say for sure this was working for me on versions 0.7.x; tried downgrading with BRAT and the problem persists, so it is probably something in obsidian that has changed which breaks the obcommands.

@ko-shin-ryo
Copy link
Contributor

With the update to Obsidian 1.7.2, executing Ex commands now requires appending <CR>.

Transitioning from Insert mode to Command-line mode may work as expected if you pass through Normal mode first. In such cases, you might consider appending a immediately after the command to return to Insert mode seamlessly.

Based on this, the following .obsidian.vimrc configuration should work as intended:

exmap highlighttext obcommand editor:toggle-highlight
imap === <Esc>:highlighttext<CR>a
nmap '= :highlighttext<CR>

@tprotopopescu
Copy link
Author

Thank you, thank you! I got the commands working. Should I mark this as closed? Or is this something that will be changed in upcoming versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants