How to edit Sublime Text build settings?

后端 未结 1 1103
你的背包
你的背包 2020-11-30 18:28

I want to enable -std=gnu++11 in Sublime Text 3\'s C++ Single File build on Ubuntu 12.04.

I have already upgraded the tool chain to the latest g++ and d

相关标签:
1条回答
  • 2020-11-30 19:16

    edited

    My original answer works, but there's a much better way of doing this, by creating your own build system. This use case is exactly why the feature is there.

    Go to ToolsBuild SystemNew Build System… (all the way at the bottom) and enter the contents below. Save as C++ 11 Single File.sublime-build, and it will now be accessible in the build system menu. Select it, hit CtrlB to build, and then hit CtrlShiftB to run the resulting program.

    {
        "cmd": ["g++", "-std=gnu++11", "${file}", "-o", "${file_path}/${file_base_name}"],
        "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
        "working_dir": "${file_path}",
        "selector": "source.c, source.c++",
    
        "variants":
        [
            {
                "name": "Run",
                "cmd": ["${file_path}/${file_base_name}"]
            }
        ]
    }
    

    If you need to edit it in the future, the file is in the User folder of Packages:

    • Linux: ~/.config/sublime-text-3/Packages
    • OS X: ~/Library/Application Support/Sublime Text 3/Packages
    • Windows Regular Install: C:\Users\YourUserName\AppData\Roaming\Sublime Text 3\Packages
    • Windows Portable Install: InstallationFolder\Sublime Text 3\Data\Packages
    0 讨论(0)
提交回复
热议问题