Objective

Edit files confidently in both nano and vim, understand vim's modal editing system, and perform basic file operations from the command line.

Tools & Technologies

  • nano
  • vi
  • vim
  • vimtutor

Key Commands

nano filename
vim filename
vi filename
vimtutor

Architecture Overview

stateDiagram-v2 [*] --> Normal: vim file Normal --> Insert: i / a / o Normal --> Visual: v / V / Ctrl+v Normal --> Command: : Insert --> Normal: Esc Visual --> Normal: Esc Command --> Normal: Enter / Esc Command --> Saved: :w Command --> Quit: :q Command --> SaveQuit: :wq Saved --> Normal: continues Quit --> [*]: exits

Step-by-Step Process

01
nano — Quick Edits

nano is beginner-friendly with on-screen shortcuts. The ^ symbol means Ctrl.

nano newfile.txt
# Type your content
# Ctrl+O  → save (WriteOut)
# Enter   → confirm filename
# Ctrl+X  → exit
# Ctrl+W  → search
# Ctrl+K  → cut line
# Ctrl+U  → paste
02
vim — Normal Mode

vim starts in Normal mode. Every key is a command, not text input. Learn to move before you edit.

vim file.txt
# Movement (Normal mode):
h j k l   # left down up right
w / b     # next/prev word
0 / $     # start/end of line
gg / G    # top/bottom of file
/pattern  # search forward
n / N     # next/prev match
03
vim — Insert & Save

Enter Insert mode to type text, then return to Normal mode to save or quit.

i        # insert before cursor
a        # insert after cursor
o        # new line below
Esc      # back to Normal
:w       # save
:q       # quit
:wq      # save and quit
:q!      # quit without saving
:set number  # show line numbers
04
vim — Editing Commands

Normal mode editing commands let you delete, copy, and paste without leaving the keyboard.

dd       # delete current line
yy       # yank (copy) line
p        # paste below
u        # undo
Ctrl+r   # redo
cw       # change word
dw       # delete word
:%s/old/new/g  # global replace

Challenges & Solutions

  • Pressing i repeatedly keeps inserting i characters — check mode indicator
  • vim exits with :q! when stuck — always works

Key Takeaways

  • Run vimtutor for 30 minutes — covers all basics interactively
  • vim is available on virtually every Unix system — worth learning well