{"id":3186,"date":"2025-02-19T16:33:31","date_gmt":"2025-02-19T16:33:31","guid":{"rendered":"https:\/\/foghosting.com\/how-to-exit-vim-vi-in-linux-3-commands\/"},"modified":"2025-02-19T16:33:31","modified_gmt":"2025-02-19T16:33:31","slug":"how-to-exit-vim-vi-in-linux-3-commands","status":"publish","type":"post","link":"https:\/\/foghosting.com\/blog\/how-to-exit-vim-vi-in-linux-3-commands\/","title":{"rendered":"How to Exit Vim\/ Vi in Linux {3 Commands}"},"content":{"rendered":"<div id=\"content\">\n<div role=\"main\">\n<div>\n<figure><\/figure>\n<\/div>\n<div>\n<h2><span id=\"Introduction\">Introduction<\/span><\/h2>\n<p>Whether you want to write codes, take notes, or simply edit a piece of text, a text editor is what you need. Vim, or Vi (basically the improved version of Vim), is one such text editor for you. This editor is used in the Linux terminal, which is a perfect platform to establish interaction with your computer system. While you can work on a Linux terminal without a text editor, it is a great tool to create and edit text-based files.<\/p>\n<p>This comprehensive piece of writing is all about the powerful text editor Vim and the ways to <strong>exit Vim<\/strong>. We will focus on different ways to <strong>quit Vi<\/strong>.<\/p>\n<h2><span id=\"Exit_Vim_in_Terminal\">Exit Vim in Terminal<\/span><\/h2>\n<p>The terminal can be launched through the applications menu in almost all Linux distributions. You can also press Ctrl+Alt+T to launch it. Once you have opened the terminal, simply type \u201cvim\u201d and press the enter key to start working with the text editor. You can even type the name of a specific file through \u201cvim filename\u201d to start working on the chosen file. On the other hand, you can create a new file through the \u201cvim newfile.txt\u201d command.\u00a0<\/p>\n<p>Now that you have learned to start and edit a file through this text editor, it\u2019s time to know how to <strong>exit the vi editor<\/strong>. Once you have finished editing and viewing your file, you need to<strong> quit the Vi editor<\/strong> and return to the terminal window. We can perform the function in two ways: one is through shortcut keys, and the other is by using commands. Let\u2019s check both ways in the below sections.<\/p>\n<p>Also Read: How to Clear Terminal in Linux?<\/p>\n<h2><span id=\"How_to_exit_Vi_through_shortcut_keys_and_commands\">How to exit Vi through shortcut keys and commands?<\/span><\/h2>\n<p>Shortcut keys cannot be used to exit certain modes like \u201cinsert.\u201d However, such a combination of keys can be easily used to <strong>quit Vi<\/strong>. Take a look at the following keys:<\/p>\n<ul>\n<li>ZZ (Shift + Z twice): In normal mode, this key combination saves any due changes and lets the user exit the text editor without any hassle.<\/li>\n<li>:wq + Enter: Typing \u201c:wq\u201d in Command-Line mode helps retain all the changes and <strong>quit vi<\/strong>.<\/li>\n<li>\ud83d\ude21 + Enter A very similar command to \u201c:wq,\u201d it allows the user to save any modification before making the final exit.<\/li>\n<li>:q! + Enter: It is a very useful combination when the user doesn\u2019t have any need to save the changes.<\/li>\n<li>At last, the user can simply press the Esc key to <strong>exit Vim<\/strong>.<\/li>\n<\/ul>\n<figure><\/figure>\n<h3><span id=\"Final_Words\"><strong>Final Words<\/strong><\/span><\/h3>\n<p>When working in the terminal, <strong>quiting Vim<\/strong> might seem like a daunting task, especially for beginners. However, there are several ways to exit Vim efficiently and effectively. Vim offers various shortcut keys for quick exits, such as \u201cZZ\u201d to save changes and exit, and the Esc key to exit Vim without saving. Commands, on the other hand, provide more nuanced control over the process.\u00a0<br \/>For example, \u201c:wq\u201d saves changes before exiting, \u201c:x\u201d is similar, but only saves changes if necessary, while \u201c:q!\u201d <strong>exits Vim<\/strong> without saving any changes. These techniques not only make navigating Vim more efficient but also help you to avoid losing important data. With practice, you\u2019ll find exiting Vim in the terminal to be a simple and seamless process that will save you time and frustration.<\/p>\n<\/p><\/div>\n<div>\n<div>\n<h3>Arpit Saini<\/h3>\n<p>\n\t\t\t\t\tHe is the Director of Cloud Operations at  and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.\t\t\t\t<\/p>\n<\/p><\/div><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Whether you want to write codes, take notes, or simply edit a piece of text, a text editor is what you need. Vim, or Vi (basically the improved version of Vim), is one such text editor for you. This editor is used in the Linux terminal, which is a perfect platform to establish interaction<\/p>\n","protected":false},"author":3,"featured_media":3076,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[17],"tags":[],"class_list":["post-3186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dedicated-servers"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/comments?post=3186"}],"version-history":[{"count":0,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3186\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media\/3076"}],"wp:attachment":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media?parent=3186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/categories?post=3186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/tags?post=3186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}