Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3 build system: keep console running

I set up a build system in Sublime Text 3 to run Matlab files. This works really fine:

{ "cmd": ["/usr/local/MATLAB/R2013b/bin/matlab", "-nosplash", "-nodesktop", "-nojvm", "-r \"run('$file');\""] }

The problem is I want to keep Matlab running in the Sublime console after $file is executed. Is this possible?

Thank you in advance.

like image 514
Eli Duenisch Avatar asked Apr 26 '14 11:04

Eli Duenisch


People also ask

How do I stop Sublime Text from running an infinite loop?

You want to use Ctrl + Break . For your own information, just go check under Tools in Sublime Text and you'll see Cancel Build and the above hotkey. It'll work just fine for infinite loops.

How do I open the console in Sublime Text 3?

For Sublime Text 3 on a Windows machine and using an azerty keyboard, CTRL+! is the shortcut that works for me. Save this answer.

How do I set build commands in Sublime Text?

Sublime Text is able to run build programs such as 'make', either when a key in pressed (F7 by default), or when a file is saved. The build system to use can be select from the Tools/Build System menu. If a project is open, the selected build system will be remembered for the project.

How do I change the Build System in Sublime Text 3?

Select it, hit Ctrl B to build, and then hit Ctrl Shift B to run the resulting program. Or you can use a Build and Run option and call it by hitting Ctrl B , then selecting that option.


1 Answers

Ok, I've finally found a solution that runs the build system in an external xterm terminal. If you use this Sublime will open a xterm window and execute the build system there. This window remains open, so e.g. Matlab plot windows will not be closed after execution of the code. I've combined the build system with and without the external terminal into one build system:

{
    "cmd": ["/usr/local/MATLAB/R2013b/bin/matlab", "-nosplash", "-nodesktop", "-r \"run('$file');quit;\""],
"selector": "source.m",

"variants": [
    { 
        "name": "xterm",
        "cmd": ["xterm", "-e", "/usr/local/MATLAB/R2013b/bin/matlab", "-nosplash", "-nodesktop", "-r \"run('$file');\""]
    }
]
}

and then assigned a user key binding to access the xterm variant easily:

[
{ "keys": ["ctrl+shift+b"], "command": "build", "args": {"variant": "xterm"} }
]

This xterm solution should also work with any other interpreter that you want to prevent from being closed after code execution finishes.

like image 199
Eli Duenisch Avatar answered Nov 09 '22 22:11

Eli Duenisch