Home Download Buy Blog Forum Support

Auto build when saving a particular file type or buffer?

Auto build when saving a particular file type or buffer?

Postby firefusion on Wed Feb 23, 2011 10:34 am

Question 1
I'd like to auto build .less files or have the option to build just a single buffer on save but no other file types or buffers. I know you can assign the crtl+s key to building but this builds other files i'm working on.

Question 2
I can't get the Build system "Automatic" selection to work for less files. This is what i have in LESS.sublime-bulid...

Code: Select all
{
   "cmd": ["dotless.Compiler.exe", "$file"],
   "selector": "source.less"
}


It output this error...
Code: Select all
[Error 2] The system cannot find the file specified
[Finished]


It works perfectly if I select "LESS" as the build system but just doesn't work for "Automatic".
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Auto build when saving a particular file type or buffer?

Postby jps on Thu Feb 24, 2011 5:00 am

What does the status bar say if you press Ctrl+Alt+P with a less file open?
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Auto build when saving a particular file type or buffer?

Postby firefusion on Thu Feb 24, 2011 6:20 am

Ah it said source.css.less. I've fixed it and it works now. Thanks :)

Any idea with the second question?
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Auto build when saving a particular file type or buffer?

Postby jps on Thu Feb 24, 2011 7:10 am

I'm not sure I understand question 1. Are you asking for a single key that will save the current file (only), and run the build command?
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Auto build when saving a particular file type or buffer?

Postby firefusion on Fri Feb 25, 2011 8:59 am

Ok, I've rethought and what i'd actually like is to assign the building of a particular file in my project to a keybinding. Can I also set project specific keybindings?
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Auto build when saving a particular file type or buffer?

Postby firefusion on Fri Feb 25, 2011 10:06 am

So I'd like something like this to work but it doesn't seem to; it just builds the current file.

Code: Select all
{ "keys": ["ctrl+s"], "command": "build", "args": {"file": "/Users/ME/Dropbox/Projects/mysite/wp-content/themes/mytheme/base.css.less"} }
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Auto build when saving a particular file type or buffer?

Postby jps on Fri Feb 25, 2011 10:17 am

Build systems are just a fancy way of calling the exec command, to do that, just use exec directly, for example: viewtopic.php?f=3&t=1731
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Auto build when saving a particular file type or buffer?

Postby firefusion on Fri Feb 25, 2011 10:39 am

Ok. I've got it to work using that example (see below) but sadly ctrl+s no longer saves the current buffer.

Code: Select all
{ "keys": ["ctrl+s"], "command": "exec", "args": { "cmd": ["dotless.Compiler.exe", "/Users/mypath/base.css.less", "/Users/mypath/base.css" ]} }


I'd like it to save the current buffer and then run the build. Is it possible to combine commands?
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Auto build when saving a particular file type or buffer?

Postby jps on Fri Feb 25, 2011 10:58 am

You'd have to write a plugin to do that
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Auto build when saving a particular file type or buffer?

Postby purplebeanie on Wed Mar 28, 2012 8:39 am

I don't generally resurrect an old thread like this, but after recently moving across to Sublime from Eclipse I was trying to do exactly this.

I ended up writing a plugin to automatically run an Ant script on file save and was amazed at how simple Sublime makes this.

If anyone else is looking for it the script is here:

http://www.purplebeanie.com/Development/automatically-run-build-on-save-in-sublime-text-2.html
purplebeanie
 
Posts: 1
Joined: Wed Mar 28, 2012 8:11 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 38 guests