Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exit the Vim editor?

Tags:

vim

vi

I'm stuck and cannot escape. It says:

"type :quit<Enter> to quit VIM" 

But when I type that it simply appears in the object body.

like image 447
jclancy Avatar asked Aug 06 '12 12:08

jclancy


People also ask

How do I save and exit from Vim?

Save a File and Quit You can save the current file and quit Vim anytime you want. Simply switch to the command mode and type the below command to save and quit vim. You can also use the :x command. It works similar to :wq but only writes when you've made actual changes.


Video Answer


1 Answers

Hit the Esc key to enter "Normal mode". Then you can type : to enter "Command-line mode". A colon (:) will appear at the bottom of the screen and you can type in one of the following commands. To execute a command, press the Enter key.

  • :q to quit (short for :quit)
  • :q! to quit without saving (short for :quit!)
  • :wq to write and quit
  • :wq! to write and quit even if file has only read permission (if file does not have write permission: force write)
  • :x to write and quit (similar to :wq, but only write if there are changes)
  • :exit to write and exit (same as :x)
  • :qa to quit all (short for :quitall)
  • :cq to quit without saving and make Vim return non-zero error (i.e. exit with error)

You can also exit Vim directly from "Normal mode" by typing ZZ to save and quit (same as :x) or ZQ to just quit (same as :q!). (Note that case is important here. ZZ and zz do not mean the same thing.)

Vim has extensive help - that you can access with the :help command - where you can find answers to all your questions and a tutorial for beginners.

like image 80
dirvine Avatar answered Oct 09 '22 07:10

dirvine