Sublime plugins
Last Updated on Thursday, 12 January 2012 09:07am Written by spunky Thursday, 12 January 2012 09:07am
Useful plugins for Sublime Text editor:
Convert a block of text to a single line:
import sublime, sublime_plugin, re
# toggle a single-line or multi-line formatted css statement
class ToggleSingleLineCssCommand(sublime_plugin.TextCommand):
def run(self,edit):
for region in reversed(self.view.sel()):
text = self.view.substr(region)
# check if the css statement needs to be expanded or collapsed
if re.match('^.*\{.*}\s*$', text):
# expand the css statement
m = re.search('^(?P.*)\{(?P
.*)\;\s*}$', text)
multiline = '%s{\n\t%s;\n}' % (m.group('key'), m.group('params').strip().replace('; ', ';\n\t'))
self.view.replace(edit, region, multiline)
else:
# collapse the css statement
singleline = ' '.join([x.strip() for x in text.split('\n')])
self.view.replace(edit, region, singleline)
Leave a Reply
Site Search
Tags
ajax contact form
anahita
anahitapolis
anxious
api
backlink
back link
backlinks
back links
black hat seo
blame
build from nothing
captcha
cms
contribute
culture
email form
environment
equality
forum posting
frustrated
fulfilment
grateful
happiness
joomla
jquery
jquery validate
locality
location
mysql
php
phpmailer
product of environment
reasons and meaning
recompile table id
recount table id
recreate table id
reset table id
search engine marketing
simple contact form
social engine
social management system
society
update variable example
white hat seo