Để disable indexing (vô hiệu hóa lập chỉ mục)
Để disable indexing (vô hiệu hóa lập chỉ mục) trong Visual Studio Code (VS Code) cho một dự án – tức là tránh việc VS Code quét toàn bộ tệp để tăng hiệu suất hoặc giảm độ ồn CPU/RAM – bạn có thể làm theo một số cách dưới đây:
✅ 1. Thêm thư mục/tệp vào .vscode/settings.json
.vscode/settings.json
Bạn có thể loại trừ các thư mục khỏi quá trình lập chỉ mục bằng cách:
jsonCopyEdit// .vscode/settings.json
{
"files.watcherExclude": {
"**/node_modules/**": true,
"**/dist/**": true,
"**/.git/**": true
},
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/build": true
},
"files.exclude": {
"**/node_modules": true,
"**/dist": true
}
}
files.watcherExclude
: tránh theo dõi file hệ thống (giảm load CPU).search.exclude
: tránh lập chỉ mục tìm kiếm.files.exclude
: ẩn thư mục khỏi Explorer.
✅ 2. Tắt IntelliSense cho một số thư mục (TypeScript/JS)
Nếu bạn dùng TypeScript hoặc JavaScript, thêm vào jsconfig.json
hoặc tsconfig.json
:
jsonCopyEdit{
"exclude": ["node_modules", "dist", "build"]
}
✅ 3. Tắt tính năng suggest từ file lớn
Trong settings.json
, thêm:
jsonCopyEdit"editor.largeFileOptimizations": true,
"typescript.tsserver.maxTsServerMemory": 2048, // hoặc giảm lại nếu đang bị nặng
"typescript.tsserver.experimental.enableProjectDiagnostics": false
✅ 4. Dùng extensions
Một số extensions giúp cải thiện hiệu suất khi làm việc với dự án lớn như:
TypeScript Hero (giúp giảm indexing không cần thiết)
Project Manager (để quản lý từng project riêng)
✅ 5. Tắt Git indexing nếu không cần
Nếu bạn không dùng Git trong VS Code:
jsonCopyEdit"git.enabled": false
Nếu bạn muốn tắt hoàn toàn tính năng lập chỉ mục cho toàn bộ dự án và chỉ dùng VS Code như một editor nhẹ, bạn có thể dùng:
jsonCopyEdit{
"files.watcherExclude": { "**": true },
"search.exclude": { "**": true },
"files.exclude": { "**": true }
}
⚠️ Cảnh báo: cách này gần như làm VS Code "mù" toàn bộ dự án – bạn sẽ không thấy gì trong sidebar, không tìm kiếm được file, không có IntelliSense.
Bạn muốn tắt index cho một số phần (như node_modules
) hay toàn bộ luôn?
Last updated
Was this helpful?