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

Feature Request: <esc> key mapping

Open Gatongone opened this issue 4 years ago • 15 comments

Thank you for your nice plugin.

I found that the key cannot be mapped during the process of using the plugin.

I am personally used to map the switch of Normal mode and Insert mode to the key.

Can you support the mapping of the key?

Gatongone avatar Mar 10 '21 05:03 Gatongone

FYI I've found that while mapping to <ESC> does not work, mapping to <C-[> does. I've also found that while inoremap isn't working properly, imap is.

LostLaplace avatar Mar 23 '21 04:03 LostLaplace

It's probably a CodeMirror limitation and maybe I can work around it, I'll look into it when I get a few hours to work on the plugin.

esm7 avatar Mar 29 '21 03:03 esm7

FYI I've found that while mapping to <ESC> does not work, mapping to <C-[> does. I've also found that while inoremap isn't working properly, imap is.

I think it's CodeMirror limitations. For example, instead of <ESC> try use <Esc>. https://github.com/codemirror/CodeMirror/blob/58bb622cfc210af2c1adcd50a55971fd0d631bfb/keymap/vim.js#L63

About inoremap , there just no such mapping https://github.com/codemirror/CodeMirror/blob/58bb622cfc210af2c1adcd50a55971fd0d631bfb/keymap/vim.js#L230-L234

velixor avatar Mar 30 '21 20:03 velixor

I created https://github.com/esm7/obsidian-vimrc-support/issues/24 as a stand-alone issue, since it seems like there are many use cases for inoremap and it's very easy to implement.

esm7 avatar Apr 05 '21 07:04 esm7

It's probably a CodeMirror limitation and maybe I can work around it, I'll look into it when I get a few hours to work on the plugin.

Thanks

Gatongone avatar Apr 06 '21 00:04 Gatongone

It's not related to this issue but, my .obsidian.vimrc is not working, probably I'm missing something, any idea?

Here is my folder tree (vault root): image

Here is the content of it: image

fuatto avatar Apr 24 '21 08:04 fuatto

It's not related to this issue but, my .obsidian.vimrc is not working, probably I'm missing something, any idea?

Here is my folder tree (vault root): image

Here is the content of it: image

If you're sure that the Vimrc plugin is installed & enabled, can you please open a separate issue for this, hopefully also together with any logs you may have in the development console (press Ctrl+Shift+I and copy what's in the Console tab)?

esm7 avatar Apr 26 '21 16:04 esm7

Definitely subscribing to this issue. I want to use vim mode but not being able to rebind escape is a non starter for me.

patrick-motard avatar Oct 03 '21 20:10 patrick-motard

Hey @patrick-motard is it working for you now? I set this plugin up and mapped Esc key to jj and works for me.

RIT3shSapata avatar Dec 19 '21 07:12 RIT3shSapata

For example, instead of <ESC> try use <Esc>.

this is the solution, btw. <Esc> works flawlessly.

chrisgrieser avatar May 17 '22 21:05 chrisgrieser

@RIT3shSapata I followed the suggested approach and was able to rebind escape using:

imap fd <Esc>

patrick-motard avatar May 31 '22 17:05 patrick-motard

For example, instead of <ESC> try use <Esc>.

@velixor how unobvious it is. Ty man

karmicdude avatar Nov 28 '22 10:11 karmicdude

Not working for me still even with Esc (uppercase E, lowercase sc) - and incredibly annoying

sachasmart avatar Dec 18 '23 00:12 sachasmart

@sachasmart - I'm wondering if your vimrc file is set up correctly in Obsidian. Can you confirm the following for us?

Lets assume your vault is in ~/Documents/vault/ and your rc file is called .obsidian.vimrc.

  • The rc file is located at ~/Documents/vault/.obsidian.vimrc
  • It is not the same rc file that you use for vim in the terminal.
  • The only contents in the file is imap fd <Esc> - this rules out any other settings in the file causing issues.
  • In obsidian Settings > Vimrc Settings > Vimrc file name : .obsidian.vimrc

If you can try this and let us know if it works or not, we can rule out several possible places where an issue could be in your setup.

patrick-motard avatar Dec 18 '23 14:12 patrick-motard