Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Sublime Text 3, how do you enable Autocompletion of HTML in JSX

In Sublime Text 3, I have the Babel package for syntax highlighting of HTML code in JSX.

However the HTML code does not have auto-completion, such as those wrapped inside the render() block. How can we enable auto-completion for the HTML codes?

like image 819
Nyxynyx Avatar asked May 20 '16 13:05

Nyxynyx


People also ask

How do I enable autocomplete in Sublime Text?

Usage. By default, Sublime Text will automatically show the completions popup when a user is editing source code or markup, but not within prose in comments, strings or markups. Pressing the Esc key will hide the completions popup. To manually show the completions popup, press Ctrl+Space.

How do I turn off autocomplete in sublime?

So, to disable Python syntax autocomplete: open the command palette with ctrl + shift + P. enter Package Control: Remove Package and select it. enter Jedi and remove the Jedi autocomplete package.


1 Answers

You need the Emmet plug-in to have autocompletition within JSX components.

Use your package controller to install Emmet. Among other Emmet capabilities, just after writing the name of a tag, by pressing Ctrl+E it will be transformed into a opening-closing tag pair. If you want to use the Tab button, you'll need to modify the basic Emmet configuration by adding into Package Settings -> Emmet -> Key Bindings (User) a JSON doc like:

[
    {
        keys: ["tab"],
        command: "expand_abbreviation_by_tab",
        context: [
            {
                operand: "source.js",
                operator: "equal",
                match_all: true,
                key: "selector",
            },
            { match_all: true, key: "selection_empty" },
            {
                operator: "equal",
                operand: false,
                match_all: true,
                key: "has_next_field",
            },
            {
                operand: false,
                operator: "equal",
                match_all: true,
                key: "auto_complete_visible",
            },
            { match_all: true, key: "is_abbreviation" },
        ],
    },
];

The Tab autocompletition is not allowed by default to avoid conflicts with inner Sublime Text features, but this script will make Emmet aware of this and will allow autocompletition within the scope of a JSX file

like image 64
Alex Avatar answered Sep 30 '22 16:09

Alex