# Tham Khảo Nhanh VS Code

*Điều hướng, chỉnh sửa, multi-cursor, terminal, debug, extensions*

> Source: VS Code Documentation (code.visualstudio.com/docs) · MIT

## Điều hướng

### Điều hướng file & symbol

| Command | Description |
|---------|-------------|
| `Ctrl+P` | Mở nhanh theo tên file |
| `Ctrl+Shift+P` | Command Palette |
| `Ctrl+Shift+O` | Đi tới symbol trong file |
| `Ctrl+T` | Đi tới symbol trong workspace |
| `Ctrl+G` | Đi tới số dòng |
| `F12` | Đi tới định nghĩa |
| `Alt+F12` | Xem trước định nghĩa |
| `Shift+F12` | Tìm tất cả tham chiếu |
| `Ctrl+Shift+\` | Đi tới dấu ngoặc tương ứng |

### Điều hướng tab & editor

| Command | Description |
|---------|-------------|
| `Ctrl+Tab` | Chuyển qua các tab đang mở |
| `Ctrl+1 / 2 / 3` | Focus vào nhóm editor 1 / 2 / 3 |
| `Ctrl+\` | Chia đôi editor |
| `Ctrl+B` | Bật/tắt sidebar |
| `Ctrl+J` | Bật/tắt panel phía dưới |

## Chỉnh sửa

### Thao tác dòng

| Command | Description |
|---------|-------------|
| `Ctrl+Shift+K` | Xóa toàn bộ dòng |
| `Alt+Up / Down` | Di chuyển dòng lên / xuống |
| `Shift+Alt+Up / Down` | Sao chép dòng lên / xuống |
| `Ctrl+Enter` | Chèn dòng bên dưới |
| `Ctrl+Shift+Enter` | Chèn dòng bên trên |
| `Ctrl+Shift+[` | Gấp vùng |
| `Ctrl+Shift+]` | Mở vùng |

### Thao tác văn bản

| Command | Description |
|---------|-------------|
| `Ctrl+D` | Chọn từ (lặp để thêm kết quả tiếp) |
| `Ctrl+Shift+L` | Chọn tất cả các lần xuất hiện |
| `Ctrl+L` | Chọn toàn bộ dòng |
| `Ctrl+/` | Bật/tắt comment dòng |
| `Shift+Alt+A` | Bật/tắt block comment |
| `Tab / Shift+Tab` | Thụt lề / bỏ thụt lề |

## Multi-Cursor

### Thêm cursors

| Command | Description |
|---------|-------------|
| `Alt+Click` | Thêm cursor tại vị trí click |
| `Ctrl+Alt+Up / Down` | Thêm cursor phía trên / dưới |
| `Ctrl+D` | Thêm lần xuất hiện tiếp của selection |
| `Ctrl+Shift+L` | Thêm cursor vào tất cả lần xuất hiện |
| `Ctrl+U` | Hoàn tác thêm cursor gần nhất |
| `Esc` | Thoát chế độ multi-cursor |

### Quy trình Multi-Cursor

```
// Select a word, then Ctrl+D to add matches
// Type replacement — all cursors update
// Ctrl+Shift+L selects ALL matches at once
// Alt+Click for arbitrary cursor placement
```

## Terminal

### Phím tắt Terminal

| Command | Description |
|---------|-------------|
| `Ctrl+`` | Bật/tắt terminal tích hợp |
| `Ctrl+Shift+`` | Tạo terminal mới |
| `Ctrl+Shift+5` | Chia đôi terminal |
| `Ctrl+PgUp / PgDn` | Cuộn terminal lên / xuống |
| `Ctrl+Shift+C` | Sao chép selection trong terminal |
| `Ctrl+Shift+V` | Dán vào terminal |

### Quản lý Terminal

| Command | Description |
|---------|-------------|
| `Ctrl+Shift+P → Terminal: Kill` | Kết thúc terminal đang hoạt động |
| `Ctrl+Shift+P → Terminal: Rename` | Đổi tên tab terminal |
| `Terminal dropdown` | Chuyển đổi giữa các terminals |
| `terminal.integrated.shell.*` | Cài đặt shell mặc định |

## Debug

### Điều khiển Debug

| Command | Description |
|---------|-------------|
| `F5` | Bắt đầu / tiếp tục debug |
| `Shift+F5` | Dừng debug |
| `Ctrl+Shift+F5` | Khởi động lại debug |
| `F9` | Bật/tắt breakpoint |
| `F10` | Step over |
| `F11` | Step into |
| `Shift+F11` | Step out |

### Ví dụ launch.json

```
{
  "type": "node",
  "request": "launch",
  "name": "Run App",
  "program": "${workspaceFolder}/app.js"
}
```

### Tính năng Debug

| Command | Description |
|---------|-------------|
| `Watch panel` | Theo dõi biểu thức khi debug |
| `Call Stack` | Xem call stack thực thi |
| `Debug Console` | Đánh giá biểu thức tại breakpoint |
| `Conditional breakpoint` | Click phải breakpoint → chỉnh điều kiện |
| `Logpoint` | Ghi log mà không dừng thực thi |

## Extensions

### Quản lý Extensions

| Command | Description |
|---------|-------------|
| `Ctrl+Shift+X` | Mở view Extensions |
| `@installed` | Lọc extensions đã cài |
| `@enabled / @disabled` | Lọc theo đã bật / tắt |
| `@recommended` | Hiển thị extensions được gợi ý |

### Extensions thiết yếu

| Command | Description |
|---------|-------------|
| `Prettier` | Formatter code (JS, TS, CSS, HTML) |
| `ESLint` | Linting JavaScript/TypeScript |
| `GitLens` | Tích hợp Git nâng cao và blame |
| `Remote - SSH` | Phát triển trên máy từ xa qua SSH |
| `Live Server` | Server phát triển local với live reload |
| `Thunder Client` | REST API client trong VS Code |

## Cài đặt

### Truy cập cài đặt

| Command | Description |
|---------|-------------|
| `Ctrl+,` | Mở UI cài đặt |
| `Ctrl+Shift+P → settings.json` | Mở JSON cài đặt |

### Cài đặt thông dụng (JSON)

```
{
  "editor.fontSize": 14,
  "editor.tabSize": 2,
  "editor.formatOnSave": true,
  "editor.wordWrap": "on",
  "files.autoSave": "afterDelay"
}
```

### Workspace vs User

| Command | Description |
|---------|-------------|
| `User settings` | Toàn cục, áp dụng cho mọi project |
| `Workspace settings` | Theo project, lưu trong .vscode/settings.json |
| `Workspace overrides User` | Cài đặt workspace được ưu tiên |

## Phím tắt bàn phím

### Tùy chỉnh

| Command | Description |
|---------|-------------|
| `Ctrl+K Ctrl+S` | Mở editor phím tắt |
| `keybindings.json` | File JSON cho bindings tùy chỉnh |

### Phím tắt thiết yếu

| Command | Description |
|---------|-------------|
| `Ctrl+Shift+P` | Command Palette (truy cập mọi thứ) |
| `Ctrl+P` | Mở nhanh file |
| `Ctrl+Shift+F` | Tìm kiếm trong tất cả file |
| `Ctrl+H` | Tìm & thay thế trong file |
| `Ctrl+Shift+H` | Tìm & thay thế trong toàn bộ file |
| `F2` | Đổi tên symbol |
| `Ctrl+.` | Quick Fix (Code Action) |
| `Ctrl+Space` | Kích hoạt IntelliSense |
| `Ctrl+Shift+I` | Định dạng tài liệu |

## Tích hợp Git

### View Source Control

| Command | Description |
|---------|-------------|
| `Ctrl+Shift+G` | Mở panel Source Control |
| `+` | Stage thay đổi (trong SCM view) |
| `-` | Unstage thay đổi |
| `Ctrl+Enter` | Commit các thay đổi đã stage |
| `...` | Thêm thao tác (push, pull, v.v.) |

### Tính năng Git inline

| Command | Description |
|---------|-------------|
| `Gutter indicators` | Chỉ báo xanh/xanh lam/đỏ cho thêm/sửa/xóa |
| `Ctrl+Shift+P → Git: Checkout` | Chuyển nhánh |
| `Ctrl+Shift+P → Git: Pull` | Pull từ remote |
| `Ctrl+Shift+P → Git: Push` | Push lên remote |
| `Click gutter change` | Xem inline diff của dòng đã sửa |

### Diff & Merge

| Command | Description |
|---------|-------------|
| `SCM → Open Changes` | Xem diff song song |
| `Inline diff arrows` | Hoàn tác từng thay đổi riêng lẻ |
| `3-way merge editor` | Giải quyết conflicts trực quan (1.69+) |

## Các mẫu thường dùng

### Tính năng Workspace

| Command | Description |
|---------|-------------|
| `Ctrl+Shift+E` | Focus vào File Explorer |
| `Ctrl+Shift+D` | Focus vào view Debug |
| `Ctrl+Shift+M` | Hiển thị panel Problems |
| `Ctrl+K Ctrl+T` | Thay đổi Color Theme |
| `Ctrl+K Z` | Vào Zen Mode |

### Snippets

```
// File → Preferences → Configure Snippets
"Print": {
  "prefix": "log",
  "body": "console.log('$1');",
  "description": "Console log"
}
```

### Tasks (tasks.json)

```
{
  "label": "build",
  "type": "shell",
  "command": "npm run build",
  "group": "build"
}
```
