Vim Recall繁體中文

Prompt user when confirmation required

:confirm

Example

Normal 0 / 3
changed alpha
Cursor on line 1, column 1

Prompt user when confirmation required.

Current buffer

Name
alpha.txt
modified
yes
Before & after
Before
changed alpha
Cursor on line 1, column 1

Current buffer

Name
alpha.txt
modified
yes
After
beta
Cursor on line 1, column 1

Confirmation

Question
Save changes to "alpha.txt"?
Illustrated choice
No

Current buffer

Name
beta.txt
modified
no

Documentation-backed illustration. a clean terminal Vim with +dialog_con and English messages; alpha.txt is a modified normal file buffer shown in only one window with bufhidden empty; hidden, autowrite and autowriteall are off and write is on; beta.txt exists with the shown contents and has not been loaded or visited; cmdheight=4, at least 80 columns and no pending messages; the illustrated user chooses No. The confirmation asks about unsaved alpha.txt. Choosing No discards that buffer's changes and opens beta.txt. Primary help: :confirm.

Details & Vim help

Prompt user when confirmation required. 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 :conf[irm] 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.