Sublime Text 3配置C++編譯運行

2016.9.8更新:linux

linux(Ubuntu16.04)下的配置,編譯後用終端運行,解決了不能輸入的問題c++

{
    "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...'\""
        }
    ]
}

 

 

————————shell

由於喜歡Sublime Text 3 的高亮配色,因而想在這裏寫程序。從emacs配置時連配置文件在哪都不知道到vim配置了半天頗有成就感,我對配置文件算是更瞭解了。不過Sublime Text 3 沒那麼麻煩。配置C++編譯運行的方法大概就是配置一個Build System。在cmd窗口運行且解決了中文亂碼問題的c++編譯配置以下:vim

{
    "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\""
        }
    ]
}
相關文章
相關標籤/搜索