Terminal Text Editors: Nano and Vim

What You'll Learn

You don't always have a graphical text editor on Linux — especially on servers. This guide teaches you two terminal-based editors: Nano (beginner-friendly) and Vim (powerful, everywhere).

Nano — The Beginner's Choice

Nano is simple and shows all available shortcuts at the bottom of the screen.

Opening Nano

nano filename.txt                 # Open or create a file
sudo nano /etc/hosts              # Edit a system file with root privileges

Essential Nano Shortcuts

ActionShortcut
SaveCtrl+O then press Enter
ExitCtrl+X
Cut lineCtrl+K
PasteCtrl+U
SearchCtrl+W
Go to line numberCtrl+_

Nano will ask if you want to save changes when you try to exit. Say yes, confirm the filename, and you're done.

Vim — The Power User's Editor

Vim is pre-installed on almost every Linux system. It has a steep learning curve but is incredibly powerful once you know the basics.

Vim Has Modes

Essential Vim Commands

ActionKey
Enter Insert modei
Leave Insert modeEsc
Save and quit:wq then Enter
Quit without saving:q! then Enter
Search for text/text then Enter
Delete a linedd (in Normal mode)
Undou

The "How Do I Exit Vim?" Cheat Sheet

Press Esc                     # Make sure you're in Normal mode
Type :q!                      # Quit without saving (if you messed up)
Type :wq                      # Save and quit (if you're happy)

New to Vim? Run vimtutor for a built-in 30-minute tutorial.

Which Should You Use?

Practice Exercise

# With Nano
nano my-notes.txt
# Type some text, Ctrl+O to save, Ctrl+X to exit

# With Vim
vim my-notes.txt
# Press i to type, Esc to leave insert mode, :wq to save and quit
vimtutor                    # Run the interactive tutorial

Troubleshooting

What's Next?

You can edit files — now learn how Linux manages users and access:

Users, Groups, and Sudo →