Sublime 解决 Anaconda 模块自动补全问题(转载)
声明:本文内容为转载,原文地址:https://zhuanlan.zhihu.com/p/34673051
问题:
在Sublime中安装了Anaconda后,再导入模块(module)的时候只能显示出当前的模块而不能像语法一样随着输入的字母自动补全。
原因:
官方这么说:
Auto-complete for import behaves badly.
Sublime Text 3's default Python package cancels the auto-completion when some words are detected (for example def or class). This list of words includes import.
Work-around: Create a new Python directory in your Packages directory and copy the contents of the file Completion Rules.tmPreferences there with the same name. Delete your Sublime Text Cache file Cache/Python/Completion <code>Rules.tmPreferences.cache</code>.
翻译:
Sublime Text 3 的默认Python包会在检测到某些词语(比如def或class)的时候取消自动补全。“import”就在这个取消自动补全的关键词列表里。
解决办法:
- 在插件目录 Packages 里新建目录 Python
- 新建文件并将其命名为 Completion Rules.tmPreferences (中间有空格),其内容为:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>scope</key> <string>source.python</string> <key>settings</key> <dict> <key>cancelCompletion</key> <string>^(.*\b(and|or)$)|(\s*(pass|return|and|or|(class|def)\s*[a-zA-Z_0-9]+)$)</string> </dict> </dict> </plist>
3. 重启Sublime即可成功解决:
posted on 2020-06-30 15:53 blackangeldsf 阅读(774) 评论(0) 收藏 举报

浙公网安备 33010602011771号