Most EC2 Ubuntu instances ship with vi (a minimal version called vim-tiny), but not the full Vim editor. If you need syntax highlighting, split windows, or plugin support, you’ll want to install the full version. This guide covers how to install Vim on EC2 Ubuntu 22.04 and 24.04.
Prerequisites
- An EC2 instance running Ubuntu 22.04 or 24.04 — follow How to Deploy EC2 Ubuntu 22.04 LTS on AWS if you need one
- SSH access to the instance — see How to Setup Passwordless SSH Login on EC2 Ubuntu 22.04 for key-based access
Connect to Your EC2 Instance
SSH into your instance:
ssh -i /path/to/your-key.pem ubuntu@203.0.113.10
Replace the key path and IP address with your own.
Install Vim on EC2 Ubuntu
1. Update Packages and Install Vim
sudo apt update && sudo apt install vim -y
This installs vim-runtime, which includes syntax highlighting, file type detection, and the full command set that vim-tiny lacks.
2. Verify the Installation
vim --version | head -1
You should see something like VIM - Vi IMproved 9.1 with the patch number.
Vim Variants: Which One to Install
Ubuntu offers different Vim packages depending on what you need:
| Package | Use Case |
|---|---|
vim |
Standard terminal Vim. Good for most server work. |
vim-nox |
Terminal Vim with scripting support (Python, Lua, Ruby). Use this if you run Vim plugins that need scripting languages. |
vim-gtk3 |
GUI version (gVim) with clipboard support. Only useful if you have a desktop environment. |
For EC2 servers, vim or vim-nox is the right choice. Install vim-nox if you plan to use plugins:
sudo apt install vim-nox -y
Essential Vim Commands
If you’re new to Vim, here are the commands you’ll use most often on a server:
| Action | Command |
|---|---|
| Open a file | vim /etc/nginx/nginx.conf |
| Enter insert mode (start typing) | i |
| Exit insert mode | Esc |
| Save | :w |
| Save and quit | :wq |
| Quit without saving | :q! |
| Search for text | /search-term |
| Go to a line number | :42 (goes to line 42) |
Vim also has a built-in tutorial. Run vimtutor in your terminal to go through it interactively.
Conclusion
You now have the full Vim editor installed on your EC2 Ubuntu instance. For editing config files and quick server-side changes, it’s the fastest option available without leaving the terminal. If you prefer editing remotely from your desktop, you can also connect VS Code to your remote server instead.


