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

  • 相关阅读:
    引入包时“”与<>的区别
    Scanners
    一个SQLite数据库的LIKE查询和IN集合查询的代码实例
    @synchronized线程同步互斥锁
    makeKeyAndVisible
    NSString 数字判断
    UILabel UITextField UITextView
    (转载)JAVA SE6.0 中使用SplashScreen
    转帖(http://hi.baidu.com/johnehuang/blog/item/e1e96782a4b04e97f703a6dc.html)
    ce
  • 原文地址:https://www.cnblogs.com/kearon/p/7354888.html
Copyright © 2011-2022 走看看