General commands (platform-independent)
| Command | Description |
| vim filename | Opens a file in the Vim editor |
| Nano File Name | Opens a file in the Nano Editor |
| VI File Name | Opens a file in the Vi editor (often an alias for Vim) |
| vimtutor | Starts the Vim tutorial |
| vim -R filename | Opens a file in Vim in read-only mode |
| vim +line number filename | Opens a file in the Vim at a specific line |
| vimdiff file1 file2 | Compares two files side by side in Vim |
| export EDITOR=vim | Sets Vim as the default editor for the current session |
| export EDITOR=nano | Sets Nano as the default editor for the current session |
Ubuntu/Debian
Installation and removal
| Command | Description |
| sudo apt update | Updates the package lists |
| sudo apt install vim | Installs the Vim editor |
| sudo apt install nano | Install the Nano Editor |
| sudo apt remove vim | Uninstalls the Vim editor |
| sudo apt remove nano | Uninstalls Nano Editor |
| sudo apt install vim-gtk3 | Installs Vim with GTK3 support (graphic) |
| sudo apt install vim-athena | Install the Athena version of Vim |
Configuration
| Command | Description |
| sudo update-alternatives –config editor | Sets the default editor system-wide |
| sudo vim /etc/vim/vimrc | Edits the global Vim configuration file |
| sudo nano /etc/nanorc | Edits the global nano configuration file |
RHEL/CentOS
Installation and removal
| Command | Description |
| sudo yum install vim | Installs the Vim editor |
| sudo yum install nano | Install the Nano Editor |
| sudo yum remove vim | Uninstalls the Vim editor |
| sudo yum remove nano | Uninstalls Nano Editor |
| sudo yum install vim-enhanced | Installs the advanced version of Vim |
Configuration
| Command | Description |
| sudo alternatives –config editor | Sets the default editor system-wide |
| sudo vim /etc/vimrc | Edits the global Vim configuration file |
| sudo nano /etc/nanorc | Edits the global nano configuration file |
Fedora
Installation and removal
| Command | Description |
| sudo dnf install vim | Installs the Vim editor |
| sudo dnf install nano | Install the Nano Editor |
| sudo dnf remove vim | Uninstalls the Vim editor |
| sudo dnf remove nano | Uninstalls Nano Editor |
| sudo dnf install vim-X11 | Installs Vim with GUI support |
Configuration
| Command | Description |
| sudo update-alternatives –config editor | Sets the default editor system-wide |
| sudo vim /etc/vimrc | Edits the global Vim configuration file |
| sudo nano /etc/nanorc | Edits the global nano configuration file |
Important configuration files
| File | Description |
| ~/.vimrc | Custom Vim Configuration |
| /etc/vim/vimrc | Global Vim configuration file (Ubuntu/Debian) |
| /etc/vimrc | Global Vim configuration file (RHEL/CentOS/Fedora) |
| ~/.nanorc | Custom Nano Configuration |
| /etc/nanorc | Global Nano Configuration File |
Useful Vim commands (within the editor)
| Command | Description |
| :w | Saves the current file |
| :q | Quit the editor |
| :wq or 😡 | Saves the file and exits the editor |
| :q! | Quits the editor without saving |
| /suchbegriff | Searches for a term in the file |
| :set number | Enables line numbering |
| :syntax on | Enables syntax highlighting |
Useful Nano commands (inside the editor)
| Keyboard shortcut | Description |
| Ctrl + O | Saves the current file |
| Ctrl + X | Quit the editor |
| Ctrl + W | Searches for a term in the file |
| Ctrl + K | Cuts out the current line |
| Ctrl + U | Pastes the last cut line |
| Alt + A | Starts the markup (text selection) |
| Ctrl + G | Displays the help page |
Set editor as default
System-wide
- Ubuntu/Debian
sudo update-alternatives –config editor
- RHEL/CentOS
sudo alternatives –config editor
For the current user
- Add one of the following lines to ~/. rc:
export EDITOR=vim
# or
export EDITOR=nano
Tips and tricks
- Vim as a replacement for Vi
On many systems, vi is a symbolic link to vim. To make sure Vim is always used, you can set an alias:
alias vi=’vim’
This can be done in the ~/. rc to make the alias permanent. - Installing plugins for Vim
Vim supports plugins to extend functionality. A popular plugin manager is Vundle:
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Then configure the plugins in the ~/.vimrc. - Nano with syntax highlighting
By default, syntax highlighting is disabled in Nano. To enable it, remove the comment characters in /etc/nanorc or ~/.nanorc before the corresponding include lines. - Example:
include “/usr/share/nano/*.nanorc”
Troubleshooting
- Problem: vim or nano is not found.
Solution: Make sure Notepad is installed and check the path:
which vim
which nano
- Problem: Changes in the configuration file are not applied.
Solution: Make sure that the configuration file has been edited correctly and does not contain any syntax errors.

