Peeter Joot's (OLD) Blog.

Math, physics, perl, and programming obscurity.

the most basic vi trick. exiting the damn thing.

Posted by peeterjoot on July 23, 2009

Although I now rate myself as a guru level vi user, there was a time that I totally hated the vi editor. Back in university if you tried to run the newsreader (trn in those days) if you hadn’t configured for a “usable” editor, vi would be invoked and then you were stuck.

So, … if you don’t want to use vi, and end up using it by mistake, how to exit? The following is promising looking, but doesn’t actually work:

~
~
~
:!@$!@^! shit, how the hell do you exit this damn thing

Here’s the real way.

Step 1: If you are in edit mode (you have on purpose or accidentally hit the ‘i’ character) you’ll need to hit the Escape character on your keyboard. If you don’t know if you are in edit mode or not you can hit the Esc character. You can hit it five times if you like, once you are out of edit mode, you’ll stay there.

Step 2: type ‘:’ (the colon character), then wq, or q, or q! or wq! Example output at the bottom of the vi screen will look something like:

~
~
~
:wq!

This last one means write and quit, and a really mean it, even if I have multiple files being edited. Plain old “:w” is just write, “:q” is quit, and “:q!” is “quit damnit, yes I really mean it”

While my vi hating days are gone, the transition from vi hating to loving requires one first baby step: being able to exit the damn editor. Eventually, if like me, you are forced to work on multi platform Unix development where the only editor you can depend on is vi, taking further steps away from vi hating may be possible.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: