At some point, whenever I use vi from the command line (windows 10/WSL) it starts up in insert mode, meaning that everything I usually do to navigate ends up adding stuff to the file, wasting time having to clean it up.
I didn't have a vimrc file, and there doesn't seem to be anything in my bash rc files to modify vi behavior. Any ideas what I may have done or any ideas how to stop this behavior? I'm using Ubuntu-20.04
FWIW, adding a .vimrc file with tab related settings didn't change it's behavior. I looked at the /etc/vimrc file, and nothing inside it seemed relevant.
I have been a long-suffering victim of this problem, but today decided to try to find a solution for it, and found this thread. Since it did not have a real good solution, and other pages/threads did not either, I looked into the problem and found a solution I thought was worth sharing.
The short answer: set your TERM variable to vt100
The default value is TERM=xterm-256color. Either change TERM from your command line, or in your .bashrc or .bash_aliases file, just add the line
export TERM=vt100
The "export" is probably implied, but does not hurt to use it.
I actually just guessed that might work and so found this solution quickly. But then I spent a lot more time investigating to see if there was a solution even better than that, or that explained why it worked, or why the problem occurred, and learned: (1) The terminal emulator that runs with debian-on-WSL1 is a Windows Console, which was specifically designed to emulate a vt100, which an xterm is based on, but is missing some capabilities and as we can see, does not fully emulate the xterm that terminfo is targeting; (2) Windows Terminal does not have the problem, it must have an improved design and does emulate an xterm more completely, so you could alternately start a Windows Terminal and run "wsl" or "debian" in a tab, and then would not have to change TERM to vt100; (3) The bad behavior results from an unintentional "2R" vim command, as the bottom status bar shows "REPLACE" not "INSERT", and the "2" must be there because text typed in gets replicated once; so the "2R" probably is part of a control string that Windows Console does not support.
After plowing through google search and trying everything I understand about configuring 'vim' and doing comparison tests, I think:
My solution: I switched to MobaXterm. It has multi-tab support, and is actually richer in features compared to Windows Terminal.
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