Following command keeps search pattern history
:keeppatterns
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2first line
second line
third line
fourth line
fifth lineCursor on line 3, column 2first line
second line
third line
fourth line
fifth lineCursor on line 3, column 2new line
second line
third line
fourth line
fifth lineCursor on line 1, column 1Following command keeps search pattern history.
Vim registers
/Last search register- Characterwise
Empty
Local marks
- 'a
line 2, column 4- 'b
line 4, column 3- '.
line 2, column 1
Jump list
Command entered · ready to apply
Vim registers
/Last search register- Characterwise
Empty
Local marks
- 'a
line 2, column 4- 'b
line 4, column 3- '.
line 2, column 1
Jump list
Command applied
Vim registers
/Last search register- Characterwise
Empty
Local marks
- 'a
line 2, column 4- 'b
line 4, column 3- '[
line 1, column 1- ']
line 1, column 1- '.
line 1, column 1
Jump list
- 1 · line 3
column 2
Before & after
first line
second line
third line
fourth line
fifth lineCursor on line 3, column 2Vim registers
/Last search register- Characterwise
Empty
Local marks
- 'a
line 2, column 4- 'b
line 4, column 3- '.
line 2, column 1
Jump list
new line
second line
third line
fourth line
fifth lineCursor on line 1, column 1Vim registers
/Last search register- Characterwise
Empty
Local marks
- 'a
line 2, column 4- 'b
line 4, column 3- '[
line 1, column 1- ']
line 1, column 1- '.
line 1, column 1
Jump list
- 1 · line 3
column 2
Start in Normal mode.
Details & Vim help
Example replayed in Vim
Following command keeps search pattern history. 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 :keepp[atterns] 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.