[Software] Windows build system set up under Sublime Text (backup)

A. Configuration Environment Variables

The / bin path MinGW added at the Path system environment variable.
Command prompt, enter " G ++ -v " test results.

II. Adding build system required documents

1. responsible for errors of judgment, the command prompt is displayed the title of "run.bat"

@echo off
title Running Your Program
if %1==0 (
    timer %2
    exit
)
exit

2. responsible for displaying the program run time, give the wrong feedback "timer.exe"

(Be sure to use the pre-compiled g ++ or other environmental IDE less cpp files, time display portion can configure itself, the dividing lines and the like can also be adjusted according to the width of the window command prompt)
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <conio.h>
#include <Windows.h>
using namespace std;

clock_t st,en;
int ret;

void get_time()
{
    SYSTEMTIME time;
    GetLocalTime(&time);
    printf("%4d/%02d/%02d %02d:%02d:%02d.%03d\n",
        time.wYear,
        time.wMonth,
        time.wDay,
        time.wHour,
        time.wMinute,
        time.wSecond,
        time.wMilliseconds
        /*time.wDayOfWeek*/);
}

void write()
{
    printf("\n------------------------------------------------------------\n");
    printf("Finish Time: ");
    get_time();
    en=clock();
    printf("Process exited after %.4f seconds with return value %d\n",(double)(en-st)/CLOCKS_PER_SEC,ret);
    printf("Press any key to continue...");
    getch();
}

int main(int argc,char const *argv[])
{
    if(argc!=2){cout<<"ERROR!"<<endl;return 0;}
    
    string argv1=argv[1];
    argv1="\""+argv1+"\"";
    cout<<argv1<<endl;
    printf("Build Time: ");
    get_time();
    st=clock();
    printf("------------------------------------------------------------\n\n");
    ret=system(argv1.c_str());
    
    write();
    return 0;
}

3. The path above the "run.bat" and "timer.exe" into the environment variable among ensure that calls run

Three .sublime internal compiler system configuration

Here will be used .sublime-build file, save the following json content to " C: \ the Users \ Administrator \ AppData \ Roaming \ Sublime Text 3 \ Packages Standard Package \ the User " (path according to the actual situation modifications "Administrator" of content), the interface can be changed to save their own file name, this will be the name of the build system, I used MyCpp this name.
{
    "cmd": ["g++", "${file}", "-o","${file_path}/${file_base_name}"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:?(.*)$",
    "working_dir": "${file_path}",
    "encoding":"cp936",
    "selector": "source.c++",
    "shell_cmd": "g++ \"$file\" -o \"$file_base_name\" && start run.bat %ERRORLEVEL% \"${file_path}/${file_base_name}\"",
}

IV. To enjoy the fruits of customized configuration

1. finished, break with the usual plug-in installation

Enter Sublime Text 3, hold down the keyboard " Ctrl + the Shift + P ", enter " pcip " (Short for "Package Control: the Install Package Penalty for"), if not installed too Package Control Options follow " the Install Package Control installation." Then wait a while you should see a screen like this:

Package Control Interface

At this point we want to install the following plug-ins, search the search box above, enter wait can be installed (if not found for a long time also install your ownFanQiangInstallation), comprising:

(1).ChineseLocalizations

After installing the language replacement at the top of the edit bar "help-language"

(2).ConverntToUTF-8

This is a plug-in conversion support UTF-8 encoding format.

(3).GBK Support

This is a Chinese garbled solve GBK encoding format support plug-ins.
Other
such as colors theme "Theme - XXX" or color scheme "XXX Color Scheme", of course, you can also install other himself.

About crack

Sublime text about the different versions of the hack is different, if not break there will not be much impact, please try to support genuine, it is not your own Baidu.

2. shortcut keys

Always press " Ctrl + B " to compile too much trouble? It does not matter, Sublime Text supports custom keyboard shortcuts.
Go to " Preferences - shortcut keys " to find { "keys": ["ctrl+b"], "command": "build" }this line, in front of the "ctrl + b" enjoy to change their habits keys. (To avoid conflicts, a new recommended .sublime-keymap --User, change the code copied into the saved separately)

3. Other common operations (currently it so much)

Looking for: ctrl + F
Alternatively: ctrl + H
Command window: ctrl + shift + P
Marquee All the same variable name: Alt + F3
Notes: ctrl + /
Switching a plurality of code labels: ctrl + tab
Split Screen: Alt + shift + number (the row number is above the keyboard, the screen indicates how many blocks of points)
Folding a plurality of rows: ctrl + J (destroy artifacts someone else's code)
Folding Code: ctrl + shift + [
Expand Code: ctrl + shift +]

The results show:

First, change the build system (choose according to their own name):

Then write the code, use the shortcut key to compile the following results:

Guess you like

Origin www.cnblogs.com/wjsoj/p/11565328.html
Recommended