-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
Steps to reproduce
- :50,100s/a/b/g # Replace every instance of 'a' with 'b' on lines 50 through 100
- Observe 'a' is highlighted all over the document
- Observe keyboards all over the world with premature wear on the :, n, o, and h keys.
You have the power to redeem these keys!
For some reason that is beyond my pay grade, the substitution function and hlsearch are like conjoined twins. Nonetheless, I'm certain that somehow POSIX has something to do with it because it always does.
On the surface, this marriage seems to be nothing more than a case of annoying and pointless behavior, but the fact that it is impacting lines outside of the given range is what elevates this to 'bug' status rather than simply 'annoyance.'
The really unfortunate part is that there might actually be some merit to this feature if it were written correctly to respect line ranges. Most of the time, users would not notice that highlighting was even happening because they just replaced the search word(s). But if the highlighting was seen, it would likely be useful as a reminder to verify that your substitution executed the way you wanted it to... or you probably forgot to use /g.
Expected behaviour
Highlighting should apply only within the specified substitution range (50–100).
Version of Vim
NVIM v0.10.4
Environment
OS: Debian 13.1 "Trixie"
Terminal: Windows Terminal -> ssh -> bash
Value of $TERM: xterm-256color
Shell: bash 5.2.37(1)-release
Logs and stack traces
N/A