Programming

vscode 세팅 (settings.json & tasks.json)

범고래_1 2019. 8. 19. 14:53

vscode 세팅

일단 이건 공통적으로 쓰이는 settings.json이다.


settings.json
{
    "emmet.triggerExpansionOnTab": true,
    
    /*
    "emmet.showExpandedAbbreviation" :"always",
    "emmet.showSuggestionsAsSnippets":true,
    "editor.snippetSuggestions": "top",
    
    */

    "window.zoomLevel": -1,
    "editor.fontSize": 18,
    "workbench.sideBar.location": "left",
    "mongo.shell.path": "/Users/abcd/downloads/bin/mongo",
    "C_Cpp.default.cppStandard": "c++11",
    "cmake-tools-helper.cmake_download_path": "/Users/abcd/.vscode/extensions/maddouri.cmake-tools-helper-0.2.1/cmake_download",
    "C_Cpp.updateChannel": "Insiders",
    "debug.console.fontSize": 21,
    //"python.pythonPath": "/usr/bin/python",
    "terminal.integrated.fontFamily" : "Ubuntu Mono derivative Powerline",
    "terminal.integrated.fontSize": 21,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "python.jediEnabled": false,    
    "python.pythonPath": "/Users/abcd/python_venv/bin/python",
    
}

vscode는 프로젝트 단위(?)가 Workspace 인데, Workspace 마다 build configuration을 따로 설정 할 수 있다.

(사실 따로 설정해야 한다....)

Workspace 폴더 내 .vscode 내에 tasks.json으로 관리된다.

python3

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "python3 venv",
            "command": "${config:python.pythonPath}",
            "args": [
                "${file}"
            ],
            //"isShellCommand": true,
            "type": "shell",
            "options": {
                "env": {
                    "PYTHONIOENCODING": "UTF-8"
                }
            },
            //"showOutput": "always",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
C99 & C++11
{
    "version": "2.0.0",
    "runner": "terminal",
    "type": "shell",
    "echoCommand": true,
    "presentation" : { "reveal": "always" },
    "tasks": [
        {
            "label": "compile and run for C++",
            "command": "g++",
            "args": [
                "${file}",
                "-std=c++11",
                "-g",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "&&${fileDirname}/${fileBasenameNoExtension}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            //"group": "build",
            "problemMatcher": {
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "label": "compile for C++",
            "command": "g++",
            "args": [
                "${file}",
                "-g",
                "-std=c++11",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],

            "group": "build",
            
            // "group": {
            //     "kind": "build",
            //     "isDefault": false
            // },
            
            "problemMatcher": {
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "label": "compile for C",
            "command": "gcc",
            "args": [
                "${file}",
                "-std=c99",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "group": "build",
            "problemMatcher": {
                "fileLocation": [
                    "relative",
                    "${workspaceRoot}"
                ],
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "label": "execute",
            "command": "cd ${fileDirname} && ./${fileBasenameNoExtension}",
            "group": "test"
        }
    ]
}


Workspace 별로 buid configuration가 따로 세팅되는 줄 몰라서 초창기에 엄청 삽질했던 기억이ㅠ

'Programming' 카테고리의 다른 글

VSCode mac gcc bits/stdc++.h 헤더 추가  (2) 2020.04.08
VSCode 빌드 단축키 설정  (0) 2020.04.08
VSCode auto format 중괄호 문제  (1) 2020.04.08
vscode 단축키 세팅 (keybindings.json)  (0) 2019.08.19