ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [VS code/터미널] 터미널로 Visual Studio Code 실행시키기 (+ VS code 파일 열기)
    Tools 2019. 5. 15. 19:17

    예전에 캐나다에 워홀로 떠났을 때, 방을 같이 쓰던 룸메이트가 

    캐나다 아마존에서 개발자로 근무하던 친구였다.

     

    사실 그 때는 개발자가 뭔지도 몰랐고, 

    그 친구가 "난 개발자야"라고 말한 적도 한 번도 없었다.

     

    다만 그 애가 맨날 노트북에 시커먼 터미널 창을 띄워놓고

    보기만 해도 토할거 같은 알파벳 나열들을 보고 있었던 것이 기억난다.

    그 때는 그게 뭔지도 모르고 되게 있어보이고 멋있어보였다.ㅋㅋㅋ

     

     

    하여튼 나도 터미널 사용에 점점 익숙해져야 할텐데 아직까진 쉽지가 않다.

    이미 마우스에 익숙해져버린 탓에 급하면 자꾸 손이 마우스로 간다. 휴...

     

    그래도 조금이나마 익숙해져보기 위해서

    제일 자주 쓰는 Visual Studio Code를 터미널로 실행시키는 법을 정리해보려고 한다.

     


     

    사실 거창하게 시작했지만 방법은 매우 쉽다.

     

    만약에 macOS 사용자라면 따로 아래 설정을 거쳐야한다.

    Command Palette (Ctrl + Shift + P)를 열고 'shell command'를 입력하여

    Shell Command: Install 'code' command in PATH command를 클릭한다.

     

    Users on macOS must first run a command ( Shell Command: Install 'code' command in PATH )

     

    만약 Windows 사용자라면 위 설정을 거치지 않아도 VS code를 설치하면 자동으로 설정된다.

    이제 터미널을 열고 프로젝트 디렉토리로 들어가서 code .를 입력하면 된다.

    그럼 그 디렉토리를 현재 위치로 하여 Visual Studio Code가 실행된다.

     

     

    1) setup 후, 터미널에 들어가서 code . 를 입력해보자.

     

     

    2) 이렇게 Visual Studio Code가 실행된다.

     

     

     

    [code와 같이 사용가능한 옵션들 리스트]

     

    Argument

    Description

    -d or --diff

    Compare two files with each other.

    두 파일을 비교하는 editor가 실행된다.

     

    code -d <filePath/fileName><filePath/fileName>

    ex) code -d test01.js test02.js

    -a or --add

    Add folder(s) to the last active window.

    입력한 폴더를 추가하여 실행된다.

     

    code -a <폴더이름>

    ex) code -a 01_homework

    -g or --goto <file:line[:character]>

    Open a file at the path on the specified line and character position.

    입력한 파일을 VS code로 실행하여 오픈하되, 입력한 특정 라인의 특정 글자에 커서가 위치한다.

     

    code -g <file:line[:character]>

    ex) code -g test.js:20:5

    -n or --new-window

    Force to open a new window.

    전에 작성하던 파일 없이 새 창으로 실행된다.

     

    code -n

    -r or --reuse-window

    Force to open a file or folder in an already opened window.

    원래 작성하던 파일이나 폴더가 있는 상태로 실행된다.

     

    code -r

    -w or --wait Wait for the files to be closed before returning.
    -v or --version

    Print VS Code version (for example, 1.22.2), GitHub commit id, and architecture (for example, x64).

    VS code 버전과 GitHub id, x64와 같은 정보들을 알려준다.

     

    code -v

    -h or --help

    Print usage.

    code 뒤에 붙여서 사용가능한 옵션들을 알려준다.

     

    code -h

    --locale <locale>

    Set the display language (locale) for the VS Code session. (for example, en-US or zh-TW)

    display language를 세팅할 수 있다.

     

    code --locale en-US

     

     

    [파일과 폴더를 VS code로 여는 법]

     

    Argument Description
    file

    Name of a file to open. If the file doesn't exist, it will be created and marked as edited. You can specify multiple files by separating each file name with a space.

    입력한 파일이 열린다. 만약에 해당 파일이 존재하지 않는다면, 해당 파일을 새로 생성하여 오픈한다. 여러 개의 파일을 동시에 열 수 있으며 공백으로 구분하여 입력한다.

     

    code <fileName> [<fileName> ...]

    ex) code test.js code.html

    file:line[:character]

    Used with the -g argument. Name of a file to open at the specified line and optional character position. You can specify multiple files in this manner, but you must use the -g argument (once) before using the file:line[:character] specifier.

     

    -g argument를 사용하여 원하는 라인, 원하는 위치의 글자에 커서가 간 상태로 그 위치에서 열린다. (위 표와 동일)

    folder

    Name of a folder to open. You can specify multiple folders and a new Multi-root Workspace is created.

    입력한 폴더가 열린다. 여러 개의 폴더를 입력할 수 있다.

     

    code <folderName>

    ex) code 01_homework

     

     


     

    [참고 사이트]

    https://code.visualstudio.com/docs/editor/command-line

     

    The Visual Studio Code Command Line Options

    Visual Studio Code command line options (switches).

    code.visualstudio.com

     

    반응형

    'Tools' 카테고리의 다른 글

    [Git] Merge 이해하기 (Merge / Squash and Merge / Rebase and Merge)  (1333) 2020.01.19

    COMMENT