简体   繁体   中英

How do I stop Sublime Text from going out of the tag on tab (after autocomplete)?

I set my autocompletion to happen on Tab . So if I type: div.control-group and hit tab, it accurately turns into <div class="control-group"></div> and places the cursor inside.

However, when I type label and hit Tab next ( <div class="control-group">label</div> ), instead of autocompleting the <label> tag, the cursor is placed after the </div> . I need to go back inside the tag again and repeat the Tab hit for it to properly autocomplete.

How do I fix this?

Looking at the Default.sublime-keymap file, I found these lines:

{ "keys": ["tab"], "command": "next_field", "context":
        [
            { "key": "has_next_field", "operator": "equal", "operand": true }
        ]
    }

I didn't want to mess with that, because jumping to the next field is a useful feature when working with autogenerated foreach loops and such.

Instead, I found this:

{ "keys": ["alt+/"], "command": "auto_complete" }

So now, when I am inside the generated tag, I use Alt + / key combination to autocomplete, instead. Slightly more inconvenient, but I get to keep Tab 's behavior intact and useful, for the most part.

I'm guessing you are using Emmet (or another plugin) to build the "div" snippet. It may also be worthwhile to see if you can configure how the snippet is generated. That is, you might be able to generate it and not specify additional cursor locations. That way, at least for the plugin expansions, you wouldn't have the issue with tab.

You may also want to try setting auto_complete_with_fields to true in your user settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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