ZIm/crates/editor/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
..
display_map Introduce "Near" block type (#28032) 2025-04-04 17:37:42 -06:00
git Git activity indicator (#28204) 2025-04-07 18:10:01 +00:00
scroll chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
test Preserve cursor position when resetting excerpts (#27850) 2025-04-01 16:55:10 +00:00
actions.rs debugger: Add run to cursor and evaluate selected text actions (#28405) 2025-04-09 19:57:29 +00:00
blink_manager.rs Remove unneeded anonymous lifetimes from gpui::Context (#27686) 2025-03-28 19:26:30 +00:00
clangd_ext.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
code_context_menus.rs Add dedicated actions for LSP completions insertion mode (#28121) 2025-04-08 22:03:03 +00:00
display_map.rs Introduce "Near" block type (#28032) 2025-04-04 17:37:42 -06:00
editor.rs debugger: Add run to cursor and evaluate selected text actions (#28405) 2025-04-09 19:57:29 +00:00
editor_settings.rs editor: Hide mouse cursor also for movements and selections (#27677) 2025-03-29 19:23:36 +05:30
editor_settings_controls.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
editor_tests.rs Don't scroll the editor on select all matches (#28435) 2025-04-09 17:50:14 +00:00
element.rs Remove actions UnfoldAt and FoldAt (#28442) 2025-04-09 17:13:41 +00:00
git.rs Project Diff 2 (#23891) 2025-02-03 13:18:50 -07:00
highlight_matching_bracket.rs Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
hover_links.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
hover_popover.rs agent: Add headers for code blocks (#28253) 2025-04-07 23:56:24 +00:00
indent_guides.rs Move "async move" a few characters to the left in cx.spawn() (#26758) 2025-03-19 02:09:02 +00:00
inlay_hint_cache.rs Preserve cursor position when resetting excerpts (#27850) 2025-04-01 16:55:10 +00:00
inline_completion_tests.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
items.rs Update default vim substitute command behavior and add support for 'g' flag (#28138) 2025-04-09 14:34:51 -06:00
jsx_tag_auto_close.rs jsx-tag-auto-close: Remove potential source of bugs and panics (#28119) 2025-04-04 19:01:08 +00:00
linked_editing_ranges.rs Move "async move" a few characters to the left in cx.spawn() (#26758) 2025-03-19 02:09:02 +00:00
lsp_ext.rs Support tasks from rust-analyzer (#28359) 2025-04-08 15:07:56 -06:00
mouse_context_menu.rs debugger: Add run to cursor and evaluate selected text actions (#28405) 2025-04-09 19:57:29 +00:00
movement.rs Preserve cursor position when resetting excerpts (#27850) 2025-04-01 16:55:10 +00:00
persistence.rs Persist editor folds between restarts (#27252) 2025-03-21 15:28:11 +00:00
proposed_changes_editor.rs Preserve cursor position when resetting excerpts (#27850) 2025-04-01 16:55:10 +00:00
rust_analyzer_ext.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
scroll.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
selections_collection.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00
signature_help.rs Use symmetric padding in signature popovers (#27734) 2025-04-01 14:14:33 +02:00
tasks.rs Support tasks from rust-analyzer (#28359) 2025-04-08 15:07:56 -06:00
test.rs chore: Bump Rust edition to 2024 (#27800) 2025-03-31 20:55:27 +02:00