I removed the -
from the word_separators
setting, and that works fine.
我删除了 - 从word_separators设置,这工作正常。
But ctrl + d on the word a
still matches the "a" in a-b
, I don't want it to do that anymore.
但是单词a上的ctrl + d仍然匹配a-b中的“a”,我不希望它再这样做了。
It's because ctrl + d wraps your search with regex boundaries \b
, and -
is still considered a boundary.
这是因为ctrl + d用正则表达式边界包裹你的搜索\ b,并且 - 仍然被认为是边界。
Is there anything I can do to now make ctrl + d not consider -
a boundary anymore.
有什么我可以做的,现在让ctrl + d不考虑 - 一个边界了。
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
a-b中的“a”不应突出显示,因为a-b是此语言中的单个变量名称,这就是为什么我从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
.
更多说明:如果我试图替换变量a的所有实例,我不希望它与其他变量的部分匹配,比如a-b中的“a”。
1 个解决方案
#1
9
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:
从我在回答您的其他问题时的一些非正式实验中可以看出,“word_separators”设置似乎主要与双击选择单词相关。例如,我在文件中有以下单词:
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
我的word_separators列表是./\\()\"'-:,;<>〜!@#%^&*||| {{{}。?!,因此它包括 - 和/但不是_。如果我将光标放在第一个foo中(不先选择整个单词)并点击CtrlD,我就会得到
and if I continue hitting CtrlD for several more times, I get
如果我再继续按CtrlD几次,我明白了
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:
所以只选择了“个别单词” - foo_bar不是,也不是foobar。但是,如果我将word_separators设置为。\\()\“':,; <>〜!@#%^&* | + = [] {}`〜?$(删除 - 和/)我得到相同的结果重复按CtrlD时:
-
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
).
- 和/仍然被视为单词分隔符,即使我从列表中删除它们。如果我将_添加到word_separators列表,结果是相同的,只能得出一个明显的结论:CtrlD(find_under_expand)忽略word_separators。
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:
但是,双击选择单词时使用word_separators列表。使用如下列表:。\\()\“'_:,; <>〜!@#%^&* | + = [] {}`〜?$(缺少 - 和/,但带_),双击每个单词中的foo依次给出以下内容:
Interestingly, double-clicking on the very first foo
gives
有趣的是,双击第一个foo给出了
indicating that the "box" highlighting of similar selections is not paying attention to word_separators
.
表明类似选择的“框”突出显示没有注意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:
使用“查找” - >“查找...”进行搜索时,将忽略word_separators。如果未选择任何内容并且在搜索框中输入了foo(非正则表达式搜索),则会突出显示以下匹配项:
This is the same regardless of whether -
, /
, and/or /
are in word_separators
or not.
无论 - ,/和/或/是否在word_separators中都是一样的。
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
:
如果在选项中设置了“全字”,结果会有所不同,但无论是否在/,/和/或/是否在word_separators中,它们都不会改变:
TL;DR
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).
因此,结论是word_separators仅在双击以选择单词时才有效。使用“查找”对话框或CtrlD(find_under_expand命令)依赖于某些内部分隔符列表,这显然无法更改(请参阅此处的答案)。
A little bit more
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.
我之前忘记添加的一些信息:word_separators也被一些插件用于各种各样的事情,例如创建/修改/以其他方式处理选择,执行可编程完成,查找和替换以及其他类型的东西。
#1
9
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:
从我在回答您的其他问题时的一些非正式实验中可以看出,“word_separators”设置似乎主要与双击选择单词相关。例如,我在文件中有以下单词:
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
我的word_separators列表是./\\()\"'-:,;<>〜!@#%^&*||| {{{}。?!,因此它包括 - 和/但不是_。如果我将光标放在第一个foo中(不先选择整个单词)并点击CtrlD,我就会得到
and if I continue hitting CtrlD for several more times, I get
如果我再继续按CtrlD几次,我明白了
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:
所以只选择了“个别单词” - foo_bar不是,也不是foobar。但是,如果我将word_separators设置为。\\()\“':,; <>〜!@#%^&* | + = [] {}`〜?$(删除 - 和/)我得到相同的结果重复按CtrlD时:
-
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
).
- 和/仍然被视为单词分隔符,即使我从列表中删除它们。如果我将_添加到word_separators列表,结果是相同的,只能得出一个明显的结论:CtrlD(find_under_expand)忽略word_separators。
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:
但是,双击选择单词时使用word_separators列表。使用如下列表:。\\()\“'_:,; <>〜!@#%^&* | + = [] {}`〜?$(缺少 - 和/,但带_),双击每个单词中的foo依次给出以下内容:
Interestingly, double-clicking on the very first foo
gives
有趣的是,双击第一个foo给出了
indicating that the "box" highlighting of similar selections is not paying attention to word_separators
.
表明类似选择的“框”突出显示没有注意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:
使用“查找” - >“查找...”进行搜索时,将忽略word_separators。如果未选择任何内容并且在搜索框中输入了foo(非正则表达式搜索),则会突出显示以下匹配项:
This is the same regardless of whether -
, /
, and/or /
are in word_separators
or not.
无论 - ,/和/或/是否在word_separators中都是一样的。
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
:
如果在选项中设置了“全字”,结果会有所不同,但无论是否在/,/和/或/是否在word_separators中,它们都不会改变:
TL;DR
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).
因此,结论是word_separators仅在双击以选择单词时才有效。使用“查找”对话框或CtrlD(find_under_expand命令)依赖于某些内部分隔符列表,这显然无法更改(请参阅此处的答案)。
A little bit more
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.
我之前忘记添加的一些信息:word_separators也被一些插件用于各种各样的事情,例如创建/修改/以其他方式处理选择,执行可编程完成,查找和替换以及其他类型的东西。