Preserve marks during a filter command
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2zeta
alphaCursor on line 1, column 1zeta
alphaCursor on line 1, column 1alpha
zetaCursor on line 1, column 1Preserve marks during a filter command.
Local marks
- a
line 1, column 1
Filter setup
- cpoptions
includes R- sort
POSIX sort, LC_ALL=C
Command entered · ready to apply
Local marks
- a
line 1, column 1
Filter setup
- cpoptions
includes R- sort
POSIX sort, LC_ALL=C
Command line
- Typed text
:keepmarks %!sort- Insertion offset
17
:keepmarks preserves mark a at line 1 while the external sort exchanges the two equal-count lines.
Local marks
- a
line 1, column 1 (now alpha)
Filter setup
- cpoptions
includes R- sort
POSIX sort, LC_ALL=C
Before & after
zeta
alphaCursor on line 1, column 1Local marks
- a
line 1, column 1
Filter setup
- cpoptions
includes R- sort
POSIX sort, LC_ALL=C
alpha
zetaCursor on line 1, column 1Local 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!.