2

How can I make Vim not remove lines below with Ctrl and Left Arrow?

So I just found a dangerous setting with Vim on Linux.

If I press Ctrl and Left Arrow then whole rows below start vanishing. With autosave disabled this could accidentally destroy hours of work.

How do I disable this dangerous behaviour in .vimrc for example?

5
  • With autosave disabled typing ':1,$d<enter>' could also accidently destroy hours of work. What terminal emulation do you use, and is it set correct?
    – Luuk
    Jun 1 '19 at 10:53
  • 1
    But, undo? This is probably just a misconfigured escape sequence gone awry. @Luuk or :%d, but again, u...
    – D. Ben Knoble
    Jun 2 '19 at 2:14
  • 3
    OP, can you add the text displayed when you start vim, press i, Ctrl-V, then Ctrl-Left ?
    – D. Ben Knoble
    Jun 2 '19 at 3:15
  • please also show what terminal you are using and what is $TERM set to? Jun 12 '19 at 8:59
  • This happened for me also when I used vim under tmux. The way to fix is described here: superuser.com/a/402084/315705 - it worked for my case. Jan 30 '21 at 11:18
0

I had a similar problem when using the git-bash inside the "Windows Terminal" tool. When using the git-bash standalone, everything worked fine in vim. But when using inside the Windows Terminal everything related to the ctrl key was strange. ctrl + right arrow deleted a lot of stuff, ctrl + end switched a character between upper and lower case instead of jumping to the end, etc.

Putting set term=xterm into my ~/.vimrc resolved the errors. This may be not a generic solution for the issue, but there isn´t such either (as of all the many different terminals used).

As mentioned in the comments https://superuser.com/questions/401926/how-to-get-shiftarrows-and-ctrlarrows-working-in-vim-in-tmux/402084#402084 seems a nice hint either.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy