Vim Recall繁體中文

Preserve marks during a filter command

:keepmarks

Example

Normal 0 / 2
zeta
alpha
Cursor on line 1, column 1

Preserve marks during a filter command.

Local marks

a
line 1, column 1

Filter setup

cpoptions
includes R
sort
POSIX sort, LC_ALL=C
Before & after
Before
zeta
alpha
Cursor on line 1, column 1

Local marks

a
line 1, column 1

Filter setup

cpoptions
includes R
sort
POSIX sort, LC_ALL=C
After
alpha
zeta
Cursor on line 1, column 1

Local marks

a
line 1, column 1 (now alpha)

Filter setup

cpoptions
includes R
sort
POSIX sort, LC_ALL=C

Documentation-backed illustration. POSIX sort with C collation, unrestricted filters, cpoptions includes R, and mark a is at the shown position; data only. :keepmarks preserves mark a at line 1 while the external sort exchanges the two equal-count lines. Primary help: :keepmarks.

Details & Vim help

Preserve marks during a filter command. 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 :kee[pmarks] 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. The documented implementation applies to filters through :range!.