VI editor "ESC" key and "Ctrl + [" do not work correctly

11,895

It is possible that there is something in your ~/.vimrc file that is causing problems. You might try moving your .vimrc file to a temporary one, then start vim basically without a configuration and see if the problem persists. If it does then put the file back and start commenting things out until you find it.

It is also possible that your terminal is passing through weird keystrokes or something.

Share:
11,895
KyleC
Author by

KyleC

I am an aspiring software developer.

Updated on June 16, 2022

Comments

  • KyleC
    KyleC almost 2 years

    I am a complete beginner with VI editor.

    I had a chance of using the VI editor by typing git commit instead of git commit -m "my comment" when commenting my commit to my git repository.

    I learned that I would go into "edit" mode by pressing i in the VI command line. And I also learned that I go back to the command mode by pressing either ESC key or Ctrl + [ key combination. However, neither keys get me out of the "edit" mode.

    What happens is that pressing either keys do the same thing, something that seems like accumulating ESC key. Each time I press either key, I see something like below in the bottom line of the screen:

    • Pressed once:

    ESC-

    • Pressed twice:

    ESC ESC-

    • Pressed three times:

    ESC ESC ESC

    Since I know that the command to save and exit is :wq, when I press ESC one time and followed by :, the command line immediately turns into to Eval:. It seems like ESC + : is the key combination for such command.

    This seems weird. What would be the problem and how could I fix it?

    Thanks in advance for your help.

    my screen


    Edit

    I found the below codes from .gitconfig file in my root directory. Is this causing the problem?

    [core]
            autocrlf = input
            safecrlf = true
            editor = emacs
    

    SOLVED! My problem was due to the [core] editor part of the global settings of .gitconfig. Once I changed it to editor = vi I was able to exit out using VI's shortcuts. Thanks everybody for helping me out.

  • KyleC
    KyleC almost 9 years
    Hello. [core] editor = emacs I found the above from .gifconfig file in my root directory. I remember following someone's settings in a tutorial. Is this a problem?
  • Ricky Nelson
    Ricky Nelson almost 9 years
    It could be if you are wanting to use vim, change emacs to vim and see if that helps.
  • KyleC
    KyleC almost 9 years
    It was the problem with my settings in the global .gitconfig Thanks for your input!