zoukankan      html  css  js  c++  java
  • Ubuntu / Debian / Deepin等 Sublime Text 3 配置C++环境(一键编译&运行,格式化代码)

    配置编译环境:

    进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 '
    Press 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 '
    Press 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打开可以修改快捷键

  • 相关阅读:
    SEVERE: One or more listeners failed to start.
    springboot junit单元测试报错
    mybatis 日期查询datetime
    设计模式详解之程序设计六大原则
    非maven项目 idea project structure
    jdbcType DATE和TIMESTAMP区别
    mysql 保存23:59:59 自动加一秒
    1、在linux服务器centos虚拟机搭建nginx网站
    QRCode 生成二维码
    CSS3的calc()使用
  • 原文地址:https://www.cnblogs.com/kearon/p/7354888.html
Copyright © 2011-2022 走看看