Saving and Quitting
Saving:
To save your changes, press : in Normal Mode, followed by w and then press Enter. Alternatively, you can use :w filename to save the file with a different name.
# In Normal Mode, ':w' saves the file.
:w
# ':w filename' saves the file with a new name.
:w newfilename.txt
Quitting:
To exit vi, type :q and press Enter. If you’ve made changes and want to save them while quitting, use :wq. If you want to quit without saving changes, use :q!.
# In Normal Mode, ':q' quits vi.
:q
# ':wq' saves changes and quits.
:wq
# ':q!' quits without saving changes.
:q!
Basic vi Commands
Text editors are essential tools for any programmer or computer enthusiast. One popular text editor that has been around for decades and is still widely used is vi (pronounced “vee-eye”). vi is a terminal-based text editor that offers powerful editing capabilities once you understand its basic commands.
In this article, we will explore the fundamental vi commands that will help you navigate, edit, and save your text files efficiently. Whether you’re a beginner or an experienced user looking to refresh your knowledge, this guide will provide you with a solid foundation in using vi.