How do I exit vi editor after saving?
The lowly and now middle-aged vi editor is still a favorite among *nix system administrators and remains an essential tool for command-line file creation and editing. Show Posted: August 20, 2019 |%t min read| by Ken Hess (Sudoer alumni, Red Hat) Image "VI vs. Emacs" by mrbill is licensed under CC BY 2.0 Gray at the temples and in need of reading glasses, the middle-aged Vi (pronounced vee-eye) editor, released in 1976, is still a system administrator's best friend. Image Download now This advanced, yet simple to use, command-line editing program shows no sign of slowing down. You can use it to edit configuration files, create a grocery list, write a letter home to ask for money, create a new script, or even edit source code. Vi is often a symbolic link to Vim (Vi Improved) or an alias to Vim, an enhanced version of Vi. [ Get the Vim cheat sheet. ] It’s easy to invoke Vi. At the command line, you type
Vi edit modesThe Vi editor has two modes: Command and Insert. When you first open a file with Vi, you are in Command mode. Command mode means you can use keyboard keys to navigate, delete, copy, paste, and do a number of other tasks—except entering text. To enter Insert mode, press [ Looking for a different text editor? Download the Emacs cheat sheet. ] In Vi's Command mode, almost every letter on the keyboard has a function. More Linux resources
To save a file, you must first be in Command mode. Press Esc to enter Command mode, and then type Note: Always make a copy of an existing file prior to editing with Vi or any editor. This is especially critical when editing system and configuration files. Vi shortcutsThe best way to learn Vi is to create a new file and try it out for yourself. Feel free to use the common keyboard shortcut list below to help you learn Vi’s extensive vocabulary. This list of shortcuts is by no means exhaustive, but they will enable you to edit files and learn Vi in a short amount of time.
[ Get more out of your text editor: 5 Vim features for power users. ] What to read nextImage Linux skills: 9 tutorials to get more from your text editor Are you getting everything you need out of your text editor? Read Enable Sysadmin's recent articles about Linux text editors to find out what you're missing. Posted: July 22, 2022 Author: Vicki Walker (Editorial Team, Red Hat) Image How to get started with the Vi editor Once you've committed Vi's keyboard shortcuts to muscle memory, watch how fast you work. Posted: January 25, 2022 Author: Seth Kenlon (Editorial Team, Red Hat) Image Top five Vim plugins for sysadmins My list of the top five Vim plugins—plus a bonus. Posted: October 16, 2020 Author: Ricardo Gerardi (Sudoer, Red Hat) Topics: Command line utilities Text editors Linux Ken HessKen has used Red Hat Linux since 1996 and has written ebooks, whitepapers, actual books, thousands of exam review questions, and hundreds of articles on open source and other topics. Ken also has 20+ years of experience as an enterprise sysadmin with Unix, Linux, Windows, and Virtualization. More about me Red Hat Summit 2022: On DemandGet the latest on Ansible, Red Hat Enterprise Linux, OpenShift, and more from our virtual event on demand. Register for free Related ContentImage Learn how Unix influenced Linux, understand Ansible lists and dictionaries, and more tips for sysadmin Check out Enable Sysadmin's top 10 articles from November 2022. Posted: December 5, 2022 Author: Vicki Walker (Editorial Team, Red Hat) Image 6 ways to get information about your CPU on Linux Getting insight into what CPU you're running is a useful trick to know. Posted: December 5, 2022 Author: Seth Kenlon (Editorial Team, Red Hat) Image How to use the lsof command to troubleshoot Linux The Linux lsof command does more than list open files; you can also use it to diagnose potential bottlenecks. |