JS: VSCode 팁

Jul 30, 2024 am 09:29 AM

JS: VSCode Tips

Discovering little tricks like that can really streamline your workflow. Here are some more tips and tricks for making the most out of your coding experience in VS Code, especially when you're working with Node.js:

1. Integrated Terminal

You already found out about using the terminal in VS Code, but did you know you can split terminals? Use Ctrl + Shift + 5 (or Cmd + Shift + 5 on Mac) to open a split terminal. This is great for running a server in one terminal while executing scripts or running tests in another.

2. Debugger

VS Code has a built-in debugger that works seamlessly with Node.js. Set breakpoints in your code by clicking in the gutter next to the line numbers, and then press F5 to start the debugger. You can step through your code, inspect variables, and view call stacks, making it much easier to find and fix issues.

3. Live Server Extension

If you're working on web projects, the Live Server extension is a game-changer. It automatically refreshes your browser whenever you save changes to your HTML, CSS, or JavaScript files. Just install the extension, right-click your index.html file, and select "Open with Live Server."

4. Emmet Abbreviations

For HTML and CSS, Emmet abbreviations can save you tons of time. For example, typing ul>li*5 and pressing Tab will generate an unordered list with five list items. It's like magic!

5. Prettier Extension

The Prettier code formatter helps keep your code consistent and clean. Install the Prettier extension and then format your code with Alt + Shift + F (or Option + Shift + F on Mac). You can also configure it to format your code on save.

6. Code Snippets

Custom snippets can speed up your coding. Go to File > Preferences > User Snippets and create a new snippet file for JavaScript. For example, you can create a snippet for a console log:

"log": {
    "prefix": "clg",
    "body": ["console.log('$1');"],
    "description": "Log output to console"
}
로그인 후 복사

Now, typing clg followed by Tab will expand to console.log();.

7. IntelliSense

VS Code’s IntelliSense offers intelligent code completion, parameter info, and member lists. For JavaScript, it’s particularly useful when dealing with complex objects or unfamiliar libraries. You can trigger it manually by pressing Ctrl + Space.

8. Extensions for Node.js

There are a few must-have extensions for Node.js developers:

  • Node.js Extension Pack: A collection of useful extensions like npm, ESLint, and Node.js Modules Intellisense.
  • Nodemon: This extension allows you to use the Nodemon utility which automatically restarts your Node.js application when file changes in the directory are detected.

9. Source Control Integration

VS Code has Git integration built-in. You can manage your repositories, stage changes, make commits, and even resolve merge conflicts directly from the editor. Use the Source Control panel on the left sidebar for all your Git operations.

10. Command Palette

The Command Palette (Ctrl + Shift + P or Cmd + Shift + P on Mac) is the gateway to all VS Code commands. You can quickly search and execute commands, open files, and run extensions without leaving your keyboard.

11. Multi-Cursor Editing

Place multiple cursors in your code by holding Alt (or Option on Mac) and clicking where you want to add a cursor. You can also use Ctrl + Alt + Down (or Cmd + Option + Down on Mac) to add a cursor below the current line. This is super handy for making the same edit in multiple places.

12. Explorer Shortcuts

Navigate your files quickly using the explorer panel on the left. Ctrl + P (or Cmd + P on Mac) brings up the quick open file menu, allowing you to jump to any file in your project with just a few keystrokes.

13. Task Runner

You can define tasks in VS Code to run scripts or commands with ease. Create a tasks.json file in the .vscode folder of your project and configure tasks like building your project or running tests.

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "npm run build",
            "problemMatcher": []
        }
    ]
}
로그인 후 복사

Now you can run your build task from the Command Palette or the terminal.

14. Code Lens

For JavaScript, Code Lens shows inline references to functions and variables, making it easier to see where they are used. Enable it in settings under Editor: Code Lens.

15. Bracket Pair Colorization

To make nested code easier to read, enable bracket pair colorization. This can be done by adding "editor.bracketPairColorization.enabled": true to your settings.json file.

16. Workspace Settings

VS Code allows you to configure settings specific to your project by adding a .vscode folder with settings.json inside your project directory. This is useful for maintaining consistent settings across team members.

{
    "editor.tabSize": 2,
    "files.exclude": {
        "**/.git": true,
        "**/.DS_Store": true
    }
}
로그인 후 복사

17. Remote Development

VS Code's Remote Development extensions let you work with code on remote machines or in containers. You can use the Remote - SSH extension to connect to a remote server or Remote - Containers to develop inside Docker containers. This is excellent for maintaining a consistent dev environment.

18. Settings Sync

You can sync your settings, extensions, and keyboard shortcuts across different devices using Settings Sync. Enable it from the gear icon in the bottom left, then "Turn on Settings Sync..." and sign in with your GitHub or Microsoft account.

19. Keyboard Shortcuts

Mastering keyboard shortcuts can significantly boost your productivity. Here are a few more handy ones:

  • Ctrl + B (or Cmd + B on Mac) to toggle the sidebar.
  • Ctrl + (or Cmd + on Mac) to open the integrated terminal.
  • Ctrl + K, Ctrl + S (or Cmd + K, Cmd + S on Mac) to open the keyboard shortcuts editor.

20. Extensions for Productivity

Explore these extensions to further enhance your productivity:

  • Bracket Pair Colorizer 2: Colors matching brackets to make nested code more readable.
  • Path Intellisense: Autocompletes filenames when you start typing a path in your import statements.
  • Todo Tree: Tracks TODO comments in your code and lists them in the explorer.

21. REST Client

The REST Client extension allows you to make HTTP requests directly from VS Code and view the responses. Create a .http or .rest file and write your requests:

GET https://api.github.com/users/octocat
로그인 후 복사

Run the request by clicking "Send Request" above the request line.

22. Polacode

Polacode is an extension that lets you create beautiful code snapshots. You can use it to generate images of your code for documentation or sharing. Simply select the code, right-click, and select "Polacode: Open" to capture the snapshot.

23. CSS Peek

For front-end developers, CSS Peek allows you to view CSS definitions directly in your HTML file by hovering over class names or IDs.

24. GitLens

GitLens supercharges the built-in Git capabilities by providing insights into your repository. It shows who changed a line of code and when, helps with navigating through commit history, and even offers inline blame annotations.

25. Snippets and Extensions for Frameworks

Depending on your tech stack, there are specific snippets and extensions you might find useful:

  • React: The ES7+ React/Redux/React-Native snippets extension offers shorthand snippets for creating components, hooks, and more.
  • Vue.js: Vetur is the go-to extension for Vue.js development, providing syntax highlighting, snippets, and more.
  • Angular: Angular Essentials pack includes Angular Language Service and other helpful tools.

26. Jupyter Notebooks

VS Code supports Jupyter Notebooks, making it an excellent tool for data science and machine learning projects. Install the Jupyter extension to create, edit, and run Jupyter notebooks directly in the editor.

27. Docker Integration

If you're working with Docker, the Docker extension is invaluable. It allows you to build, manage, and deploy containerized applications directly from VS Code. You can view containers, images, and registries all from the sidebar.

28. Markdown Preview

VS Code has built-in support for Markdown. You can preview Markdown files by opening the file and pressing Ctrl + Shift + V (or Cmd + Shift + V on Mac). This is great for writing documentation or README files.

29. Workspace Trust

VS Code introduces Workspace Trust, which allows you to control the level of trust you assign to the files within a workspace. This is especially useful when working with code from unknown sources, ensuring your environment remains secure.

30. 젠 모드

집중이 필요할 때 Zen 모드는 방해 없는 코딩 환경을 제공합니다. Ctrl + K Z(또는 Mac에서는 Cmd + K Z)를 눌러 Zen 모드로 들어갑니다. 이렇게 하면 모든 도구 모음과 패널이 숨겨지고 코드만 남게 됩니다.

31. 코드 탐색

다음과 같은 기능을 사용하여 코드베이스를 효율적으로 탐색하세요.

  • 정의로 이동: F12 또는 마우스 오른쪽 버튼 클릭 > 정의로 이동하세요.
  • 정의 엿보기: 정의를 인라인으로 보려면 Alt + F12(또는 Mac에서는 Option + F12)
  • 기호로 이동: Ctrl + Shift + O(또는 Mac에서는 Cmd + Shift + O)를 사용하여 현재 파일의 기호로 이동합니다.

32. 프로젝트 매니저

Project Manager 확장 프로그램을 사용하면 여러 프로젝트를 관리하고 전환할 수 있습니다. 현재 프로젝트를 저장하고, 최근 프로젝트를 나열하고, 프로젝트 간에 빠르게 전환할 수 있습니다.

33. 코드 맞춤법 검사기

코드 맞춤법 검사기 확장 프로그램을 사용하면 코드와 주석에서 당황스러운 오타를 방지할 수 있습니다. 철자 오류를 강조 표시하고 제안 사항을 제공하여 문서 및 변수 이름을 더욱 전문적으로 만듭니다.

34. 깃 그래프

Git Graph 확장 프로그램을 사용하여 저장소의 커밋 기록을 시각화하세요. 브랜치, 커밋, 병합을 그래픽으로 표현하여 프로젝트 흐름을 더 쉽게 이해할 수 있습니다.

35. 버전 관리 비교

VS Code에는 강력한 비교 기능이 있습니다. 파일을 선택하고 Ctrl + D(또는 Mac에서는 Cmd + D)를 눌러 파일을 비교하거나 변경 사항을 볼 수 있습니다. 이는 병합 충돌을 커밋하거나 해결하기 전에 변경 사항을 검토하는 데 유용합니다.

36. 코드 측정항목

CodeMetrics 확장 프로그램은 코드에 대한 복잡성 지표를 제공하여 리팩터링이 필요할 수 있는 영역을 식별하는 데 도움을 줍니다. 함수와 클래스의 인지적 복잡성을 보여줌으로써 깔끔하고 효율적인 코드를 더 쉽게 유지할 수 있습니다.

37. 키 바인딩 사용자 정의

작업 흐름에 맞게 키 바인딩을 맞춤 설정할 수 있습니다. Ctrl + K Ctrl + S(또는 Mac에서는 Cmd + K Cmd + S)를 눌러 키바인딩 편집기를 열고 기존 단축키를 수정하거나 새 단축키를 만드세요.

38. 파일 및 코드 탐색

VS Code는 강력한 파일 및 코드 탐색 기능을 제공합니다.

  • 빠른 열기: Ctrl + P(또는 Mac에서는 Cmd + P)를 사용하여 이름의 일부를 입력하여 파일을 빠르게 열 수 있습니다.
  • 뒤로 및 앞으로 탐색: 커서 기록을 이동하려면 Ctrl + - 및 Ctrl + Shift + -(또는 Mac에서는 Cmd + - 및 Cmd + Shift + -)를 사용하세요.
  • 탐색경로: 탐색경로를 활성화하면 편집기 상단에 파일의 현재 위치와 계층 구조가 표시됩니다.

39. 자동 닫기 태그 및 자동 이름 바꾸기 태그

이러한 확장은 HTML 및 JSX 개발에 특히 유용합니다. 자동 닫기 태그는 입력할 때 자동으로 태그를 닫고, 자동 이름 바꾸기 태그는 열기 태그와 닫기 태그 간의 변경 사항을 동기화합니다.

40. 프로젝트별 확장

특정 프로젝트 요구 사항에 맞는 확장 프로그램을 설치하세요. 예를 들어 Python 프로젝트에서 작업하는 경우 Python 확장은 IntelliSense, Linting 및 디버깅을 포함한 포괄적인 도구 세트를 제공합니다. Java 프로젝트의 경우 Java Extension Pack을 고려해보세요.

이 팁은 한동안 바쁜 시간을 보내고 VS Code 설정을 강화하는 데 도움이 될 것입니다. 이 모든 기능을 살펴보고 즐거운 코딩을 즐겨보세요!

위 내용은 JS: VSCode 팁의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

프론트 엔드 열 용지 영수증에 대한 차량 코드 인쇄를 만나면 어떻게해야합니까? 프론트 엔드 열 용지 영수증에 대한 차량 코드 인쇄를 만나면 어떻게해야합니까? Apr 04, 2025 pm 02:42 PM

프론트 엔드 개발시 프론트 엔드 열지대 티켓 인쇄를위한 자주 묻는 질문과 솔루션, 티켓 인쇄는 일반적인 요구 사항입니다. 그러나 많은 개발자들이 구현하고 있습니다 ...

Demystifying JavaScript : 그것이하는 일과 중요한 이유 Demystifying JavaScript : 그것이하는 일과 중요한 이유 Apr 09, 2025 am 12:07 AM

JavaScript는 현대 웹 개발의 초석이며 주요 기능에는 이벤트 중심 프로그래밍, 동적 컨텐츠 생성 및 비동기 프로그래밍이 포함됩니다. 1) 이벤트 중심 프로그래밍을 사용하면 사용자 작업에 따라 웹 페이지가 동적으로 변경 될 수 있습니다. 2) 동적 컨텐츠 생성을 사용하면 조건에 따라 페이지 컨텐츠를 조정할 수 있습니다. 3) 비동기 프로그래밍은 사용자 인터페이스가 차단되지 않도록합니다. JavaScript는 웹 상호 작용, 단일 페이지 응용 프로그램 및 서버 측 개발에 널리 사용되며 사용자 경험 및 크로스 플랫폼 개발의 유연성을 크게 향상시킵니다.

누가 더 많은 파이썬이나 자바 스크립트를 지불합니까? 누가 더 많은 파이썬이나 자바 스크립트를 지불합니까? Apr 04, 2025 am 12:09 AM

기술 및 산업 요구에 따라 Python 및 JavaScript 개발자에 대한 절대 급여는 없습니다. 1. 파이썬은 데이터 과학 및 기계 학습에서 더 많은 비용을 지불 할 수 있습니다. 2. JavaScript는 프론트 엔드 및 풀 스택 개발에 큰 수요가 있으며 급여도 상당합니다. 3. 영향 요인에는 경험, 지리적 위치, 회사 규모 및 특정 기술이 포함됩니다.

Shiseido의 공식 웹 사이트와 같은 시차 스크롤 및 요소 애니메이션 효과를 달성하는 방법은 무엇입니까?
또는:
Shiseido의 공식 웹 사이트와 같은 페이지 스크롤과 함께 애니메이션 효과를 어떻게 달성 할 수 있습니까? Shiseido의 공식 웹 사이트와 같은 시차 스크롤 및 요소 애니메이션 효과를 달성하는 방법은 무엇입니까? 또는: Shiseido의 공식 웹 사이트와 같은 페이지 스크롤과 함께 애니메이션 효과를 어떻게 달성 할 수 있습니까? Apr 04, 2025 pm 05:36 PM

이 기사에서 시차 스크롤 및 요소 애니메이션 효과 실현에 대한 토론은 Shiseido 공식 웹 사이트 (https://www.shiseido.co.jp/sb/wonderland/)와 유사하게 달성하는 방법을 살펴볼 것입니다.

JavaScript는 배우기가 어렵습니까? JavaScript는 배우기가 어렵습니까? Apr 03, 2025 am 12:20 AM

JavaScript를 배우는 것은 어렵지 않지만 어려운 일입니다. 1) 변수, 데이터 유형, 기능 등과 같은 기본 개념을 이해합니다. 2) 마스터 비동기 프로그래밍 및 이벤트 루프를 통해이를 구현하십시오. 3) DOM 운영을 사용하고 비동기 요청을 처리합니다. 4) 일반적인 실수를 피하고 디버깅 기술을 사용하십시오. 5) 성능을 최적화하고 모범 사례를 따르십시오.

JavaScript의 진화 : 현재 동향과 미래 전망 JavaScript의 진화 : 현재 동향과 미래 전망 Apr 10, 2025 am 09:33 AM

JavaScript의 최신 트렌드에는 Typescript의 Rise, 현대 프레임 워크 및 라이브러리의 인기 및 WebAssembly의 적용이 포함됩니다. 향후 전망은보다 강력한 유형 시스템, 서버 측 JavaScript 개발, 인공 지능 및 기계 학습의 확장, IoT 및 Edge 컴퓨팅의 잠재력을 포함합니다.

JavaScript를 사용하여 동일한 ID와 동일한 ID로 배열 요소를 하나의 객체로 병합하는 방법은 무엇입니까? JavaScript를 사용하여 동일한 ID와 동일한 ID로 배열 요소를 하나의 객체로 병합하는 방법은 무엇입니까? Apr 04, 2025 pm 05:09 PM

동일한 ID로 배열 요소를 JavaScript의 하나의 객체로 병합하는 방법은 무엇입니까? 데이터를 처리 할 때 종종 동일한 ID를 가질 필요가 있습니다 ...

Zustand 비동기 작동 : Usestore가 얻은 최신 상태를 보장하는 방법은 무엇입니까? Zustand 비동기 작동 : Usestore가 얻은 최신 상태를 보장하는 방법은 무엇입니까? Apr 04, 2025 pm 02:09 PM

zustand 비동기 작업의 데이터 업데이트 문제. Zustand State Management Library를 사용할 때는 종종 비동기 작업이시기 적절하게 발생하는 데이터 업데이트 문제가 발생합니다. � ...

See all articles