Vim Recall繁體中文

Save view of current window to a file

:mkview

Example

Normal 0 / 2

Save view of current window to a file.

Current window view

File
chapter.txt
Cursor
line 2, column 1
Fold
lines 2–3 closed
viewoptions
folds,cursor

Files

chapter.view.vim
absent
Before & after

Before

Current window view

File
chapter.txt
Cursor
line 2, column 1
Fold
lines 2–3 closed
viewoptions
folds,cursor

Files

chapter.view.vim
absent

After

Current window view

File
chapter.txt
Cursor
line 2, column 1
Fold
lines 2–3 closed
viewoptions
folds,cursor

Files

chapter.view.vim
created: restore chapter.txt, closed fold 2–3, cursor line 2

Subject: :mkview. Documentation-backed illustration; assumes named chapter.txt, manual fold 2–3, viewoptions=folds,cursor, writable absent output file; not replay-verified. Writes a script restoring this window's file, fold and cursor. An explicit file name adds an edit command; source chapter.view.vim later restores it.

Sample buffer
chapter one
chapter two
chapter three
Cursor on line 2, column 1
Details & Vim help

Save view of current window to a 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 :mkvie[w] 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.