-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vim mode: add :s/search/replace command #9428
Comments
👍 We currently support TODO:
If you'd like to pair with me on this, you can book time here: https://calendly.com/conradirwin/pairing |
Global search and replace is handy but current line and fixed number of lines replacement is extremely useful too (the range parsing @ConradIrwin mentions) 👍 Edit: line parsing in general would be handy. Keeps throwing me off, e.g. for indentation like |
Release Notes: - Added support for line ranges in vim replace commands #9428 - not supporting anything other than bare line numbers right now - ~need to figure out how to show range in question in search bar~ @ConradIrwin implemented showing a highlight of the selected range for a short direction instead - ~tests lol~
This is now in 0.134.0-pre. |
Awesome, thanks! |
Is the |
Currently we support % and (as of recently) 1,2s to give a line number range. What range syntax were you trying to use? |
I was trying to substitute the text that I selected in visual mode |
I was trying to substitute the text that I selected in visual mode
👍 Thanks!
I'm in a bit of a pickle with what to do about '< and '> - vim always adds
them to the command palette from visual mode and then complains if you do
something "wrong" (like `:w`).
It seems like there are three options:
- vim-style: when typing `:` it prefills the '</'> marks, and if you
type a command that doesn't support a range it errors
- zed-style: when typing `:` with a visual selection, it doesn't give
you a visual indication, and if the command respects the active selection
then it just works
- hybrid: we prefill the marks, and if you type a command that doesn't
support them, we just ignore that?
Any preferences?
…On Mon, May 20, 2024 at 1:24 PM, Stepan Tikunov ***@***.***> wrote:
I was trying to substitute the text that I selected in visual mode
—
Reply to this email directly, view it on GitHub
<#9428 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAXAQGIH5DFQMRO4KX5HWLZDJEVJAVCNFSM6AAAAABEY6F4WWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRRGA3DANRVHA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
The first option seems the least preferable if our goal isn't to 100% replicate vim's behavior. There is no real functional difference between the zed-style and the hybrid options. But it seems that the zed-style option looks more intuitive from user's perspective as opposed to the hybrid way because for commands that don't rely on visual selection, those prefilled marks might confuse someone |
I would very much prefer an indication that Zed will only perform the replace in the selection and won't mess up the entire file. |
I don't think the any of the original features here are implemented? The global find replace works, but none of the following works?
I'm not sure this should be closed yet, especially since it was a top voted issue. It's actually the single issue stopping me from using Zed at the moment (maybe I'm alone in how often I use Vim search replace on visual selections though 🤷). |
Also something with the range syntax appears to be broken as well. If I have the text
and I execute the command:
I get the result
If I do the same in vim I get the expected result:
|
I took a stab at the issue I mentioned: #13920 |
This is related to #9428 I noticed that doing a search and replace for the beginning of a line `^` results in the trailing line being included in the search. This seems to be because of the way the range is generated for generating matches being the up to the start of the trailing line rather than up to the end of the last line. I added a test and took a stab at fixing it but it is a bit yolo as this is the first time I've seen this codebase.
+1 on this issue, it was very jarring to see the %s replaced every instance in file rather than just the selected lines in visual mode. This feels like a must have for a vim mode. Entering line ranges manually isn’t something I do ever in vim. Hoping this gets fixed soon! |
I never use visual mode, but I enter line ranges all the time - however it doesn't work anyway for many things, e.g. search and replace does not work on a single line or on a line range. Honestly the most frustrating thing in zed and why I sometimes jump back into real vim. |
The most requested feature here is "search and replace in visual mode", but as a happy side effect we can now support things like :2,12j to join those lines, and much much more. Release Notes: - vim: Added support for range syntax in command ([#9428](#9428)). - vim: Prefill command with `:'<,'>` from visual mode ([#13535](#13535)).
This should be landing in today's preview release. |
Check for existing issues
Describe the feature
I find needing to use the GUI for find&replace to be quite unwieldy. It would be quite useful to have Vim's
:s
implemented. The features (some missed by other projects implementing Vim emulation) should be::s/search/replace
- replaces one occurrence of "search" with "replace":s/search/replace/g
- replaces all occurrences of "search" with "replace":s=a/b=c/d
- replaces "a/b" with "c/d" (using=
or another character as a different separator to allow the search to contain the/
character)If applicable, add mockups / screenshots to help present your vision of the feature
No response
The text was updated successfully, but these errors were encountered: