is there any plugin to autoclose html elements? for example: as i type <html> this tag need to be closed as </html> automatically.
thank you.
bizoo wrote:In a recent build:
Menu: Edit -> Tag -> Close Tag (Alt+.)
div<div></div> // Auto close tags
{ "keys": [">"], "command": "auto_close_tag", "args": { "prefix": ">"}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html meta.tag -string -punctuation.definition.tag.begin.html -meta.scope.between-tag-pair.html, text.xml meta.tag -string -punctuation.definition.tag.begin.xml -meta.scope.between-tag-pair.xml", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "(?:\\<(?:img|br|hr|meta|link|base|input)\\>[^<]*)|/$" }
]
},
// Line and Tab when hitting enter between tags
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true},
{ "key": "selector", "operator": "equal", "operand": "meta.scope.between-tag-pair"}
]
},
import sublime, sublime_plugin
class AutoCloseTagCommand(sublime_plugin.TextCommand):
def run(self, edit, prefix=""):
self.view.run_command('insert', {'characters': prefix})
cursorPosition = self.view.sel()[0].begin()
self.view.run_command('close_tag')
self.view.sel().clear()
self.view.sel().add(cursorPosition)
grayrest wrote:Here's what I have in User:
…
autoclose_tags.py:
Users browsing this forum: Crasher, Google [Bot] and 7 guests