Hi guys. I’m migrating from E and I’m missing some features. One of that is toggling single/multi line for css properties.
Let’s say this code:
.test {
color:#000;
text-decoration:none;
background:red;
}
After I press a key combination will become
.test {color:#000; text-decoration:none; background:red; }
I know about ctrl+j command, but that will work only one way. Ok, so the code from E is this:
#!/usr/bin/env ruby
if ENV'TM_SOFT_TABS'] == 'NO'
tab = "\t"
else
tab = " " * ENV'TM_TAB_SIZE'].to_i
end
print case str = STDIN.read
# Expand
when /\A\{(.*)\}\z/
"{\n#{tab}" + $1.strip.gsub("; ", ";\n#{tab}") + "\n}"
# Collapse
when /\A\{(.*)\}\z/m
("{" + $1.gsub("\n", " ") + "}").gsub(/\s{2,}/, " ")
# Default case
else str
end
My ruby and py skills are zero, so I don’t even know where to start. However, i did this:
import sublime, sublime_plugin, re
class ToggleSingleLineCommand(sublime_plugin.TextCommand):
def run(self, edit):
Which is… all I know how to do it
Can i get some hints/help/solution?
Thanks!