Sublime Text 添加C/C++環境


輕巧便捷的sublime text 3代碼編輯功能非常強大,不過作為一款代碼編輯軟件,我們要是讓它能把我們的c或者c++代碼run起來,變成一個輕量級編譯器那就更好了!今天來給大家說一下怎么在sublime下配置c/c++,使它能run C和C++的代碼 (附Sublime下載地址:Sublime Text 3))[http://www.sublimetext.com/]

首先,我們要有一個編譯器,如果你已經有了CodeBlocks或者Dev-C++,那么直接看下一步就好了。如果沒有的話,我們需要先下載一個編譯器,這里是 (MinGW的下載地址:MinGW)[http://www.mingw.org/]

安裝mingw

配置環境變量。找到你的MinGW安裝路徑下的bin文件夾,配置環境變量

配置sublime,打開sublime,點擊Tools→Build System→New Build System

{
    "cmd": ["g++", ,"-Wall","${file}", "-o", "${file_path}/${file_base_name}"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
    "encoding":"cp936",
    "variants":
    [
    {
    "name": "Run",
    "cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "cmd", "/c", "${file_path}/${file_base_name}"]
    },
    {
    "name": "RunInCommand",
    "cmd": ["cmd", "/c", "g++", "-Wall","${file}", "-o", "${file_path}/${file_base_name}", "&&", "start", "cmd", "/c", "${file_path}/${file_base_name} & echo.&pause"]
    }
    ]
}

配置編譯快捷鍵

[
	{"keys": ["ctrl+F11"], "command": "build", "args": {"variant": "RunInCommand"}}
]

sublime 沒有Debug


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM