dkauffman dkauffman - 1 year ago 111
HTML Question

Sublime Text 3: How do I stop flagrantly incorrect tab suggestions?

Where in my settings is autocomplete failing to decipher what it's suggesting? This is obviously syntactically incorrect, I'm inside the quotes for a tag and it's suggesting more tags.


Answer Source

This is due to the way Sublime Text scopes work. Autocompletion is based on the scope of the character immediately to the right of the caret when there is no selection. In your example, it is the " character. It therefore doesn't see that the caret is actually inside the style attribute, because it sees CSS as only what is between the quotes, and not the quotes themselves. Therefore, it suggests other attribute names.

The workaround is simply to ensure there is a space between where you are typing and the closing " character of the attribute value.

demo of caret position importance

EDIT: I have now suggested a fix for this in a PR to the SublimeText Default Packages repo. If it gets accepted, it will be available in the next ST3 build. Alternatively, you can follow the instructions in the repo's Readme to grab the changes sooner.

EDIT: and another PR to make the same fix when typing just before the </style> tag.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download