PyCharm中Ctrl+F仅匹配完整字符串,如何开启子串搜索?
PyCharm 文件内全子串搜索设置方法
你的问题是因为PyCharm默认开启了「仅匹配整个单词」的搜索模式,导致无法匹配子串。按照以下步骤修改设置即可:
- 按下Ctrl + F打开文件内搜索框
- 点击搜索框右侧的齿轮图标,取消勾选Match Whole Words Only(仅匹配整个单词)选项
- 快捷操作:搜索框激活时,按Option + W(macOS)可快速切换该模式
- 重新输入子串(如
_cfg、time),即可找到所有包含该子串的内容
如果需要精准匹配结尾的内容(比如以_cfg结尾的变量),可以启用正则表达式模式:
- 同样打开搜索选项,勾选Regex
- 输入
_cfg$即可匹配所有以_cfg结尾的字符串,time$则匹配以time结尾的导入语句
环境信息
PyCharm 2023.3.4 (Community Edition)
Build #PC-233.14475.56, built on February 26, 2024
Runtime version: 17.0.10+1-b1087.17 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.3.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 16
Metal Rendering is ON
Registry:
ide.experimental.ui=true
Non-Bundled Plugins:
com.chesterccw.excelreader (2024.2.1-233)
Key Promoter X (2023.3.0)
com.dsoftware.ghtoolbar (1.17.0)
com.github.copilot (1.4.18.4775)
net.ashald.envfile (3.4.2)
内容的提问来源于stack exchange,提问作者MickWise
相关产品推荐
相关产品推荐

