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.
Vim often comes pre-installed on Ubuntu. To ensure you have it or to install it manually:
You can now launch it by typing vim
in your terminal.
To open a file (or create a new one):
This launches Vim in normal mode, which is the default mode used for navigation and commands.
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.
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