Sublime Forum

Autocomplete not working at all with simple HTML

#1

H there
I’m new to coding and have just started using Sublime. I cannot get it to autocomplete at all. I’ve tried various ideas from a Google search but none seem to help, including changing the user file in preferences as suggested here:
https://www.granneman.com/webdev/editors/sublime-text/top-features-of-sublime-text/auto-completion-in-sublime-text
but all to no avail.
I’m running the most up to date version and the package is unregistered.
Would love some help if anyone’s got any idea!
Kirsty

0 Likes

#2

By latest version you mean 3211?

Builtin auto completions complete tags only. It doesn’t provide attribute names atm.

  1. To complete those just type < followed by the first character of the tag you want.

    Animation

  2. You can also just type the tag name and hit tab key.

    Animation

  3. You can wrap existing text into tags by selecting it and pressing alt+shift+w

    Animation

Note: tag name completion doesn’t work very perfect while editing wrapped tags. That has been fixed in ST4.

  1. Also auto adding closing tags works out of the box by just typing </.

The screencasts are made with ST 3211 vanilla setup. No plugins, no custom settings.

If you need more sohpisticated completions, you may want to try LSP and LSP-html packages. The former is a general Language Server Client for Sublime Text and the latter one is a helper to install/manage an html language server. It needs nodejs being installed.

If you are new to ST the following youtube channel may provide some useful stuff to learn about the power of ST: https://www.youtube.com/c/OdatNurd

3 Likes

St have auto complete buit-in for HTML and CSS?
#3

Thanks so much for that.
Yes I do mean 3211. It’s not completing tags at all - not behaving as your response indicates.
I just deleted it and downloaded it again and it’s still not working.

When I open a file I get an error message.

Error trying to parse settings: Unexpected trailing characters in Packages/User/Preferences.sublime-settings:8:1

Not sure what that means or if it affects the problem I’m having.
I looked in preferences thinking there might be some error there I could recognise but I don’t see anything.

Here’s what I could find about user preferences:
{
“ignored_packages”:
[
“Vintage”
]
}
// Enable auto complete to be triggered automatically when typing.
“auto_complete”: true,

// The maximum file size where auto complete will be automatically triggered.
“auto_complete_size_limit”: 4194304,

// The delay, in ms, before the auto complete window is shown after typing
“auto_complete_delay”: 50,

// Controls what scopes auto complete will be triggered in
“auto_complete_selector”: “source - comment”,

// Additional situations to trigger auto complete
“auto_complete_triggers”: [ {“selector”: “text.html”, “characters”: “<”} ],

// 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”: false,

I saw on the Sublime site that you can download for free but to continue using it you need to buy a license. Maybe that’s the problem? What do you think?
https://www.sublimehq.com/store/text

Hope you can help.

Thank you!

0 Likes

#4

Maybe that’s the problem? What do you think?

ST doesn’t limit features if no license is entered.

I just deleted it and downloaded it again and it’s still not working.

Just reinstalling can’t most likely solve such issues as it does not touch the settings folders, IIRC.

ST stores all settings and states in your user profile. Depending on OS it is located at ~/.config/sublime-text-3 or %APPDATA%\Sublime Text 3.

If something behaves weird and may look like a bug it is often a good idea to just temporarily rename those directories to let ST start in a clean state. If an issue persists, it’s most likely a core bug then, if not the journey of finding the causing package/plugin begins.

Error trying to parse settings: Unexpected trailing characters in Packages/User/Preferences.sublime-settings:8:1

It says, it found an error at line 8.

{
  "ignored_packages":
  [
    "Vintage"
  ]
} <- end of config file!!!!

... <- your settings

Your settings are placed outside of the JSON dictionary, which is not allowed.

Producing such parse errors doesn’t stop auto completions from working on my machine though.

You may want to try PackageDev. It supports editing all kinds of Sublime Text resource files by providing completions etc. It’s an must have package, IMHO.


Did you make sure to manually set syntax to HTML or save the file with HTML extension?

If you just create a new file syntax is Plain Text and HTML completions are not enabled.

Syntax is displayed on the right end of the status bar.

1 Like

How to start auto-completion?
#5

Thank you so much for your help. I’m gonna confess to the error even though it’s kind of embarrassing. I had not saved the file with the html extension. Thanks to your suggestion to save it, it now works. Thank you for taking the time to help.
I cannot get back the afternoon I spent on this but I will not make this mistake again!

0 Likes