Sublime Text 2 build via simple batch file

2019-03-25 03:30发布

I've been playing a bit with ST2 and it seems like a pretty cute editor. Unfortunatelly, its documentation is horrible.

And I'm being nice. So here's my question.

I have five files in a directory, which I usually build via a .bat file with

ifort file1.f90 file2.f90 file3.f90 ...

how can I define and execute this line on windows cmd (taking account the enviromental variables like PATH) from ST2 via a shortcut and see the output? Is something like that even possible at this stage with ST2?

2条回答
男人必须洒脱
2楼-- · 2019-03-25 04:19

I just made a new build like this:

{
    "cmd": ["$file"],
    "selector": "source.dosbatch"
}

Then you would put your ifort ... string in a .bat file and "build" that.

查看更多
Explosion°爆炸
3楼-- · 2019-03-25 04:19

Here's a step by step way to run a batch file as part of your build process:

In Sublime Text 2 go to Tools -> Build System -> New Build System

You'll be presented with a new text file with the following code in it:

{
"cmd": ["make"]
}

Now change the "make" to the exact path of your batch file so it looks something like this:

{
"cmd": ["D:\\xampp\\htdocs\\myproject\\dostuff.bat"]
}

Notice you must use double backslash for windows paths.

Then save this file out as myproject.sublime-build in the default directory it asks you to save it in (should be $HOME_DIR/AppData/Roaming/Sublime Text 2/Packages/User).

Then in your project go back to Tools -> Build System and select the build system that is the same name as the file you just created (in this case it's "myproject").

Hit ctrl + b or go to tools -> build and your batch file should run and output will appear in the ST2 console.

查看更多
登录 后发表回答