Are cygwin vim commands different than normal vim?

36,360

Solution 1

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?

Update

You can add below sets in ~/.vimrc to make is similar to default vim

set nocompatible
set backspace=indent,eol,start
set backup
set history=50
set ruler
set background=dark
set showcmd
set incsearch
syntax on
set hlsearch

If vim does not pick up your vimrc file, it may be looking for a .virc file instead. In this case, rename the file and the changes will be applied.

Solution 2

The easiest way is copy Cygwin VIM's sample vimrc file

cp /usr/share/vim/vim*/vimrc_example.vim /etc/vimrc

This will fix the problem for every account on your system. If, for some reason, you only want to change it for a particular user, do

cp /usr/share/vim/vim*/vimrc_example.vim ~/.vimrc

See reference here

Solution 3

I had problem with arrow keys while trying vim inside Windows 8.1 using cygwin. The issue was, printing A/B/C/D while navigating with Arrow keys in insertion mode. The solution worked for me is:

cp vimrc_example.vim ~/.vimrc

Basically, above command copying vimrc_example.vim file to /home/<user name>/.vimrc.

Solution 4

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

Solution 5

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:
36,360

Related videos on Youtube

Mirage
Author by

Mirage

Updated on September 18, 2022

Comments

  • Mirage
    Mirage over 1 year

    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?

  • Scott Marriott
    Scott Marriott almost 11 years
    Would have been nice if you would have said how to set no compatibility off.
  • JohnEye
    JohnEye about 9 years
    This should be the accepted answer because the example actually turns on syntax highlighting by default and probably a lot of other defaults people are used to.
  • 3bdalla
    3bdalla almost 9 years
    Did not work until a PC restart. But it works!
  • crobicha
    crobicha over 8 years
    Excellent answer, simple and solved all the different issues I was seeing with a fresh cygwin install, and syntax highlighting is a bonus that was unexpected
  • Yanick Girouard
    Yanick Girouard over 8 years
    That fixed it for me. I had the same issue with the insert key and arrows not working in vim. That was on Windows 10.
  • Theodore R. Smith
    Theodore R. Smith about 8 years
    This is by far the best answer!!
  • Alex
    Alex about 7 years
    Do you know where is the default home location of cygwin? I want to create .virc by GUI instead of cygwin
  • Kate J
    Kate J over 4 years
    There is certainly some package dependency needed here. I know I'm writing some years ahead, but a recent fresh Cygwin install (default package selection) does not present the referenced file.