esm7 / obsidian-vimrc-support

A plugin for the Obsidian.md note-taking software
MIT License
1.08k stars 49 forks source link

Can't remap keys correctly #16

Open oswid opened 3 years ago

oswid commented 3 years ago

After use my vimrc some problems appear with keys "l", "r" and "w". They are not remapped version 0.2.3

noremap I a
noremap o l
noremap u k
noremap e j
noremap a h 
noremap O $
noremap A 0 
noremap U gg
noremap E G
noremap k u
noremap w r
noremap W R
noremap R I
noremap L A
noremap r o
noremap l O

in webStorm all working correctly

esm7 commented 3 years ago

Sorry for the long time to reply. Is this still happening? I can't recreate these, they seem to work well for me. Are you sure you have the Vimrc plugin enabled (because noremap is a feature of the plugin, it doesn't exist in the built-in Vim support)? Also, what happens when you try to apply the commands interactively (:noremap I a in Obsidian)?

StephenBrown commented 3 years ago

This might be related, but I have quite a few remappings that work in Vim and with this Vimrc plugin, but switching l and o:

noremap l o
noremap o l
nnoremap L O
nnoremap O L

Switching y and h works fine. There might be an issue with remappings that touch either/or l and o.

These all work fine when remapped below the l and o remappings in the .obsidian.vimrc file:

noremap j n
noremap n j
noremap J N
noremap N J
noremap gn gj
noremap gj gn
noremap k e
noremap e k
noremap K E
noremap E <nop>
noremap gk ge
noremap ge gk
noremap h y
noremap y h
noremap H Y
noremap Y H
Arax20 commented 3 years ago

This may be a similar issue For me:

noremap j gj
noremap k gk
noremap H g^
noremap L g_

noremap J 5gj
noremap K 5gk

noremap W 4w
noremap B 4b

All failed to work

peteanning commented 3 years ago

I try to remap my navigation keys as per my Mac main vim settings:

noremap ; l noremap l k noremap k j noremap j h

but this does not work

Arax20 commented 3 years ago

@peteanning I switched to using map instead of noremap and that solved most of my issues. My remaps aren't too complex so recursion isn't a huge concern for me, something like:

map ; l
map l k
map k j
map j h
peteanning commented 3 years ago

I

@peteanning I switched to using map instead of noremap and that solved most of my issues. My remaps aren't too complex so recursion isn't a huge concern for me, something like:

map ; l
map l k
map k j
map j h

Tried this no difference. I wonder if fundamentally if this is not working.

esm7 commented 3 years ago

@oswid are there any side-effects if you use map instead? Basically CodeMirror doesn't support noremap and it's a feature of the plugin, I'll spend some time when I'm able to check if it might be broken, but I think recursive mappings are not possible in CodeMirror anyway so map or nmap should work.

luuf commented 2 years ago

but I think recursive mappings are not possible in CodeMirror anyway so map or nmap should work

When I have map k hk in my vimrc (to try to work around another obsidian bug), that causes exactly the issues you would expect from recursion. And unfortunately noremap doesn't work.

B4rc1 commented 2 days ago

This works for me now with obsidian 1.7 🥳 🎉