zed
zed copied to clipboard
Vim substitution command should work if c or n flags are used
Check for existing issues
- [x] Completed
Describe the bug / provide steps to reproduce it
Currently :s/foo/bar replaces foofoo with barbar. There is code to override this if :s/foo/bar/n or :s/foo/bar/c are used, however it is not executed. The result is that these flags cause the command to do nothing.
Zed Version and System Specs
In Zed, create a buffer with multiple cases of the same word on the same line. Example: foofoo. Enable vim mode.
Then type
:s/foo/bar/c
Nothing occurs.
The same happens if you type
:s/foo/bar/n
Note: The normal vim behavior is to only replace one occurrence unless /g is used. The behavior in zed is different by design and /g is not needed, but should be possible to override with either of these options.
If applicable, add screenshots or screencasts of the incorrect state / behavior
No response
If applicable, attach your Zed.log file to this issue.
No response
I mentioned this on the PR, but just to make sure it's visible:
- I think in Vim,
/ndoes no replacements, it just shows the count. In zed we should treat this the same as a search and ignore the replace /casks you to confirm before each replacement. I think we should "emulate" this by focusing the replace editor so you can mash<enter>to do replacements.
This will also get a lot better once we have command palette history
Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 7 days. Thanks for your help!
Still relevant—I miss /c, and single replace without /g.
/g was implemented a few months ago!
I think /n kind of works right too (it just highlights things, but doesn't move the cursor).
/c needs some work to make keyboard shortcuts right.
/g was implemented a few months ago!
@ConradIrwin Is it possible to replace only the next occurrence when omitting /g?
Yes, https://github.com/zed-industries/zed/pull/28138 added that. Are you seeing something different?
Ahhh you're right, I was using :%s instead of :s, never mind 😅 Looking forward to /c though!
Fixed it 🦀