Vi Exit

Problem

Exiting a file in vi.



Solution

There are quite a few ways to exit a file in vi. Here are some of my favorites.



Example


The standard: :wq

Force, in the case of read-only: :wq!

Abort updates: :q!

Reset the file without writing: :e!

Quick save and exit: 😡

Lazy one, without using a colon: ZZ

Going to another file: n filename

Go back to the first file, when you'v edited with wildcard or list of files: :rew



Reference

[tags]vi, Unix Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *