Vim Recall繁體中文

Save all text to swap file

:preserve

Example

Normal 0 / 2

Save all text to swap file.

Fixture files

notes.txt
draft
.notes.txt.swp
exists; text blocks not fully flushed
Before & after

Before

Fixture files

notes.txt
draft
.notes.txt.swp
exists; text blocks not fully flushed

After

Fixture files

notes.txt
draft
.notes.txt.swp
all current text saved: draft revised; recoverable without original file

Subject: :preserve. Documentation-backed illustration; assumes swapfile enabled, writable swap file for named notes.txt and modified current buffer; not replay-verified. Writes all current buffer text to its swap file. The original notes.txt remains draft; preserve is not a normal file write.

Sample buffer
draft revised
Cursor on line 1, column 1
Details & Vim help

Save all text to swap file. This Ex reference uses the full command name; the alphabetical index omits arguments. Supply the ranges, arguments, flags and prerequisite state documented in the linked help. Press Enter to submit a complete command. The index spelling :pre[serve] puts the optional abbreviation suffix in square brackets; those brackets are not typed. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative.