I removed the -
from the word_separators
setting, and that works fine.
But ctrl + d on the word a
still matches the "a" in a-b
, I don't want it to do that anymore.
It's because ctrl + d wraps your search with regex boundaries \b
, and -
is still considered a boundary.
Is there anything I can do to now make ctrl + d not consider -
a boundary anymore.
EDIT: picture:
The "a" in a-b
should not be highlighted, as a-b
is a single variable name in this language, which is why I removed the -
from word_separators
More clarification: If I'm trying to replace all instance of the variable a
, I don't want it matching against parts of other variables, like the "a" in a-b
.
From what I can tell from some informal experimenting while answering your other question, the "word_separators"
setting seems to primarily relevant when double-clicking to select words. For example, I have the following words in a file:
and my word_separators
list is ./\\()\"'-:,;<>~!@#%^&*|+=[]{}`~?$
, so it includes -
and /
but not _
. If I put my cursor in the first foo
(without selecting the whole word first) and hit CtrlD, I get
and if I continue hitting CtrlD for several more times, I get
so only the "individual words" are selected - foo_bar
is not, nor is foobar
. However, if I set word_separators
to .\\()\"':,;<>~!@#%^&*|+=[]{}`~?$
(removing -
and /
) I get the same results when hitting CtrlD repeatedly:
-
and /
are still treated as word separators, even though I removed them from the list. If I add _
to the word_separators
list, the results are the same, and only one obvious conclusion can be drawn: word_separators
is ignored by CtrlD (find_under_expand
).
However, the word_separators
list IS used when double-clicking to select a word. With the list like this: .\\()\"'_:,;<>~!@#%^&*|+=[]{}`~?$
(missing -
and /
, but with _
), double-clicking on foo
in each word in turn gives the following:
Interestingly, double-clicking on the very first foo
gives
indicating that the "box" highlighting of similar selections is not paying attention to word_separators
.
When using Find -> Find...
to search, word_separators
is ignored. When nothing is selected and foo
is entered into the search box (non-regex search), the following matches are highlighted:
This is the same regardless of whether -
, /
, and/or /
are in word_separators
or not.
If "Whole Word"
is set in the options, the results are a bit different, but again they don't change regardless of whether -
, /
, and/or /
are in word_separators
:
So, the conclusion is that word_separators
is only in effect when double-clicking to select a word. Using a Find
dialog or CtrlD (find_under_expand
command) relies on some internal separator list, which apparently can't be altered (see my answer here).
Some info I forgot to add earlier: word_separators
is also used by some plugins for various sorts of things, such as creating/modifying/otherwise working with selections, doing programmable completions, find and replace, and other sorts of stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With