Sublime Forum

Advanced use of build selector

#1

Hi,

Is it possible to use the selector field of a sublime build to distinguish between files in two (or more) folders instead of just the extension?

I have 3 JavaScript projects (in 3 distinct folders) that build with a different script. Currently I have to go to the menu to switch (which is somewhat annoying). Ideally I would like that when I press Ctrl+B the script correspondent to the project where the current file is in would run.

(I don’t always run the 3 scripts because that is way too slow.)

Best regards,
Luis

0 Likes

#2

Couldn’t you use the per project Build Systems ? http://www.sublimetext.com/docs/2/projects.html

0 Likes

#3

I think that some clarification is in order. When I said 3 projects what I really meant was one project with 3 folders (sorry). I have this because it is not possible to have more than one project opened at a time (I think).

0 Likes

#4

OK, I don’t think that what you ask is possible.

But you can write a single sublime-build file and use variants for your 3 different build:
http://docs.sublimetext.info/en/latest/reference/build_systems.html

The variants are available from the Command Palette with the prefix "Build: ".
Additionally, you can create a keybinding to open the Command Palette with the prefix already typed, this way you have a kind of build menu (what I’ve done myself).

If you want something more advanced, you probably have to write a plugin yourself and use it as “target” command in your sublime-build file.
This way you can do whatever you want.

0 Likes

#5

It is possible to have multiple projects open at once.

You may need to open a new window first: File, New Window, or Ctrl+Shift+N

Then open an existing project in the new window: Project, Open Project or Recent Projects

0 Likes

#6

The variants option seems nice but I can’t get it to work :frowning:

I have configured the build file as instructed in the example on the link you sent (with the names on the variant elements) but nothing appears in the command palette (by nothing I mean not event a build command is available on the list). I have selected the project with the variants in the menu and even tried to add “selector”: “source.js” to the build configuration. Do I need to do anything else?

(Also, yes I could have the project open in another window, but the switching would be annoying…)

0 Likes

#7

What’s your ST2 build ?
You probably don’t have Build 2197 or later.

0 Likes

#8

Your are right! I have the build 2181… I’m going to update it and report back.

0 Likes

#9

The current version in sublimetext.com/2 is 2181… I need to purchase a licence to have the updates?

0 Likes

#10

You can try the development version without a license sublimetext.com/dev
The nightly however does require a license.

0 Likes

#11

Hum, ok. I think I will wait for the next stable version then. Thanks!

0 Likes

#12

Your choice.
Note that dev build are usually as stable as stable build.

0 Likes