Software & AppsOperating SystemLinux

How To Install and Use Vim/Vi for Programming in Linux

Ubuntu 15

Vim, also known as Vi Improved, is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems. In this article, we will guide you through the process of installing and using Vim/Vi for programming on a Linux system.

Installing Vim/Vi

Before we start, open your terminal by pressing Ctrl + Alt + t.

Updating the Package List

The first step is to update your package list to ensure that you have the latest version of Vim available for installation. Run the following command:

sudo apt-get update

The sudo command is used to run operations that require root or administrative access. apt-get is the package handling utility in Ubuntu. update is the command to resynchronize the package index files from their sources.

Installing Vim

After updating the package list, you can install Vim by running:

sudo apt-get install vim

The install command is used to install new packages. vim is the package name of the Vim editor.

Once the installation is complete, you can verify the installation by checking the version of Vim installed. Run the following command:

vim --version

Getting Started with Vim

To start a new project or file with Vim, use the command vim followed by the name of the file you want to create or edit. For example:

vim new_project.c

This command will open a new or existing file named new_project.c in Vim.

Basic Vim Commands

Once you’ve opened a file in Vim, you can start editing. Here are some basic commands to get you started:

  • i – Switch to insert mode, allowing you to insert text.
  • :w – Save your file.
  • :q – Quit Vim.
  • :wq – Save your file and quit Vim.
  • dd – Delete the current line.
  • u – Undo the last operation.
  • Ctrl + r – Redo the last undo.

Learning More About Vim

Vim has a steep learning curve, but it’s worth the effort due to its efficiency and powerful features. To learn more about Vim and its commands, you can refer to its manual by running:

man vim

The man command is used to display the user manual of any command that we can run on the terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUE, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS and SEE ALSO.

If you prefer a more interactive learning experience, you can try running vimtutor from the command line. This will provide a 30-minute tutorial that teaches the most basic Vim functionality hands-on.


Vim is a powerful text editor that can greatly enhance your programming efficiency once you get used to it. It may seem intimidating at first, but with practice, you’ll find it an indispensable tool in your programming toolkit.

For additional help, you can refer to various cheat sheets available online, such as Vim Cheat Sheet and Vim Commands Cheat Sheet. If you prefer a more interactive and gamified approach to learning Vim, you can try out Vim Adventures. It’s a fun game that teaches you the basic functionality of Vim.

Remember, practice is key when learning Vim. It may feel frustrating at first, but with time and practice, you will become more comfortable and efficient with it. Happy coding!

Can I use Vim/Vi on Windows or macOS?

Yes, Vim/Vi is available for Windows and macOS. For Windows, you can download the installer from the official Vim website ( or use a package manager like Chocolatey ( For macOS, you can use Homebrew ( to install Vim by running brew install vim in the terminal.

How can I customize Vim/Vi to suit my preferences?

Vim/Vi is highly configurable. You can customize it by creating a .vimrc file in your home directory. This file allows you to set various options and define key mappings. You can find numerous resources and examples online to help you customize Vim/Vi to your liking.

Can I use Vim/Vi as my default text editor?

Yes, you can set Vim/Vi as your default text editor by modifying your system’s configuration. In Linux, you can use the update-alternatives command to set Vim/Vi as the default editor. In Windows, you can associate specific file types with Vim/Vi by changing the default programs in the Control Panel. In macOS, you can set Vim/Vi as the default editor using the open command in the terminal.

Is it possible to use Vim/Vi for programming languages other than C?

Absolutely! Vim/Vi supports a wide range of programming languages, including but not limited to C, C++, Java, Python, Ruby, JavaScript, HTML, CSS, and many more. It provides syntax highlighting, auto-indentation, and other features specific to each language. You can also install additional plugins and extensions to enhance the programming experience for specific languages.

Can I use Vim/Vi to edit remote files on a server?

Yes, Vim/Vi has built-in support for editing remote files using protocols like SSH. You can use the vim command with the appropriate remote file path, such as vim username@hostname:/path/to/file. Vim/Vi will open the file for editing, and you can save and quit as usual. This feature is particularly useful when working on remote servers or editing files on cloud-based development environments.

Are there any alternatives to Vim/Vi for programming in Linux?

Yes, there are several alternatives to Vim/Vi for programming in Linux. Some popular alternatives include Emacs, Nano, Sublime Text, Atom, and Visual Studio Code. Each editor has its own features and advantages, so you can choose the one that best suits your preferences and workflow. It’s always good to explore different editors and find the one that works best for you.

Leave a Comment

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