简体   繁体   English

崇高的文字2 HTML自动完成产生奇怪的结果

[英]sublime text 2 html auto complete produces odd result

If my cursor is placed after an html closing tag and I press enter, I get a popup auto-completion suggestion as follows: 如果将光标放在html结束标记之后,然后按Enter键,则会显示如下弹出自动完成建议:

p> (element) p>(元素)

If I press enter again p> is printed on the screen. 如果我再次按Enter键,则会在屏幕上打印p>。

This is annoying and I want to prevent it but how? 这很烦人,我想阻止它,但是如何呢? I have already tried setting auto_complete to false in user preferences but that did not work. 我已经尝试在用户首选项中将auto_complete设置为false,但这没有用。

There is complete description for Auto Completion on there site as 在该网站上,完整的自动完成描述为

Disabling Auto Complete 禁用自动完成

Auto complete can be disabled with the auto_complete setting. 可以使用auto_complete设置禁用自动完成功能。 To disable it, add this line to Preferences/File Settings - User: 要禁用它,请将此行添加到“首选项/文件设置-用户”:

"auto_complete": false If auto complete is disabled, the completion popup can be shown manually, or tab can be used to insert the highest ranking completion without showing the popup. “ auto_complete”:假如果禁用了自动完成,则可以手动显示完成弹出窗口,或者可以使用Tab键插入最高排名的完成而不显示弹出窗口。

Manually Showing Completions 手动显示完成

Pressing Ctrl+Space will show the completion popup if it's not currently showing. 如果当前未显示完成,请按Ctrl + Space将显示完成弹出窗口。 If it is showing, it'll select the next item. 如果显示,它将选择下一个项目。

Commit on Tab 在标签上提交

By default, the selected item in the completion popup will be committed when enter is pressed. 默认情况下,按Enter键将提交完成弹出窗口中的选定项目。 This can create ambiguity between committing the completion, and inserting a newline. 这会在提交补全和插入换行符之间造成歧义。 By setting the auto_complete_commit_on_tab setting to true, enter will insert a newline, and tab will commit the current completion. 通过将auto_complete_commit_on_tab设置设置为true,enter将插入换行符,而tab将提交当前完成。 There are other benefits, too: because Sublime Text knows there is no ambiguity, it will show a more curated list of completions, with the one you want more likely to be in first place. 还有其他好处:因为Sublime Text知道没有歧义,所以它将显示更多精选的完成列表,而您希望的列表更可能排在第一位。

Enabling Commit on Tab is recommended, but it will take a short time to get used to. 建议启用“在选项卡上提交”,但要花一点时间才能习惯。

Source : Sublime 2 Auto Complete 来源: Sublime 2自动完成

Hope this helps. 希望这可以帮助。

Answer in short (worked for me): Remove SublimeCodeIntel package. 简短的答案(对我有用):删除SublimeCodeIntel软件包。

After searching some more, I found that this is actually a long standing problem (7 months). 经过更多搜索后,我发现这实际上是一个长期存在的问题(7个月)。 The problem is posted on github as issue #279 and issue #359 . 该问题在github上发布为Issue #279和Issue #359 Still not sure how to fix it exactly though (Without removing the package). 仍然不确定如何准确地修复它(无需删除软件包)。

Long answer: 长答案:
I was having the same problem you describe and it also annoyed me. 我遇到了与您描述的问题相同的问题,这也使我很烦。
For me the problem was coming from the Sublime​Code​Intel package that I installed in Sublime Text, so I guess you also have this package installed, causing this problem. 对我来说,问题来自于我在Sublime Text中安装的Sublime Code Intel软件包,所以我想你也已经安装了此软件包,从而导致了这个问题。 I'm using ST version 3, but I guess there should be no difference to version 2 regarding this issue. 我使用的是ST版本3,但我认为就此问题而言,版本2应该没有什么区别。

Although the answer by Jatin seems to be a work-a-round, (disabling the auto_complete will just mask the problem, what if you want to keep auto_complete on true), when I actually set auto_complete to false, I was still getting the auto_complete pop-up. 尽管Jatin的回答似乎是一个解决方案,(禁用auto_complete只会掩盖问题,如果您想将auto_complete保持为true怎么办),当我实际上将auto_complete设置为false时,我仍在获取auto_complete弹出。 After some thought, my guess was because of the Sublime​Code​Intel package I had installed. 经过一番思考,我的猜测是因为我安装了Sublime Code Intel软件包。

So I removed the Sublime​Code​Intel package and behold, no popup auto-completion with the "p> (element)" suggestion. 所以我删除了Sublime Code Intel软件包并发现,没有弹出自动完成的``p>(element)''建议。

Of course, removing SublimeCodeIntel may also seem a bit of a drastic solution. 当然,删除SublimeCodeIntel似乎也有些棘手的解决方案。 Maybe the package can be configured in such a way that the problem does not occur any more. 也许可以以不再出现问题的方式配置软件包。 I haven't looked into the problem why SublimeCodeIntel displays this incorrect auto complete suggestion. 我尚未研究SublimeCodeIntel为什么显示此错误的自动完成建议的问题。 It might be good to send a bug report to the author of the package? 将错误报告发送给软件包的作者可能会很好? (At the moment I'm happy enough to just remove the package) (目前,我很高兴只需要删除软件包)

You can disable the languages that CodeIntel autocompletes for. 您可以禁用CodeIntel自动完成的语言。

The default setting is: 默认设置为:

"codeintel_enabled_languages":
[
   "JavaScript", "SCSS", "Python", "HTML",
   "Ruby", "Python3", "XML", "Sass", "HTML5", "Perl", "CSS",
   "Twig", "Less", "Node.js", "TemplateToolkit", "PHP"
],

Override the settings in your User Settings by removing the HTML and HTML5 items (paste this into your User Settings: Go to Preferences -> Package Settings -> SublimeCodeIntel -> Settings - User ): 通过删除HTML和HTML5项来覆盖用户设置中的设置(将此粘贴到用户设置中:转到“首选项”->“程序包设置”->“ SublimeCodeIntel”->“设置”-“用户” ):

{
    "codeintel_enabled_languages":
    [
       "JavaScript", "SCSS", "Python",
       "Ruby", "Python3", "XML", "Sass", "Perl", "CSS",
       "Twig", "Less", "Node.js", "TemplateToolkit", "PHP"
    ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM