5

(Noob here, so apologies for the very basic question). Currently I mostly use Sublime Text for editing code. However to compile I alt-tab to MSVC and compile there and then alt-tab again to a file browser and launch my .exe file. I am looking for a way to optimise this and not having to alt-tab all the time.

So first question is: Is there way to make Sublime Text compile a MSVC C++ project ? I know you can press Ctrl-B, but then you have to know how to set-up all the compiler options link all the libraries (and this was a total nightmare for me to do in MSVC, so preferrably I do not have to do this again for some other compiler).

Second question is: Once the .exe is compiled, is there way to make Sublime launch the .exe (now I have to look it up in my file browser each time, which is a huge pain).

mnr
  • 604
  • 2
  • 7
  • 15
  • 1
    If you have a MS solution already this may help with question 1: https://stackoverflow.com/questions/9646776/how-do-i-make-a-build-system-for-sublime-text-2-to-build-msbuild – doctorlove May 17 '19 at 08:51
  • Also it would be nice to consider alternatives like [eclipse](https://en.wikipedia.org/wiki/Eclipse_(software)) . – AKL May 17 '19 at 09:30
  • No eclipse or other IDE's are not really option for me as they do not provide the text editing options that Sublime Text 3 provides (such as vim mode, multiple cursors, all my own scripts and snippets, and so on and so forth) – mnr May 17 '19 at 09:50

2 Answers2

3

For once I do have a solution !

Here it is :

  • You have to be able to create shortcuts in ST to launch an external app I've tried this in ST3
  • You probably have Visual Studio solution at this point, so you need to create a shortcut to start MSBuild.exe
  • Create a shortcut to start your .exe

I found an old script that uses MSBuild to build an old solution like that :

%PATH_TO_MSBUILD%\MSBuild.exe %SLN_ABSOLUTE_PATH% /t:Clean /t:%TARGET% /p:Configuration=%MODE_COMPILATION%

Hope this helps.

SOKS
  • 190
  • 3
  • 11
1

Use MSBuild to trigger a build using your Visual Studio project file. See the examples in the official documentation, e.g.:

MSBuild.exe MyProj.proj -property:Configuration=Debug

Note that you may have to initialize your environment beforehand. See Use the MSVC toolset from the command line for that, e.g. by calling vcvarsall.bat etc.

Acorn
  • 24,970
  • 5
  • 40
  • 69