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

Can't remap keys correctly

Open oswid opened this issue 4 years ago • 9 comments

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

oswid avatar Jan 25 '21 21:01 oswid

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)?

esm7 avatar Mar 29 '21 03:03 esm7

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

StephenBrown avatar Apr 08 '21 14:04 StephenBrown

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

Arax20 avatar Apr 22 '21 14:04 Arax20

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

peteanning avatar Sep 28 '21 11:09 peteanning

@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

Arax20 avatar Sep 29 '21 08:09 Arax20

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.

peteanning avatar Sep 30 '21 08:09 peteanning

@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.

esm7 avatar Oct 13 '21 11:10 esm7

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.

luuf avatar Aug 16 '22 21:08 luuf