5

Newbie to vi / vim, I normally use pico but using a locked down box (for now) that only has these 2 editors.

I am having trouble getting it to save a file or even just quit. I see others having the same issue and they were told to use :x but even that doesn't work, just throws up an error message.

Is there an exit command that JUST works?

thanks

0

3 Answers 3

10

:q should work, unless the file hasn't been saved.

:q! will work.

:wq will attempt to save and quit, but won't quit if it can't save.

:wq! will attempt to save, and then quit whether or not it can save.

E: Credit to @GregoryNisbet for reminding me: if you have multiple files open, there is a series of 'all' quit commands:

:qa should quit all buffers (open files, more or less).

:qa! will quit all buffers regardless of if they have been saved.

:wqa will attempt to save and quit all buffers.

:wqa! will attempt to save all buffers, and then quit whether or not they are saved.

Sign up to request clarification or add additional context in comments.

2 Comments

:qa! will quit an unlimited number of buffers regardless of their saved-ness
Don't forget to exit edit mode by pressing escape. For the truly new, it's possible to get stuck in edit mode.
1

The solution that has worked for me is

  1. Esp Z + Z
  2. :wq!

Comments

-2

you should type :q not q.Every command in vim should start with :

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.