How to exit from editor in linux terminal

Namaste,

I was trying to make my first commit to git by following a video tutorial. I did the following steps:
a. git init
b. git add index.html
c. git commit
d. Editor opened, I typed “i” to enter input mode
e. After entering comment pressed “esc” followed by “:wq”

It did not exit the editor. I tried a few things after that but nothing is working and I am kind of suspended in a limbo. Please help

Hi, I don’t know the solution to this problem but if you are in a hurry to upload the index.html to github you can do it from the web

Yeah, the VIM editor takes some getting used to. This might help with your immediate problem. But in the long run, it would be good to learn the basics of the editor.

Yes, of course, it is for the moment, I had a similar problem and I solved it that way but I also have to learn the correct way

Thanks Juan. I am actually just trying to learn about git and github. The index.html file has nothing worthwhile actually :smiley:

1 Like

Thanks Kevin. I actually had used a few basic commands in Vim earlier and the “esc” key to get out of the insert mode had worked the last couple of times. I am not sure what went wrong this time. Now when I press “esc” i just get “^[” printed on the screen

i to switch to insert mode, type some stuff

<ESC> to exit back to normal mode

: to enter a command

w or write to write the file

q or quit to quit

<CR> (carriage return, ie enter key) to execute a command.


So

i, type commit message, <ESC>, then :wq<CR>


Type :vimtutor and hit enter, it will give you a tutorial

Type :help ANYTHING where ANYTHING is literally any possible vim command and it will open a help buffer (tab autocompletion I think is on by default so as soon as you type anything you can hit tab to complete but I might be wrong). Vim is very heavily documented


Edit: not sure why pressing escape is literally printing the ASCII escape sequence for escape (it sounds like something has been accidentally turned on/off, caps lock maybe? Or different keyboard?), but you can also send an escape code via <CTRL>[ (sends same character to the terminal as escape), or <CTRL>3

<ALT> + any other key should work as well (though it will run whatever the other key does, so just h, j, k or l, ie the movement keys, is probably a safe key to use)

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.