Source: Dev.to
Introduction
When working on Linux or connecting to a remote server, you often need to open and edit files directly in the terminal. This includes tasks like updating configuration files, fixing environment variables, editing server settings, or quickly changing code. Linux provides two main terminal‑based text editors: nano (easy) and vim (powerful). This cheat sheet explains both in a beginner‑friendly way.
Nano Cheat Sheet
Opening a file
nano filename.txt
Key Bindings
| Action | Keys | Explanation |
|---|
| Save file | CTRL + O | Writes your changes |
| Exit nano | CTRL + X | Asks to save if needed |
| Cut line | CTRL + K | Removes whole line |
| Paste line | CTRL + U | Pastes last cut |
| Search | CTRL + W | Find words |
| Go to line | CTRL + _ | Navigate fast |
| Undo | ALT + U | Undo changes |
| Redo | ALT + E | Redo undone changes |
When to use Nano
- Simple tasks
- Editing configs
- Avoiding complex shortcuts
Vim Cheat Sheet
Opening a file
vim filename.txt
Modes
| Mode | Purpose |
|---|
| Normal | Move around & issue commands |
| Insert | Type text normally |
| Visual | Select text |
Basic Insert Mode Keys
| Action | Key |
|---|
| Enter insert mode | i |
| Insert at end of line | A |
| New line below | o |
| Back to normal mode | ESC |
Common Commands
| Action | Command |
|---|
| Save | :w |
| Quit | :q |
| Save & quit | :wq or ZZ |
| Quit without saving | :q! |
Navigation
| Action | Key |
|---|
| Move left/down/up/right | h j k l |
| Start of line | 0 |
| End of line | $ |
| Top of file | gg |
| Bottom of file | G |
Editing
| Action | Command |
|---|
| Delete character | x |
| Delete line | dd |
| Copy line | yy |
| Paste | p |
| Undo | u |
| Redo | CTRL + r |
Searching
| Action | Command |
|---|
| Search | /word |
| Next match | n |
| Previous match | N |
When to use Vim
- Remote servers where nano isn’t installed
- Advanced editing
- Speed and power
Conclusion
Enjoy editing confidently on Linux and servers!