본문 바로가기

[자유]

[MAC] Visual Studio Code for Mac

728x90

1 . 아래의 링크에 접속하여 Mac용 Visual Studio Code 파일을 다운받는다.

https://code.visualstudio.com/download

 

Download Visual Studio Code - Mac, Linux, Windows

Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications.

code.visualstudio.com

 

2 .  (선택) 언어를 한국어 팩으로 바꾸고 싶을 경우 

 

 

        단축키  command(⌘) + shift + x  를 누르고 한국어 팩을 설치해준다.

 

한국어 확장팩 설치

 

3 . 프로젝트를 생성하고 cpp파일을 저장해준다.

 

프로젝트 폴더 만들고 cpp 파일 생성

 

3 . 코드 컴파일 및 실행 가능하도록 task.json 수정

 

 ● Visual Studio Code의 메뉴에서 터미널 -> 기본빌드 작업구성 

 

'템플릿에서 tasks.json 파일 만들기' 선택

 

● 'Others' 선택

 

● task.json 파일을 아래의 코드로 변경한다.

{
    "version": "2.0.0",
    "runner": "terminal",
    "type": "shell",
    "echoCommand": true,
    "presentation" : { "reveal": "always" },
    "tasks": [
          //C++ 컴파일
          {
            "label": "save and compile for C++",
            "command": "g++",
            "args": [
                "${file}",
                "-std=c++11",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "group": "build",

            //컴파일시 에러를 편집기에 반영
            //참고:   https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher

            "problemMatcher": {
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    // The regular expression. 
                   //Example to match: helloWorld.c:5:3: warning: implicit declaration of function 'prinft'
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        //C 컴파일
        {
            "label": "save and compile for C",
            "command": "gcc",
            "args": [
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "group": "build",

            //컴파일시 에러를 편집기에 반영
            //참고:   https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher

            "problemMatcher": {
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    // The regular expression. 
                   //Example to match: helloWorld.c:5:3: warning: implicit declaration of function 'prinft'
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        // 바이너리 실행(Ubuntu)

        {

            "label": "execute",

            "command": "cd ${fileDirname} && ./${fileBasenameNoExtension}",

            "group": "test"

        }
        // // 바이너리 실행(Windows)
        // {
        //     "label": "execute",
        //     "command": "cmd",
        //     "group": "test",
        //     "args": [
        //         "/C", "${fileDirname}\\${fileBasenameNoExtension}"
        //     ]
    
        // }
    ]
}

이후 빌드와 실행을 하면 된다.

 

=> 실제 포스팅을 시작하기 전에 미리 설치를 해놓으니 순서대로 소개하기가 힘든 점이 많은 것 같다. 

    이후로는 설치와 포스팅이 한번에 이루어지도록 노력해야겠다.

728x90