[bug] Cannot unmap the default jumpToPreviousLink mapping and remap it onto another key
Please make sure your question is within the scope of this plugin.
- [x] I know this plugin is about persisting changes to the Vim support built into Obsidian, plus some bonus features, and considered asking in the Obsidian forum first.
Describe the question I prefer this settings in my vimrc file:
" using H and L for beginning/end of line
noremap H ^
noremap L $
noremap gH H
noremap gL L
But gL is conflict to the default settings after v0.10 where gl and gL are introduced.
I'd like to keep my settings and remap gL to another key. How should I do?
Bug confirmed. See https://github.com/esm7/obsidian-vimrc-support/issues/264#issuecomment-2898167308
I also want to know how to disable keymaps
# disable ctrl-c and ctrl-v
vmap <C-c> <nop>
map <C-v> <nop>
This works fine in vim, but in obsidian, it prints
Hi, DeeliN221. Your question seems to be unrelated to mine. So it'd be better to create a new issue for that. But anyway we could ask dev @alythobani and hope he know how to anwser them
Hey,
@DeeliN221
According to the README you should be able to use unmap as well as vunmap, iunmap, and nunmap. I tried this out locally and it seems to work:
vunmap <C-c>
unmap <C-v>
@XDcedar
The settings you pasted work for me. To map a different key combo to jumpToPreviousLink, it seems to work if I do this:
" using H and L for beginning/end of line
noremap H ^
noremap L $
noremap gH H
" First noremap 'L (or whatever key combo you want) to gL before it gets mapped away from jumpToPreviousLink
noremap 'L gL
" Now we can map gL from jumpToPreviousLink to L
noremap gL L
@alythobani I didn't notice those commands, thank you very much, it works.
Thanks for replying, @alythobani
I tested your settings but it didn't work.
I create a test Vault and copy-paste them to my .obsidian.vimrc. Then I relaunch Obsidian and make sure the new settings are loaded. H, L, gL and gH work fine. The default mapping gl also works fine. But type 'L doesn't do anything.
For your information, I'm using Windows 11 and Obsidian v1.8.10 (the latest version).
I rarely use jumpToNextLink or jumpToPreviousLink so I can live with it. But I think it might be a bug.
@XDcedar ah you're right, I tested things out in a new vault and the settings above didn't work, on their own.
Weirdly enough, it was that I had other settings - in particular ones that unmap s and S - that enabled me to noremap 'L gL successfully. It seems to require all 4 unmapping lines.
If you want to try it out feel free:
" NOTE: must use `nunmap s/S` and `vunmap s/S` and not `unmap s/S`
nunmap s
vunmap s
nunmap S
vunmap S
" First noremap 'L (or whatever key combo you want) to gL before it gets mapped away from jumpToPreviousLink
noremap 'L gL
noremap 'l gl
" Now you can map gL from jumpToPreviousLink to L
noremap gL L
noremap gH H
" Now we can map L away
noremap H g^
noremap L g$
map 0 ^
This definitely is a bug though. I haven't looked at all at the mapping/remapping internals so I'm not sure what exactly is going on.
It works after unmapping s/S. However I cannot do that since I need s/S keys. But still good to know it's a bug. Thank you! I'll keep this work-around as a comment in my .vimrc file.