# Survive any remote box with a Vim quick start

> Survive SSH edits with Normal, Insert, and safe quit paths, plus a check for Vim versus nvi.

Source: https://fullbytedeveloper.com/blog/vim-quick-start-remote-box
Published here: 2026-11-17, updated 2026-12-03

The goal on a strange SSH box is survival: open a file, change a line, leave safely. Vim starts in Normal mode, where keys are commands, not text. Press `i` for Insert, `Esc` to return to Normal, and `:` for Command-line quit paths. `ZZ` writes and exits; `colon-q-bang` discards [1][2].

## Quick start: check which vi you actually have

Before teaching Vim-only tricks, ask the remote host what `vi` is. FreeBSD, NetBSD, and OpenBSD traditionally ship nvi as the default `vi` (a smaller Berkeley re-implementation). Treat that lineage note as orientation, not a portability guarantee [3][4].

```bash
command -v vi vim nvi 2>/dev/null
readlink -f "$(command -v vi)" 2>/dev/null
vim --version | head -1
vi --version 2>&1 | head -1
```

Captured on this Debian-derived host:

```text
/usr/bin/vi
/usr/bin/vim
/usr/bin/vim.basic
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Aug 24 2026 22:13:04)
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Aug 24 2026 22:13:04)
```

Sandbox capture on the review host; re-run on your box before you treat the numbers as a lab result.

Here `vi` resolves to a Vim binary. If `nvi` is what you have, stick to classic vi motions and the quit paths below until you install Vim on purpose.

## Edit, save, and quit without panic

Interactive practice (do this on a throwaway file, not production configs):

```text
vim /tmp/vim-demo-fbd/demo.txt
# Normal mode: press i, type text, press Esc
# Save and quit: ZZ
# Or: :wq then Enter
# Abort without saving: colon-q-bang then Enter
```

Bare `:q` can fail with `E37: No write since last change (add bang to override)` when the buffer has unsaved edits [1]. Use `colon-q-bang` when you mean to discard.

For a non-interactive check that the same editor can rewrite a file:

```bash
mkdir -p /tmp/vim-demo-fbd
printf 'line1\nline2\n' > /tmp/vim-demo-fbd/demo.txt
vim -es -u NONE /tmp/vim-demo-fbd/demo.txt <<'EOF'
%s/line1/hello/
wq
EOF
cat /tmp/vim-demo-fbd/demo.txt
```

Captured output:

```text
hello
line2
```

That proves the editor can rewrite a path without a GUI. Muscle-memory the interactive path (`i`, `Esc`, `ZZ`) before you need it on a broken production box.

<figure>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 280" role="img" aria-label="Dark diagram: Normal mode box with keys as commands, i arrow into Insert mode where keys become text, Esc return path, Command-line box with :wq and colon-q-bang, plus ZZ write-and-exit footer, no people.">
  <defs>
    <marker id="vimArrow" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto">
      <path d="M0,0 L8,3 L0,6 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="720" height="280" rx="12" fill="#0b1f3a"/>
  <text x="24" y="36" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="16" font-weight="700">day-one Vim modes</text>
  <rect x="24" y="56" width="180" height="88" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="40" y="88" fill="#14b8a6" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">Normal</text>
  <text x="40" y="112" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">keys are commands</text>
  <path d="M212 100 H250" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#vimArrow)"/>
  <text x="220" y="88" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">i</text>
  <rect x="258" y="56" width="180" height="88" rx="8" fill="#123052" stroke="#f59e0b" stroke-width="2"/>
  <text x="274" y="88" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">Insert</text>
  <text x="274" y="112" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">keys become text</text>
  <path d="M348 144 V168" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#vimArrow)"/>
  <text x="356" y="164" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">Esc</text>
  <rect x="468" y="56" width="228" height="88" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="484" y="88" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">Command-line</text>
  <text x="484" y="112" fill="#f8fafc" font-family="ui-monospace, monospace" font-size="14">:wq  colon-q-bang</text>
  <rect x="24" y="188" width="672" height="64" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="40" y="228" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">ZZ in Normal writes and exits; colon-q-bang discards unsaved edits [1]</text>
</svg>
</figure>

*Normal mode treats keys as commands. Press i to enter Insert where typing becomes text, then Esc to return. Command-line mode handles :wq and colon-q-bang. ZZ in Normal writes and exits so you can leave a remote edit safely.*

## Keep the day-one set small

Teach Normal, Insert, and Command-line first. Mention Visual mode only as "select, then act" if someone asks. Do not start remote sessions with destructive macros on production files. Prefer a dedicated scratch file under `/tmp` until the quit paths are muscle memory.

Minimal motion set that covers most rescue edits:

- `h` `j` `k` `l` move one character or line
- `0` and end-of-line (`$` in Vim help) jump to line start and end
- `dd` deletes a line in Normal (practice on the scratch file)
- `u` undoes the last change

Stop there on day one. Search, macros, and plugins wait until you can exit without closing the SSH window [1][2].

## Mistakes that trap people on SSH boxes

Closing the terminal window because `:q` printed `E37`. Use `colon-q-bang` or `ZZ` instead [1].

Treating every `vi` as Vim. Check `--version` before relying on Vim-only syntax [3][4].

Editing `/etc` files before practicing on `/tmp`. One wrong `dd` on a real config is enough.

Staying in Insert while trying to run Normal commands. Press `Esc` until you are sure, then try again.

Typing `Ctrl+S` by accident and thinking Vim froze. That is terminal flow control; see [terminal stuck recovery](/blog/term-stuck) before you kill the session.

## Depth: why modes exist

Normal mode keeps the keyboard free for operators. Insert mode is the rare state where typing inserts. Command-line mode is for ex commands such as write and quit [1]. That split is why beginners feel "stuck": they are in the wrong mode for the key they pressed. The fix is always the same: `Esc` to Normal, then choose Insert or `:`.

When the box is reached through SSH aliases, keep the Host block short so reconnecting after a bad edit is two words. Pair this page with [SSH config aliases](/blog/ssh-config) and [top terminal commands part 1](/blog/essential-linux-commands-developers-part-1).

## A five-minute drill you can repeat

1. Create `/tmp/vim-demo-fbd/notes.txt` with one line of text.
2. Open it in Vim. Press `i`, append a word, press `Esc`.
3. Save with `ZZ`. Re-open and confirm the word stuck.
4. Open again, change something, leave with `colon-q-bang`, re-open and confirm the discard.
5. Run the `vim -es` rewrite snippet once so you trust non-interactive edits too.

Repeat that drill on the next unfamiliar host before you touch production configs. The host that ships nvi will still honor the classic quit paths even when Vim-only features are missing [3][4].

## When something still feels frozen

If the screen stops updating after `Ctrl+S`, press `Ctrl+Q`. If SSH itself is wedged, use the tilde escape from [terminal stuck recovery](/blog/term-stuck). If Vim is merely waiting in the wrong mode, `Esc` then `colon-q-bang` is still the safe abort. Closing the window kills every job in that session, which is how people turn a small edit into an outage.

## Write versus quit, said plainly

Three exits cover almost every panic:

1. `ZZ` in Normal: write the file if needed, then quit [1].
2. `:wq` then Enter: same intent, typed on the command line.
3. `colon-q-bang` then Enter: quit and throw away the buffer [1].

`:w` alone writes and leaves you inside Vim. `:q` alone quits only when nothing changed; otherwise you meet `E37` [1]. Say the intent out loud before you type: "save and leave" versus "leave and discard." That one sentence prevents half of the closed-window stories.

## Count lines before you delete

On a rescue edit, jump with `0` and `$`, fix the typo in Insert, then leave. If you must delete a bad line, glance at the line number (`Ctrl+G` shows position in many builds) before `dd` [1]. Undo with `u` immediately if the wrong line vanished. Macros, global substitutes, and plugins wait until those habits are boring.

Some hosts only offer nvi. Classic motions and the quit paths above still apply; Vim-only `:help` pages and some visual tricks may not [3][4]. When you control the box, install Vim on purpose and keep using the same survival set.

## Pair the editor with a short SSH alias

Long `ssh -i ... -p ...` lines make people rush the edit because reconnecting hurts. Put the Host block in place first ([SSH config aliases](/blog/ssh-config)), then practice Vim on `/tmp`. Reconnect should be two words so a bad buffer is cheap to abandon with `colon-q-bang`.

## What to ignore on day one

Skip `.vimrc` customization until you can exit cleanly on a stock binary. Skip plugins, status lines, and color schemes on a rescue box. Skip Visual mode until Normal, Insert, and the three quit paths are automatic [1]. The user manual usr_02 is intentionally small; that is the point for remote survival [1][2].

If the host opens `nano` when you type `EDITOR=nano`, that is fine for that session. This page is for the common case where `vi` or `vim` is what you get, including when a tool drops you into `$EDITOR` mid-incident. Know the escape hatches before the incident, not during it.

## One more non-interactive check

After the `%s` rewrite demo, confirm you can append a line without a TTY:

```bash
vim -es -u NONE /tmp/vim-demo-fbd/demo.txt <<'EOF'
a
third
.
wq
EOF
cat /tmp/vim-demo-fbd/demo.txt
```

Captured output:

```text
hello
line2
third
```

If that fails on nvi, fall back to the interactive `i` / `Esc` / `ZZ` path and treat ex-mode scripts as Vim-only until you verify [3][4].

Browse the [Dev explainers topic](https://fullbytedeveloper.com/blog/topic/dev-explainers).

Send this to the friend who got stuck in vim on a server and closed the window.

Image: A dark editor slab split into a calm navy normal-mode pane and a glowing amber insert-mode pane, with a teal pipe running from the slab into a stacked remote cube, on a navy grid with small unmarked geometric accents and no typography, keys, or figures.
https://fullbytedeveloper.com/media/vim-quick-start-remote-box/vim-quick-start-remote-box-venice.webp
Reach the box, switch modes, and keep a safe quit path before you edit.

## Sources

1. [Vim user manual usr_02 (first steps), accessed 2026-11-14](https://vimhelp.org/usr_02.txt.html)
2. [vim.org documentation index, accessed 2026-11-14](https://www.vim.org/docs.php)
3. [vi.stackexchange: relation between vi, nvi, and Vim, accessed 2026-11-14](https://vi.stackexchange.com/questions/341/what-is-the-relation-between-vi-nvi-and-vim)
4. [Wikipedia: Nvi, accessed 2026-11-14](https://en.wikipedia.org/wiki/Nvi)
