I'm new to vi. I started vi on my Ubuntu machine and I can't quit. I see the editor and I can write text, at the bottom line there is a label "recording".
How do I quit the vi editor?
I'm new to vi. I started vi on my Ubuntu machine and I can't quit. I see the editor and I can write text, at the bottom line there is a label "recording".
How do I quit the vi editor?
vim is a modal editor. Hit the ESC key to get into Normal (command) mode then type :q and press Enter.
To quit without saving any changes, type :q! and press Enter.
See also Getting out in Vim documentation.
I use ctrl+[ to generate the esc sequence, this keeps me from having to move my fingers from the home row (remember the esc key was in a different place when vi was invented. :wq will write all files regardeless of necessity. I suggest using ZZ (which is shift+z twice) which will only write if a change has been made in the file. Also :xa is the same as ZZ except if you have more than 1 file open in the editor instance (such as vim tabs). note: I'm not sure all this is 100% compat with all vi clones, but I know it works with vim
The quit from the vi is another way is Esc :x.
The option is used for save and quit at the same time.
As Sinan said, vim is a modal editor. If you want to know whether that works for you you should maybe invest some time and run vimtutor which is an interactive way to learn vim. (It also covers how to exit, what the modes mean and what you can do in each mode).
After modification, please press ESC and the given command :wq!.
This will forcefully write the new modification on the read-only file. Earlier it was not working because the file is read-only.