Ubuntu / Debian / Deepin等 Sublime Text 3 配置C++環境(一鍵編譯&運行,格式化代碼)

來源:互聯網
上載者:User

標籤:複製   file_path   mat   base   alt+   tool   ges   url   port   

配置編譯環境:

進sublime,然後點擊Tools->Build System->New build System

直接用下面的替換

{      "shell_cmd": "g++ ‘${file}‘ -o ‘${file_path}/${file_base_name}‘",      "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",      "working_dir": "${file_path}",      "selector": "source.c, source.c++",        "variants":      [          {              "name": "Build & Run",              "shell_cmd": "x-terminal-emulator  -e bash -c \"g++ ‘${file}‘ -o ‘${file_path}/${file_base_name}‘ ; ‘${file_path}/${file_base_name}‘ ; read -p ‘\nPress ENTER or type command to continue...‘\""          },            {              "name": "Build Only",              "shell_cmd": "g++ ‘${file}‘ -o ‘${file_path}/${file_base_name}‘"          },            {              "name": "Run Only",              "shell_cmd": "x-terminal-emulator  -e bash -c \"‘${file_path}/${file_base_name}‘ ; read -p ‘\nPress ENTER or type command to continue...‘\""          }      ]  }  

  儲存檔案,檔案名稱任意

  每次使用前,我們按Ctrl+shift+B來選擇編譯選項

配置一鍵編譯&運行快速鍵

點擊Preferences->Key Buildings - User

[      { "keys": ["ctrl+d"], "command": "duplicate_line" },      { "keys": ["alt+up"], "command": "swap_line_up" },      { "keys": ["alt+down"], "command": "swap_line_down" },    { "keys": ["f9"], "command": "build", "args": {"variant": "Build & Run"}},]  

  分別是複製代碼,上移,下移,一鍵編譯並運行

安裝格式化外掛程式

首先需要安裝Package Control

點擊View->Show Console,然後輸入

import urllib.request,os; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), ‘wb‘).write(urllib.request.urlopen( ‘http://sublime.wbond.net/‘ + pf.replace(‘ ‘,‘%20‘)).read())

  

安裝成功後,按Ctrl+Shift+P,然後輸入install,選Package Control: Install Package

然後輸入CoolFormat並安裝

點擊Preferences->Browse Packages,然後進CoolFormat,裡面有個Default.sublime-keymap開啟可以修改快速鍵

 

Ubuntu / Debian / Deepin等 Sublime Text 3 配置C++環境(一鍵編譯&運行,格式化代碼)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.