Remapping `i` key in all shortcuts in vim

I'm trying to interchange i and l keys in vim. I've succeeded in all modes except for one issue. After pressing di vim receives di instead of dl and thus, instead of deleting the character to the right vim waits for another key to be pressed to execute the corresponding shortcut. If another key is pressed then vim acts executing dl + key since the remap is working. At the same time, if dl is pressed vim also waits for a key to execute a shortcut and this time the shortcut is correctly executed since, again, the remap works correctly.

So my question is, why is does vim recieve di after pressing pressing di and executes dl and receives di too after pressing dl but executes di?

In the next picture I pressed di and vim received di but executes dl after pressing another key. enter image description here

In the next picture I pressed dl and vim received di and executed the key combination correctly. enter image description here

The only difference is di vs "+di I can't interpret.

Remaps are the following:

" Movement Remapping
" Down
noremap n gj
" Up
noremap e gk
noremap E K
" Right
noremap i l
noremap I L
" Preserve Insertion
noremap l i
noremap L I

" Next Search Result
noremap k n
" Previous Search Result
noremap K N


" Forward end of word
noremap j e
noremap J E

" Enables writing in snippets selection
sunmap n
sunmap N
sunmap e
sunmap E
sunmap i
sunmap I
sunmap l
sunmap L
sunmap j
sunmap J

Upvotes: 0

Views: 590

Answers (1)

romainl
romainl

Reputation: 196556

Vim commands are not "maps" so those things are not "remaps", they are "mappings".

You seem to be confused about quite a few things…

  • The mapping under Up goes down.
  • The mapping under Down goes up.
  • The first mapping under Left goes up.
  • The second one goes nowhere because K is not even a motion: :help K.
  • The second mapping under Right goes down, to the last line of the window.
  • The third one enters insert mode to the left of the current character.
  • The fourth one enters insert mode to the left of the first printable character.
  • The second mapping under For inverse order search is the only one of the two that relates to "inverse order search".
  • The second mapping under Forward end of word overrides the very useful :help J.

Your problem with di is very likely to be caused by a race condition between your mapping noremap i l and the built-in text objects mechanism (:help text-objects).

I am not sure what you are trying to achieve with all those mappings but overriding things like J or K or disabling entirely some of Vim's most powerful features doesn't sound like a good idea to me, especially with comments that contradict the code.

You should give this more thought.

Upvotes: 1

Related Questions