Sublime Text 2 auto completion popup does not work properly

北战南征 提交于 2019-12-28 05:14:13

问题


I got problem with jQuery Snippet that i installed throughout package control. After installation I do not have popup with jQuery code hints and intalisance. Look at this video:
http://code.tutsplus.com/courses/perfect-workflow-in-sublime-text-2/lessons/adding-snippets-through-package-control

On 0:50 after typing . he got popup with code hints - I don't have this one. I have to type . on and then press Tab to display popup with snippet...
And yes, I'm in JavaScript file and I got default settings.

And after . he also got all jQuery functions like add or addClass. I do not have this one even if I press Ctrl+Space.


回答1:


If you hit CTRL-SPACE you'll get the dropdown of available completions for what you've just typed.

http://www.sublimetext.com/docs/2/tab_completion.html

If you want the autocomplete dropdown to appear as you type then add this line to your User Preferences.sublime-settings file:

{
  "auto_complete_selector": "source, text"
}

That should do what you're looking for :-)




回答2:


Consider changing User Settings to the following:

{
  // By default, auto complete will commit the current completion on enter.
  // This setting can be used to make it complete on tab instead.
  // Completing on tab is generally a superior option, as it removes
  // ambiguity between committing the completion and inserting a newline.
  "auto_complete_commit_on_tab": true,

  // Controls if auto complete is shown when snippet fields are active.
  // Only relevant if auto_complete_commit_on_tab is true.
  "auto_complete_with_fields": true,

  // As Richard Jordan suggested, this item
  // controls what scopes auto complete will be triggered in
  "auto_complete_selector": "source, text"
}

Open your User Settings by pressing Cmd+, on Mac or Ctrl+, on Windows

And if you want to fully grasp Sublime Text 2, I do recommend this course: Perfect Workflow in Sublime Text. It used to be free by the time I first posted this answer. I still recommend it anyways.




回答3:


Which OS are you using? I'm guessing Windows.

The problem here seems to be that the jQuery snippets in the available plugins have <tabTrigger> attributes that start either with a $ or a ., which causes trouble.

Try the following: Find the jQuery package that contains those snippets (Under Preferences -> Browse Packages) and open the .sublime-snippet file of a snippet that doesn't work properly. The one you named in your post would be defined in the file event-on.sublime-snippet.

Find the line

<tabTrigger>.on</tabTrigger>

and remove the . as follows

<tabTrigger>on</tabTrigger>

Save and return to your .js file. Now see if the snippet shows up when you type o. This works for me.

I guess this is a bug in Sublime Text 2 for Windows (maybe Linux, too?), since it obviously works fine on OS X as we see in the video course you've linked.

There was an issue created on GitHub on this specific package and I now commented this info. I guess the only way to get this working is to have snippets that do not start with special characters.

I also filed a bug for Sublime Text on Userecho.




回答4:


The creator of the video is using SublimeCodeIntel. What you see at 00:50 isn't Sublime Text 2's autocompletion popup, it's SublimeCodeIntel's import autocompletion popup:

Imports autocomplete - Shows autocomplete with the available modules/symbols in real time.

See the Github page for more information.



来源:https://stackoverflow.com/questions/12656448/sublime-text-2-auto-completion-popup-does-not-work-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!