Vim Recall繁體中文

Create a fold

:fold

Example

Normal 0 / 2
outer start
  first
  second
  third
outer end
separator
last line
Cursor on line 1, column 1

Create a fold.

Folds

Line 1 · level 1 Active
closed · lines 1–5
Line 2 · level 2
closed · lines 1–5
Line 3 · level 2
closed · lines 1–5
Line 4 · level 2
closed · lines 1–5
Line 5 · level 1
closed · lines 1–5

Option · foldenable

Local foldenable
1
Global foldenable
1

Option · foldlevel

Local foldlevel
0
Global foldlevel
0
Before & after
Before
outer start
  first
  second
  third
outer end
separator
last line
Cursor on line 1, column 1

Folds

Line 1 · level 1 Active
closed · lines 1–5
Line 2 · level 2
closed · lines 1–5
Line 3 · level 2
closed · lines 1–5
Line 4 · level 2
closed · lines 1–5
Line 5 · level 1
closed · lines 1–5

Option · foldenable

Local foldenable
1
Global foldenable
1

Option · foldlevel

Local foldlevel
0
Global foldlevel
0
After
outer start
  first
  second
  third
outer end
separator
last line
Cursor on line 1, column 1

Folds

Line 1 · level 2 Active
closed · lines 1–5
Line 2 · level 3
closed · lines 1–5
Line 3 · level 3
closed · lines 1–5
Line 4 · level 3
closed · lines 1–5
Line 5 · level 2
closed · lines 1–5

Option · foldenable

Local foldenable
1
Global foldenable
1

Option · foldlevel

Local foldlevel
0
Global foldlevel
0

Start in Normal mode. foldmethod=manual is prepared with lines 2–4 nested inside a fold spanning lines 1–5. The fold panel reports the resulting open and closed state of those ranges.

Details & Vim help

Example replayed in Vim

Create a fold. 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 :fo[ld] 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.