Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Linux » Mastering Vim in Linux: How to Create, Edit, Save, and Quit Files
  • VLC Media Player pcgh b2article artwork
    How to Set Quicktime or VLC as a default player on macOS Mac
  • Featured image dataTransfer.
    How to transfer data from an old PC to a new PC Windows
  • Object Firt OOTBI offline and online cluster update
    Offline and Online Update for Object First Out-of-the-Box Cluster Windows Server
  • How to Manage Azure Virtual Machines with Windows Admin Center and Serial Console​
    Manage Azure Virtual Machine with Windows Admin Center and Serial Console AWS/Azure/OpenShift
  • Trellix BitLocker and fileVault Recovery
    Selfservice Recovery: Trellix BitLocker and fileVault Recovery Security | Vulnerability Scans and Assessment
  • fix this PC cannot run on Windows
    How to Fix “This PC Can’t Run Windows 11” on Hyper Windows
  • UpdateOfficeOnlineServer 1
    Perform Office Online Server Update via Windows Updates Windows Server
  • trrdf
    Remote Desktop cannot find the computer this in the specified network: Verify the computer name and domain that you are trying to connect Windows Server

Mastering Vim in Linux: How to Create, Edit, Save, and Quit Files

Posted on 05/10/202105/07/2025 Imoh Etuk By Imoh Etuk No Comments on Mastering Vim in Linux: How to Create, Edit, Save, and Quit Files
How-to-create-edit-save-exit-file
Create-edit-save-quit-Vim editor

Vi/Vim is a very powerful editor that has many commands, too many to explain in a tutor such as this. This tutorial aims to take you through how to create, edit and save files in Linux via Vi/Vim editor. In addition, Vim is a screen editor for Linux, Unix, and other Unix-like operating systems. Please see how to setup SELinux on a Linux server, how to Fix Windows defender blocked incoming connection on Windows and a brief introduction to Linux, and how to create disk partition in Ubuntu Linux.

Vim stands for Visual instrument Improved. It is a widely-used default text editor for Unix-based systems and is shipped with virtually all versions of Unix. Furthermore, it exclusively uses the keyboard and provides a very efficient interface for editing programs and scripts.

Kindly refer to these related guides: How to install and remove Microsoft Edge Browser on Linux, and how to install and configure BigBlueButton on Ubuntu Linux 16.04 LTS Xenial Xerus.

What you need to know about Vim Editor

Vi Improved (Vim) is somewhat difficult to learn, but most users are happy and ready to go through the learning curve to be more efficient in their jobs. When compared to the general-purpose word processor program, Vim is best for a more specific profile of usage and users i.e. programmers of Linux-based systems.

Vim is the text editor of choice for many users that spend a lot of time on the command line. Unlike other editors, Vim has several modes of operation, which can be a little intimidating for new users.

Vim or its predecessor Vi (Visual Instrument) comes preinstalled on all Linux distributions. Knowing the basics of Vim will help you when you encounter a situation where your favorite editor is not available.

Although, Vim could be intimidating for beginners because unlike the widely-adopted and most used word processor such as Microsoft Word, it doesn’t offer any form of formatting of “What You See Is What Get (WYSIWYG)” but it’s necessary you know how to use it mostly those intending to start a career in Pentesting or Ethical Hacking.

Vim Modes

There are several modes in Vim editor. When you launch the Vim editor, you’re in normal mode. In this mode, you can use vim commands and navigate through the file.

To type a text, you need to enter the insert mode by pressing the i key. This mode allows you to insert and delete characters in the same way you do in a regular text editor. To go back to the normal mode from any other mode, just press the Esc key.

Please, see “Azure Virtual Networks: Preparing Azure and On-Premises Virtual Networks with Azure CLI Commands“, and “Read-only Files: Saving Files in VIM Editor on Linux/Unix-like OS“.

VI VS VIM

Vi and Vim are both text editors available in Linux-based/Unix-like operating system. The text editor, with its numerous implementations, is by far the most distributed and widely used text editor. This section briefly explains the differences between the Vi and Vim editors in detail.

Vi is the universal text editor of Linux. If you know how to use the Vi text editor, you can edit any text file on any mode and version of Linux. Vim is simply an improved version of Vi, but unlike Vi, Vim is not universal. Depending on your Linux distro, it may or may not be installed by default.

Vim, which stands for Vi IMproved, has all the features of Vi with some excellent additions that aid in editing source code by programmers. There’s also a comprehensive help system and lots of customization options available. The diagram below gives a clearer picture of the differences and what both Vi and Vim shares in common.

Vi-vs.-Vim-1
VI VS VIM

In this guide you will learn how to do the following:

  • create a file
  • edit it in insert mode and
  • save it and quit the Vim editor

Requirements to create, edit and save file in Vim Editor

  • A system running Linux
  • A user account with sudo or root privileges
  • Access to a terminal window / command line (Activities > Search > Terminal). To use Vim editor in a terminal running on a Windows OS, run vimtutor and press the Enter key. For the purpose of this guide, we are going to use a terminal from Ubuntu Linux OS.

To get started with Linux and Ubuntu Linux Distribution.

Pease refer to the following related guides:  how to install and configure Ubuntu Linux on VirtualBox,  how to create and deliver a report on System Utilization on a Linux based OS, how to install, remove, and upgrade packages in Ubuntu Linux.

Now let’s get started by launching the terminal from Ubuntu.

Creating a File in Vim Editor

I’m going to create a simple file with a html extension. To do so and get vim editor launched run vim filename (not filename as used here indicate the name of the file you want to edit) followed by the enter key in your terminal window. See my screenshot below for clarification.

Launch-vim-editor
Creating a file in Vim Editor

The screenshot above shows that my file name is contactform.html. You create any type of file, it must not be an html file.

Once you press enter on your keyboard, the first screen that will show up is the normal mode screen.

By default, Vim starts in “normal” mode. Meanwhile, normal mode can be accessed from other modes by pressing Esc or <C-[>. In Normal mode key presses do not work as one would expect.

That is, they don’t insert text into the document until you press letter i on your keyboard. Hence, see my screenshot below for your information.

VIM-Normal-Mode
Vim Normal Mode

Editing a file in Vim Editor

Now let’s enter into the insert mode by pressing i on our keyboard and start write our text file right away. Refer to the below screenshot for your reference.

Insert-mode
Vim Insert Mode

Vim editor is very powerful and comes with some intuitive features that give users the best experience they need. Certainly one of the key selling points of Vim over its precursor, Vi editor is its syntax highlighting.

Vim can be programmed to highlight portions of the buffer in different colors or styles, based on the type of file being edited. So, this improvement over Vi comes in handy for programmers using Vim to write/edit code. Just as shown in the html file we just created.

Please, see How to Exit Linux Vim or Vi Editor, How to install Amazon RDS using Terraform, and Shell Scripting: How to Automate a Process in Linux.

Save a file and Quit Vim Editor

Now let’s get back to our editor to save and quit Vim editor;

To save and quite the Vim editor, run :wq! or :wq (write and quit) in normal mode and press the Enter key. You must press the Esc key to get back into normal mode.

Note, running only :q! without running the :wq! will quit the editor without saving your file.

Saving-file-in-VIm
Saving a file in Vim Editor

Another command to save a file and quit Vim is :x. The difference between these two commands is that :x writes the buffer to the file only if there are unsaved changes, whereas :wq! or :wq always writes the buffer to file and updates the file modification time.

To open the file you just created in case you wish to make changes to it, simply run vim filename and hit the enter key. That’s all!

You now have a grasp of how to create, edit, save and quit file in Vim Editor.

I hope you found this article useful on how to create, edit and save files in Linux via Vim Editor. Please feel free to leave a comment below.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:Terminal, Ubuntu

Post navigation

Previous Post: How to install and uninstall Docker Desktop on Windows 10 and Windows Server
Next Post: There has been a runner system failure: failed to start the process exec “pwsh”

Related Posts

  • maxresdefault
    Linux Directory Hierarchy Linux
  • linux tux minimalism 4k 42 2560x1700 1 1
    Warning useradd: the home directory already exists. Not copying any file from skel director into it Linux
  • MM
    How to install Mattermost on Ubuntu and Debian Linux
  • linux windows 10
    Windows Subsystem for Linux: How to install WSL on Windows 10 Linux
  • 517443 637286201540125528 16x9 1
    User account and process management in Linux Linux
  • Screenshot 2020 05 14 at 19.28.50
    How to install and configure Rancid Linux

More Related Articles

maxresdefault Linux Directory Hierarchy Linux
linux tux minimalism 4k 42 2560x1700 1 1 Warning useradd: the home directory already exists. Not copying any file from skel director into it Linux
MM How to install Mattermost on Ubuntu and Debian Linux
linux windows 10 Windows Subsystem for Linux: How to install WSL on Windows 10 Linux
517443 637286201540125528 16x9 1 User account and process management in Linux Linux
Screenshot 2020 05 14 at 19.28.50 How to install and configure Rancid Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a
 
  • VLC Media Player pcgh b2article artwork
    How to Set Quicktime or VLC as a default player on macOS Mac
  • Featured image dataTransfer.
    How to transfer data from an old PC to a new PC Windows
  • Object Firt OOTBI offline and online cluster update
    Offline and Online Update for Object First Out-of-the-Box Cluster Windows Server
  • How to Manage Azure Virtual Machines with Windows Admin Center and Serial Console​
    Manage Azure Virtual Machine with Windows Admin Center and Serial Console AWS/Azure/OpenShift
  • Trellix BitLocker and fileVault Recovery
    Selfservice Recovery: Trellix BitLocker and fileVault Recovery Security | Vulnerability Scans and Assessment
  • fix this PC cannot run on Windows
    How to Fix “This PC Can’t Run Windows 11” on Hyper Windows
  • UpdateOfficeOnlineServer 1
    Perform Office Online Server Update via Windows Updates Windows Server
  • trrdf
    Remote Desktop cannot find the computer this in the specified network: Verify the computer name and domain that you are trying to connect Windows Server

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,841 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.