Closed dancojocaru2000 closed 2 weeks ago
:+1: We currently support :%s/../..
, (and you can use any character instead of /
) but you have to use %
and /g
is always provided. It would be lovely to parse this more similarly to vim.
TODO:
/g
(only replace the first match on a line by default)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 3>>
to indent the next three lines. Seems to work intermittently, e.g. 3dd
works to delete the next three lines.
This is now in 0.134.0-pre.
Awesome, thanks!
Is the s/search/replace
still not supported or is it still only in preview release? The only thing that worked for me is %s/search/replace
which is not what I always want.
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:
:
it prefills the '</'> marks, and if you
type a command that doesn't support a range it errors:
with a visual selection, it doesn't give
you a visual indication, and if the command respects the active selection
then it just worksAny 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 https://github.com/zed-industries/zed/issues/9428#issuecomment-2121060658, 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
1
2
3
4
5
and I execute the command:
:2,3s/^/x/
I get the result
1
x2
x3
x4
5
If I do the same in vim I get the expected result:
1
x2
x3
4
5
I took a stab at the issue I mentioned: https://github.com/zed-industries/zed/pull/13920
+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.
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