1. No Modes
- Unlike
vi/vim
, which has Normal mode and Insert mode,nano
is always in Insert mode, meaning you can start typing immediately. - No need to switch between modes with
ESC
ori
.
2. Command Execution
- In
vi/vim
, commands are executed using:
(e.g.,:w
,:q
,:x
). - In
nano
, all commands use the Ctrl (^
) key, e.g.,Ctrl + X
to exit,Ctrl + O
to save.
3. Text Selection and Copy/Paste
vi/vim
uses Visual mode (v
to start selecting,d
ory
to delete or copy).nano
usesCtrl + 6
to start selecting, followed byCtrl + K
(cut) orAlt + 6
(copy).
Nano vs. Vi/Vim – Command Comparison
Action | Nano | Vi/Vim |
---|---|---|
Open a file | nano filename | vi filename |
Exit | Ctrl + X | :q |
Save | Ctrl + O → Enter | :w |
Save and Exit | Ctrl + O → Enter → Ctrl + X | :wq or ZZ |
Force Exit (without saving) | Ctrl + X → N | :q! |
Move to beginning of line | Ctrl + A | 0 |
Move to end of line | Ctrl + E | $ |
Move up one line | ↑ or Ctrl + P | k |
Move down one line | ↓ or Ctrl + N | j |
Page up | Ctrl + Y | Ctrl + b |
Page down | Ctrl + V | Ctrl + f |
Move to a specific line | Ctrl + _ → line number | :line number |
Search | Ctrl + W | / |
Go to next match | Alt + W | n |
Replace | Ctrl + \\ | :s/search/replace/g |
Cut a line | Ctrl + K | dd |
Cut selected text | Ctrl + 6 (start selection) → Ctrl + K | v → d |
Copy selected text | Ctrl + 6 (start selection) → Alt + 6 | v → y |
Paste | Ctrl + U | p |
Show current line number | Ctrl + C | Ctrl + g |
Redraw screen | Ctrl + L | Ctrl + l |
Open nano help | Ctrl + G | :help |
Key Points for Vi/Vim Users Switching to Nano
- No modes, so you can type immediately.
- No need to press
i
orESC
to switch modes. - In
nano
, you can start typing immediately after opening it, and there is no need for an equivalent operation toi
- No need to press
- Use
Ctrl
instead of:
commands.Ctrl + X
(exit),Ctrl + O
(save),Ctrl + K
(cut).
- Text selection and copy/paste work differently.
Ctrl + 6
starts selection,Alt + 6
copies,Ctrl + K
cuts.
- Search and replace use different commands.
Ctrl + W
(search),Ctrl + \\
(replace).
- Nano is simpler but lacks advanced features like macros and plugins.
- For basic file editing,
nano
is quicker and easier. - For complex text manipulation,
vim
is more powerful.
- For basic file editing,
Useful Nano Options
Option | Description |
---|---|
nano -c | Show line numbers (:set number in Vim) |
nano -m | Enable mouse support (:set mouse=a ) |
nano -w | Disable line wrapping (:set nowrap ) |
nano -l | Enable syntax highlighting (syntax on ) |
Example: Open a file with line numbers
nano -c filename
Conclusion
- Nano is lightweight and simple, great for quick edits.
- Vi/Vim is more powerful for advanced text manipulation.
- If you’re used to Vim, the main challenge in Nano is adapting to
Ctrl
based commands. - For quick file edits, Nano is faster than Vim, but Vim is better for scripting and customization.
If you want nano
to feel a bit more like vi
, try using nano -c -m -w
when opening files