ZIm/crates/vim/src
Dino af5318df98
Update default vim substitute command behavior and add support for 'g' flag (#28138)
This Pull Request updates the default behavior of the substitute (`s`)
command in vim mode to only replace the next match by default, instead
of all, and replace all matches only when the `g` flag is provided,
making it more similar to NeoVim's behavior.

In order to achieve this, the following changes were introduced:

- Update `BufferSearchBar::replace_next` to be a public method, so it
can be called from `Vim::replace_command` .
- Update the `Replacement::parse` to set the `should_replace_all` field
to `false` by default, and only set it to `true` if the `'g'` flag is
present in the query.
- Add support for when the `Replacement.should_replace_all` is set to
`false` in `Vim::replace_command`, so as to have it only replace the
next occurrence instead of all occurrences in the line.
- Introduce `BufferSearchBar::select_first_match` so as to activate the
first match on the line under the cursor.

Closes #24450 

Release Notes:

- Improved vim's substitute command so as to only replace the first
match by default, and replace all matches if the `'g'` flag is provided

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-04-09 14:34:51 -06:00
..
digraph Add Vim digraphs (#14887) 2024-07-28 22:44:32 -06:00
normal Update default vim substitute command behavior and add support for 'g' flag (#28138) 2025-04-09 14:34:51 -06:00
test chore: Bump Rust version to 1.86 (#28021) 2025-04-03 23:32:50 +02:00
change_list.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
command.rs vim: Add :Git (#27874) 2025-04-01 15:12:36 -06:00
digraph.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
helix.rs Temporarily disable helix tests (#28279) 2025-04-07 21:50:35 +00:00
indent.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
insert.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
mode_indicator.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
motion.rs vim: Add indent-wise motions (#28044) 2025-04-08 09:07:37 -06:00
normal.rs Flesh out helix bindings (#28103) 2025-04-04 12:21:15 -06:00
object.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
replace.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
rewrap.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
state.rs vim: Add g? convert to Rot13/Rot47 (#27824) 2025-04-02 02:17:00 +00:00
surrounds.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
test.rs Don't use dbg! in test input (#27811) 2025-03-31 18:59:52 -06:00
vim.rs vim: Fix exchange showing ccx in pending keys (#28303) 2025-04-08 09:03:24 -06:00
visual.rs Fix vim test keystroke (#28406) 2025-04-09 14:29:03 -06:00