Mikey’s Linux Field NotesAll topics

GUIDE 03 / EVERYDAY COMMANDS

Vim & editing

Move between modes, save safely, and find the text you need.

4 quick lessons · Examples to adapt to your server
In this guide
Open a fileSave or leaveSearch and navigateCheck scripts after editing

Commands use class paths and example filenames. Replace placeholders and inspect the target before making changes.

01

Open a file

Vim starts in Normal mode. Press i to enter Insert mode and type. Press Esc to return to Normal mode before entering editing commands.

COMMANDS & EXAMPLES
vim ~/.bashrc
vim ~/scripts/shell/health-check.sh
Field note

On a Mac using zsh, interactive shell customizations usually belong in ~/.zshrc. Check echo "$SHELL" and the shell you are actually running before choosing a startup file.

02

Save or leave

Type these commands in Normal mode. :w saves, :q quits, and :wq does both. :q! discards unsaved edits.

COMMANDS & EXAMPLES
:w
:q
:wq
:q!
Field note

The leading colon opens the Vim command line; these are Vim commands, not shell commands.

03

Search and navigate

Use /text followed by Enter to search forward. n repeats the search; N reverses direction. gg goes to the first line and G to the last line.

COMMANDS & EXAMPLES
:set number
:52
/if curl
:set paste
Field note

For terminal paste problems, :set paste can help on terminals without bracketed paste support; turn it off with :set nopaste afterward.

04

Check scripts after editing

A syntax check catches unmatched quotes, missing fi or done, and incomplete loops before the script runs. An error near the end can originate much earlier.

COMMANDS & EXAMPLES
bash -n ~/scripts/shell/health-check.sh
nl -ba ~/scripts/shell/health-check.sh | less
Field note

Copy commands from code blocks. Markdown link syntax such as [label](URL) does not belong in a shell script.