Sublime Text 3配置C++编译运行

2016.9.8更新:

linux(Ubuntu16.04)下的配置,编译后用终端运行,解决了不能输入的问题

{
    "encoding": "utf-8",
    "working_dir": "$file_path",
    "shell_cmd": "g++ \"$file_name\" -o \"$file_base_name\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "selector": "source.c++",
 
    "variants": 
    [
        {    
        "name": "Run",
        "shell_cmd": "g++ '$file' -o '$file_base_name' && gnome-terminal -x bash -c \"'${file_path}/${file_base_name}';read -p '\nPress any key to continue...'\""
        }
    ]
}

 

 

————————

因为喜欢Sublime Text 3 的高亮配色,于是想在这里写程序。从emacs配置时连配置文件在哪都不知道到vim配置了半天很有成就感,我对配置文件算是更了解了。不过Sublime Text 3 没那么麻烦。配置C++编译运行的方法大概就是配置一个Build System。在cmd窗口运行且解决了中文乱码问题的c++编译配置如下:

{
    "encoding": "utf-8",
    "working_dir": "$file_path",
    "shell_cmd": "g++ -Wall -std=c++11 -fexec-charset=GBK \"$file_name\" -o \"$file_base_name\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "selector": "source.c++",
 
    "variants": 
    [
        {    
        "name": "Run",
            "shell_cmd": "g++ -Wall -std=c++11 -fexec-charset=GBK \"$file\" -o \"$file_base_name\" && start cmd /c \"\"${file_path}/${file_base_name}\" & pause\""
        }
    ]
}

 

posted @ 2016-09-02 23:47  水郁  阅读(4182)  评论(1编辑  收藏  举报
……