sublime text3设置运行自己的Makefile

版权声明:本文为博主原创文章,转载请注明出处。 https://blog.csdn.net/qq_30650153/article/details/82289246

一、Sublime Text3简介

Sublime Text3:一款具有代码高亮、语法提示、自动完成且反应快速的编辑器软件,不仅具有华丽的界面,还支持插件扩展机制,用她来写代码,绝对是一种享受。相比于难于上手的Vim,浮肿沉重的Eclipse,VS,即便体积轻巧迅速启动的Editplus、Notepad++,在SublimeText面前大略显失色,无疑这款性感无比的编辑器是Coding和Writing最佳的选择,没有之一。

二、C/C++必备插件

  • Package Control 管理插件的插件,必备中的必备
  • Ctags 跳转必备
  • Terminal 当前文件路径打开终端,效率神器
  • BracketHighlighter 括号高亮

三、编译与其快捷键设置 

Linux下许多项目是用makefile来管理的,是用gcc+make等方式来编译和运行。在sublime_text3中调用自己写的Makefile,显著提升效率。

1、自定义build配置脚本

在sublime text3中,
tools—–>build system——>new build system
新建一个配置脚本,比如我取名为rotation.sublime-build

{
        "shell_cmd": "make",
        "file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$",
        "working_dir": "/home/work/xRobot_ts_locat/xRobot_ME/trunk",
        "selector": "source.c, source.cpp",
        "keyfiles": ["Makefile", "makefile"], 
        "variants":
        [
            {
                "name": "Clean",
                "shell_cmd": "make rotation clean"
            },
            {
                "name": "Run",
                "shell_cmd": "make rotation"
            }
        ]
    }

其中"shell_cmd": "make rotation" 为编译命令。

2、定义快捷键

Preferences—–>Key Bindins修改右侧的User设置(左边全部拷贝过来)
修改为:

{ "keys": ["f7"], "command": "build" },
{ "keys": ["ctrl+b"], "command": "build" },
{ "keys": ["ctrl+shift+b"], "command": "build", "args": {"variant": "Run","select": true} },
{ "keys": ["ctrl+break"], "command": "cancel_build" },

猜你喜欢

转载自blog.csdn.net/qq_30650153/article/details/82289246