Problem every linux newbie hitting 'v' in less (the program) on typical Red Hat or similar distro where vi is default editor: vi starts up, newbie panics, hits Ctrl-C, Ctrl-C and Ctrl-C... Esc... Ctrl-X... Meta-X... Meta-Ctrl-X... God damn! and hits reset. And forcedly fsck's root.

No, don't laugh. Things like that happen.

And the answer is... :q[enter] !!! That's right.

What kind of sick and twisted mind hides exit button like that...

P.S. On some systems it may be necessary to hit 'ESC' prior to :v.

More on exiting vi:

  • :wq [Return] saves and exits.
  • :q [Return] exits, but only if there is nothing to save.
  • :q! [Return] exits no matter what.
  • ZZ (note that this is not a command line command, and you don't need to press [Return] or anything) also saves and exits! This information appears to fall under the category of cheat codes for vi.

I'm grateful to whoever taught me "ZZ"; I've no idea who you are, or when it was!

A note on ZZ: On most keyboards, it is easy to depress Ctrl instead of Shift. When you're just ready to use ZZ to save and quit, you can sometimes hit Ctrl-Z by mistake.

Under UNIX-like operating systems, this suspends the active process and returns the user to the shell. To us newbies it looks like vi has closed without saving, but ideally, your file can (and should) be recovered before the session is closed.

First, type


Look through the list (it should hopefully be very very small). One of the processes should have the word vi in the last column. The number used to refer to this process is shown in square brackets at the start of the column. For example:

1  + Stopped (user)       vi

In the above example, vi is process 1. Therefore, to retrieve it (along with the needed file) we use

fg 1

Replace 1 with the appropriate number. This should bring vi to the foreground and get it running nicely once more.

I don't know, I'm just a newbie.

Log in or registerto write something here or to contact authors.