KyleC
KyleC

Reputation: 159

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

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:

ESC-

ESC ESC-

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.

Upvotes: 5

Views: 14368

Answers (1)

Ricky Nelson
Ricky Nelson

Reputation: 876

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.

Upvotes: 1

Related Questions