Sorry for my ignorance. I just started trying SublimeText so far, and like it a lot. But I really want tag closing.
This is what I did:
- Went to Tools > New Plugin, and pasted in this:
import sublime, sublime_plugin, re
class CloseTagCommand(sublime_plugin.TextCommand):
def run(self, edit ):
leftOfCursor = self.view.substr(sublime.Region(0, self.view.sel()[0].begin()))
regex = re.compile('<(/?\w+)^>]*>')
tags = regex.findall(leftOfCursor)
opentags = ]
for tag in tags:
if tag[0] == '/':
if opentags-1] == tag[1:]: opentags.pop()
else: opentags.append(tag)
if len(opentags) > 0:
tag = '</' + opentags-1] + '>'
self.view.insert(edit, self.view.sel()[0].begin(), tag)
I then saved it to the default plugin directory: C:\Users~\AppData\Roaming\Sublime Text\Packages
- I then went to Preference > User Key Bindings, and pasted in the command I found here like this:
<!--
Place your key bindings in here, this will ensure they don't get overwritten
when installing new versions of Sublime Text
-->
<bindings>
<binding key="ctrl+period" command="closeTag"/>
</bindings>
Hitting Ctrl + . does not do anything though. And nothing shows up in the console when I do.
How can I make this work? Thanks