Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am unable to edit text files using vim in cygwin.

I have to press i many times to insert text. Sometimes it works and sometimes doesn't. Whenever I move cursor up down I have to press I many times.

What could be the problem? Does backspace work in cygwin?

share|improve this question
    
Are you running inside the native Windows console, in another terminal emulator running as a native application, in a terminal emulator running under X? What version of Windows? Does the delay between pressing ESC and pressing i matter? –  Gilles Apr 20 '11 at 19:46

6 Answers 6

up vote 20 down vote accepted

Cygwin vim ships with vim's default configuration, which leaves vim in vi compatibility mode where it tries to emulate the original vi as closely as possible. Among other limitations, arrow keys do not work in that mode, and backspace just moves the cursor left rather than erasing a character.

Creating an empty ~/.vimrc is sufficient to disable vi compatibility mode:

touch ~/.vimrc

Having said that, i to enter insert mode should work anyway. You'll need to provide more details on where and how you're running vim. Also, are you actually running the vim that comes with Cygwin, or the native Windows version of vim?

share|improve this answer
    
don't bother reading any of the other answers - this is all you need –  anger May 8 '13 at 10:22
    
Would have been nice if you would have said how to set no compatibility off. –  gideon May 20 '13 at 12:02

No the commands are exactly the same. It sounds like you have an input problem. Either your keyboard is messed up or your terminal is on the fritz or something.

share|improve this answer

Are you sure you're not using vi instead of vim?

share|improve this answer

Depending on the characteristics of your terminal program, when you press a cursor key it sends a sequence of characters starting with the ESC key. For example, the Up Arrow key sends the three characters ESC [ A. With vim in input mode, pressing a cursor key may terminate input mode when ESC is seen, and the subsequent characters may be interpreted as vim commands. Since it exits input mode, you need to press i again to continue inserting text. Perhaps this is what's happening for you.

Check if your terminal has options that can change the emulation, such as VT-100, VT-220, or a setting that specifies what is sent when the Backspace or Del keys are pressed. Changing those settings may get the behavior you want. If you're using the native Windows command console, you probably don't get those options.

You may have to avoid using the cursor keys in input mode. Press ESC to exit input mode, then move the cursor, then i again for more input. That's how us old-timers had to do it before vim got smart enough to interpret the cursor keys in input mode.

share|improve this answer

The easiest way is copy the sample VIM rc file from, e.g /usr/share/vim/vim62/vimrc_example.vim to ~/.vimrc

See reference here

share|improve this answer

Try this way:

  • first:

    cp /usr/share/vim/vim73/vimrc_example.vim ~/.vimrc
    
  • then, add this line to your ./.bashrc file:

    alias vi="vim"
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.