Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable 'vi compatible' mode for Vim in Cygwin on Windows 8?

Tags:

vim

cygwin

I am using Cygwin 1.7.22 (32-bit) on Windows 8 (64-bit). Within Cygwin, I am using Vim 7.3.1152, which is the default version.

Behavior that seem like bugs:

  1. When I press I to enter insert mode, it does not say -- INSERT -- in the bottom left. In fact, it doesn't say anything. It does behave correctly, though.

  2. When I delete letters using Backspace in insert mode, the letters do not disappear but the cursor does move to the left.

  3. When I use the arrow keys in insert mode, it enters the letters A, B, C, and D, rather than moving the cursor. The arrow keys work normally outside of insert mode.

How do I make Vim behave as I expect?

like image 818
SerMetAla Avatar asked Aug 07 '13 23:08

SerMetAla


People also ask

What is Vim compatible mode?

Compatible mode means compatibility to venerable old vi. When you :set compatible , all the enhancements and improvements of Vi Improved are turned off.

How to make Vim nocompatible?

Create a ~/.vimrc file with the following contents to put vim in nocompatible mode (actually the mere presence of the file is sufficient.) The behavior you are seeing is how vi used to behave. These are not bugs. In vim compatible mode tries to emulate vi as closely as possible. --insert-- is not part of vi so it not shown in compatible mode.

What version of Vim do you use with Cygwin?

I am using Cygwin 1.7.22 (32-bit) on Windows 8 (64-bit). Within Cygwin, I am using Vim 7.3.1152, which is the default version.

Why is VIM not showing--insert in compatible mode?

These are not bugs. In vim compatible mode tries to emulate vi as closely as possible. --insert-- is not part of vi so it not shown in compatible mode. I believe vi did a lazy redraw of the screen and didn't update until you exited back to normal mode.

How to enable nocompatible mode for classic VI?

A personal .vimrc can enable the compatibility to the classic vi, also the mouse control can by disabled. If you would insert with right-click then use the option set mouse-=a. NOTE: that ~/.vimrc Vim automatically enables nocompatible mode as soon as a personal initialization file is available. debian.vim sets nocompatible.


1 Answers

Create a ~/.vimrc file with the following contents to put vim in nocompatible mode (actually the mere presence of the file is sufficient.)

set nocompatible 

The behavior you are seeing is how vi used to behave. These are not bugs.

Take a look at :h nocompatible


In vim compatible mode tries to emulate vi as closely as possible.

  1. --insert-- is not part of vi so it not shown in compatible mode.
  2. I believe vi did a lazy redraw of the screen and didn't update until you exited back to normal mode. Also backspace is only usable also only works on stuff that was entered in the current insert mode. Overall its not very user friendly.
  3. The arrow keys are sent to vim as escape sequences (escape followed by a coupled of letters). Let ^[ be escape. ^[OA is up on my computer its probably something similar on yours. vim sees this as an escape (goes back to normal mode), and O (add a line above the current) and A which is the A you see entered onto your screen. This just means that vim in compatible mode does not interpret the escape characters properly. Most likely because vi did not interpret them (nor was it designed to use them).

set nocompatible fixes problems 1 and 3.

I think set backspace=indent,eol,start should fix problem 2.

like image 126
FDinoff Avatar answered Sep 28 '22 23:09

FDinoff