The Vi/Vim text editor is a powerful, lightweight, and widely-used command-line tool in the Linux world. Whether you’re editing config files or writing code, knowing how to use Vim on Ubuntu server can dramatically improve your efficiency as a system user or developer.

Installing Vim on Ubuntu

Vim often comes pre-installed on Ubuntu. To ensure you have it or to install it manually:

sudo apt update
sudo apt install vim

You can now launch it by typing vim in your terminal.

Starting Vim

To open a file (or create a new one):

vim filename.txt

This launches Vim in normal mode, which is the default mode used for navigation and commands.

Understanding Vim Modes

Vim has three main modes:

  • Normal mode (for navigating and running commands)

  • Insert mode (for editing text)

  • Command-line mode (for saving, quitting, etc.)

Switching modes:

  • Press i to enter Insert mode.

  • Press Esc to return to Normal mode.

  • Type : to enter Command-line mode from Normal mode.

🌐 Tips for Productivity

  • Use syntax highlighting: :syntax on

  • Enable line numbers: :set number

  • Customize Vim using the ~/.vimrc file

  • Explore visual mode with v for selecting blocks of text