I’m having trouble with hjkl movement in insert mode.
The issue is that I have changed hjkl movement to move by display line. I have
'wrap' on. The cursor should normally move line by line, not move display line by display line.
With my vimrc, when Ctrl is pressed along with up or down movement, it should move through display line by display line, but somehow it kept inserting a space and moving through display line (especially up movement).
Yesterday, I tried with only the Ctrl + movement key in insert mode, and it worked fine, but it failed to work properly when other scripts are included. I can't figure out how to solve it.
:set wrap linebreak nolist :set showbreak=… vmap j gj vmap k gk nmap j gj nmap k gk inoremap <C-h> <Left> inoremap <C-j> <C-o>gj inoremap <C-k> <C-o>gk inoremap <C-l> <Right> cnoremap <C-h> <Left> cnoremap <C-j> <Down> cnoremap <C-k> <Up> cnoremap <C-l> <Right>
<C-j>in Insert mode, to trigger the
<C-o>gjmapping? You said it's not working, but what is happening in that case? Is it just not moving at all, or moving to the next real line instead of the next virtual line? Can you reproduce the issue by typing
<C-o>gjdirectly? Can you try to reproduce it with a minimal vimrc with only 4 or 5 lines needed to set that up? If you inspect the mappings with
:imap, do you see that
<C-j>mapping correctly displayed there?
:set listenabled to see if you have any extra unwanted spaces there?