Wednesday, October 27, 2021

Re: [vim/vim] [question] How to remap ctrl + Left/Right (Issue #9059)

On 2021-10-27, Julio Guerrero wrote:
> Hi Gary, I have applied those changes in my vimrc but the problem remains,
> after I ran the verbose command maps are pointing to my vimrc (same lines I
> added). I'm sorry I did not know this is the dev repo, will move my question to
> the other repo.
>
> Hi lacygoill, as per your questions:
>
> • $TERM: screen-256color
> • E846: Key code not set:
> • Ctrl-V then Ctrl-Right, delete lines
> • I use tmux
> • TERM out multiplexer: same as inside VIM - screen-256color

I'm using a different terminal now than I was this morning. Running
vim within tmux, I now see the problem.

In insert mode Ctrl-V Ctrl-Left inserts:

^[[1;5D

Ctrl-V Ctrl-Right inserts:

^[[1;5C

See

:help i_CTRL-V

Pressing Ctrl-Left in either normal or insert modes deletes the next
5 lines. Pressing Ctrl-Right also deletes 5 lines but goes to
insert mode.

That makes sense. Vim doesn't recognize those escape sequences so
it processes them as normal keystrokes. In normal mode, Vim ignores
that first <Esc> (^[). In insert mode, that first <Esc> puts Vim
into normal mode. Vim does not recognize the sequence [1 and
appears to ignore it. The ; will repeat the latest f, t, F or
T command. That may or may not move the cursor and affect the next
command. 5D deletes 5 lines. 5C deletes from the cursor to the end
of the line 4 more lines and starts insert mode.

I don't know the right solution at the moment, but a workaround
would be to put this in your vimrc.

if &term == "screen-256color"
nnoremap <Esc>[1;5C <C-Right>
nnoremap <Esc>[1;5D <C-Left>
inoremap <Esc>[1;5C <C-Right>
inoremap <Esc>[1;5D <C-Left>
endif

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20211027201947.GC2195%40phoenix.

No comments: