My Vim on MinGW 4.6.2 is behaving weirdly, for example, pressing Backspace in insert mode deletes characters, but I have to move the cursor with arrow keys before the deleted characters disappear, and it also takes me out of insert mode.
Another example, pressing Del to delete characters sometimes generates weird characters like changing lowercase characters to uppercase, or corrupts the next character that I key in, for example pressing 'S' gives me '$' initally.
Am I using Vim wrong or something? I'm not too unfamiliar with Vim so I'm not sure if this is default behaviour, but the typical Vim behaviour as I understand is like the Vim in Git Bash, where Backspace and Del work like they do in NotePad.
I also have problems with using vim in MinGW, specifically having to do with mouse wheel scrolling. But the problem you describe sounds like vi compatibility.
Have you tried the following settings in vimrc?
set nocompatible
set backspace=2
The thing is, backspace is often ^H
and delete is often ^?
-- and some idiot terminals swap the two or have both provide the same character. When some terminals are really wrong, a keypress will generate ESC~<something>
and the ESC
will put vim
into command mode, then the ~
will swap the case of characters, and so on.
You've also got the terminfo
or termcap
databases of terminal capabilities to contend with -- if your TERM
environment variable does not match the running terminal exactly, the wrong capabilities will be selected and the application will generate the wrong escape sequences to properly control the terminal.
Of course, running on Windows further complicates everything because terminals aren't very native to the platform -- CMD.EXE
does its own thing, MSYS
does another, and vim
is probably expected bog-standard CMD.EXE
just because it is quite common.
All these are reasons why I'd recommend using gvim
; it starts a GUI window that behaves almost exactly like the text-mode vim
, but it is much more predictable in its behavior and you can configure it entirely within gvim
-- fixing vim
's behavior might actually mean changing the MSYS
configuration, which may break other programs. I dislike the way gvim
starts a "new context" rather than just editing in the environment I'm already using but gvim
feels way less awkward under Windows.
Your vim is behaving correctly - just in a mode where it detected a low-capability terminal, and doesn't want to touch the screen too much (the S
issue - $
marks the end of the region that will be deleted, but it waits till you're done inserting so it only needs to repaint the rest of the line once). Bad terminal emulation can also send rubbish when you press certain keys.
gvim, that @sarnold suggested, is just a build of vim which works in a window, not another editor. It is still full vim, and there is still the challenge. If you're stuck on a Windows box, this is a much better choice than a terminal vim, since I am not aware of a single terminal I liked working in (and I'm including Cygwin).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With