How to exit vi/vim?

in #programming7 years ago (edited)

You have to press ESC at first - Vim enters command mode. And then type:

:q! to quit without saving (think: quit)
:wq to write and quit (write and quit)

followed by ENTER key.

This was the most searched question on stack overflow.
Source: https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/