您可以透過 File > Preferences > Keyboard Shortcuts
(或按 Ctrl + K + Ctrl + S)來自訂快速鍵設定。
Insert Date String
Ctrl + Shift + X
,Mac:Cmd + Shift + X
)。Alt + Shift + I
插入目前的日期時間。Ctrl + Shift + P
,執行 Insert Date String
指令。Ctrl + Shift + P
(Mac:Cmd + Shift + P
),輸入並選擇 Preferences: Configure User Snippets
。plaintext.json
或 python.json
)。
"Insert Date": {
"prefix": "date",
"body": [
"${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}"
],
"description": "插入目前日期"
}
輸入 date
並按 Tab
即可插入日期。
macros
搭配日期功能Insert Date String 擴充套件支援多種日期格式,安裝後可在 settings.json
中自訂格式,例如:
"insertDateString.format": "YYYY-MM-DD HH:mm:ss"
Ctrl + Shift + X
(Mac: Cmd + Shift + X
)開啟「擴充套件市集 (Extensions)」。Ctrl + Shift + O
(Mac: Cmd + Shift + O
)快速瀏覽符號清單。F5
)、變數檢視等功能。Ctrl + Shift + P
(Mac: Cmd + Shift + P
)並輸入 Python: Select Interpreter
選擇 Python 版本。.ipynb
格式,適合資料科學與機器學習開發。擴充套件名稱 | 功能描述 |
---|---|
Python (Microsoft) | 官方 Python 支援,包含語法高亮、補全、除錯 |
Pylance | 提供更快的 IntelliSense 與型別檢查 |
Jupyter | 讓 VSCode 支援 Jupyter Notebook |
Python Environment Manager | 方便管理 Python 虛擬環境 |
Python Docstring Generator | 自動產生 Python 註解 (Docstring) |
Ctrl + Shift + P
(Mac:Cmd + Shift + P
)。Preferences: Open Settings (JSON)
並選擇。settings.json
,可直接編輯個人設定。settings.json
編輯頁面。Windows / Linux:
%APPDATA%\Code\User\settings.json
macOS:
~/Library/Application Support/Code/User/settings.json
你也可以用 VSCode 的 File → Open File
直接開啟該路徑的檔案。
{ "tabWidth": 4, "useTabs": false, "singleQuote": true, "trailingComma": "es5" }
[*.{js,css,html}] indent_style = space indent_size = 2
Ctrl + K Ctrl + S
(Windows/Linux)或 Cmd + K Cmd + S
(Mac)開啟快捷鍵設定。keybindings.json
。[
{
"key": "ctrl+alt+u",
"command": "workbench.action.editor.changeEncoding",
"args": "utf8",
"when": "editorTextFocus"
}
]
ctrl+alt+u
為其他按鍵組合。"utf8"
為目標編碼,可改為其他編碼。Ctrl + Shift + P
(Mac 使用 Cmd + Shift + P
)。utf8
(UTF-8)utf16le
(UTF-16 LE)utf16be
(UTF-16 BE)big5
(Big5)gbk
(GBK)iso88591
(ISO-8859-1)windows1252
(Windows-1252)Ctrl + Alt + U
(或你設置的快捷鍵)。在 VSCode 中,若你編輯含有中文、全形符號或 Unicode 特殊字元的文件,常會遇到字寬不一致、無法垂直對齊的問題。這些問題即使使用等寬英文字體仍可能出現,特別是涉及 CJK 字元時。
以下字型能較好地處理中文等寬排列問題:
開啟 settings.json
(快捷鍵 Ctrl + Shift + P
→ 輸入「Preferences: Open Settings (JSON)」),加入以下設定:
"editor.fontFamily": "'SimSun-ExtB', 'MS Gothic', '仿宋', '標楷體', monospace"
此設定會依序嘗試載入字型,若前者未安裝則 fallback 到下一個。
"editor.fontLigatures": false
:避免字型合併導致對齊問題"editor.renderWhitespace": "all"
:顯示空白字符,便於調整格式"editor.lineHeight": 22
:視字體大小微調行高以避免上下重疊若希望在 VSCode 中使用繁體中文字型實現 Unicode 欄位整齊對齊,可透過 SimSun-ExtB
、MS Gothic
、仿宋
、標楷體
等進行組合設定,並啟用輔助設定強化對齊效果。
或直接編輯 settings.json
:
{
"editor.folding": false
}
#region
和 #endregion
。{...}
。Ctrl + Shift + E
Cmd + Shift + E
按下該快捷鍵後,焦點將從編輯器切換到「檔案總管」(Explorer)視窗。
Ctrl + K Ctrl + S
(Windows/Linux)或 Cmd + K Cmd + S
(Mac)開啟快捷鍵設定。workbench.view.explorer
。Ctrl + Alt + E
。如果要手動修改 JSON 設定,可以在 keybindings.json
加入以下內容:
[
{
"key": "ctrl+alt+e",
"command": "workbench.view.explorer"
}
]
Ctrl + Shift + E
或你自訂的快捷鍵。Ctrl + P
並複製當前單詞Ctrl + Shift + ←
(Mac: Cmd + Shift + ←
)選取檔名。Ctrl + C
(Mac: Cmd + C
)複製檔名。Ctrl + P
(Mac: Cmd + P
)開啟 Go To File 面板。Ctrl + V
或 Cmd + V
)並按 Enter
開啟檔案。editor.action.goToImplementation
import
或 require
,可直接跳轉。F12
(跳轉到定義)。Ctrl + Click
(Mac: Cmd + Click
)。Ctrl + Shift + Click
。Quick File Open
若經常需要此功能,可安裝 Quick File Open 擴充套件,並設定快捷鍵,自動從游標位置提取檔案名稱並開啟。
Open file - Frank Stuetzer
Open file From Path - jack89ita
VSCode 雖支援直欄選取(Column Selection),但預設無內建功能可直接對選取區域的數值進行加總。不過你可透過以下幾種方法來達成此目的。
Calculate Sum
Ctrl+C
複製# Python 範例
nums = [12, 15, 8, 10]
print(sum(nums))
可將數值快速整理後,貼至 Excel、Google Sheets、或 Pandas 等工具中進行加總。
若你經常需要進行這類操作,安裝 Calculate 擴充套件是最方便直接的做法。
Visual Studio Code 支援對選取區域的多行文字進行排序,可依照字母順序、數字大小或反向排序,常用於程式碼整理、資料處理或清單編排。
Ctrl + Shift + P
Sort Lines Ascending
(升冪)或 Sort Lines Descending
(降冪)預設未綁定快捷鍵,你可以自行設定:
Sort Lines Ascending
或 Descending
若需要自訂排序條件(例如:忽略大小寫、按欄位排序、自然數字排序等),可安裝以下擴充套件:
Alt + Shift + ↓ / ↑
快速複製或移動行VSCode 內建已支援基本的行排序功能,若有進階需求,可透過擴充套件擴展使用情境。
Ctrl + Shift + P
(Mac: Cmd + Shift + P
)開啟指令面板,輸入 View: Show Outline
並執行。Ctrl + Shift + O
(Mac: Cmd + Shift + O
)。@
或 :
快速過濾Ctrl + P
(Mac: Cmd + P
)開啟快速搜尋面板。@
來查看所有函式與類別。:@
來僅顯示 Python 類別與函式。Ctrl + `
或選單中選取「終端機」)。git remote add origin [遠端儲存庫網址]
。git remote -v
。git push origin main
(根據分支名稱調整)。git pull origin main
。git log
查看提交歷史。可在 settings.json
中設定 PHP 可執行檔路徑:
"php.validate.executablePath": "C:/php/php.exe"
.vscode/launch.json
設定除錯參數。若主要需求是程式編輯與自動完成,安裝 PHP Intelephense 即可;若需要除錯,務必搭配 PHP Debug 與 Xdebug。
在 Visual Studio Code 中使用 php.validate.executablePath
功能,無需安裝額外的 PHP 擴充套件,但需確認已安裝 PHP 執行檔於系統中。
建議安裝以下擴充套件以加強 PHP 開發體驗:
C:\\php\\php.exe
/usr/bin/php
或使用 which php
取得路徑Preferences: Open Settings (JSON)
"php.validate.executablePath": "C:\\php\\php.exe"
(Linux/macOS 路徑範例:"/usr/bin/php"
)
settings.json
php.validate.executablePath
VS Code 本身沒有直接設定 php.ini
的選項,它是透過你在 settings.json
指定的 php.exe 來讀取對應的 php.ini
。步驟如下:
C:\php\php.exe
C:\php\php.ini
settings.json
(快捷鍵:Ctrl + ,
→ 右上角「開啟設定 (JSON)」圖示)。"php.validate.executablePath": "C:/php/php.exe"
php.ini
與該 php.exe
屬於同一個 PHP 安裝路徑,這樣 VS Code 在語法檢查與除錯時,就會使用該 php.ini
。php --ini
Configuration File (php.ini) Path: C:\php
Loaded Configuration File: C:\php\php.ini
在 VS Code 無法直接指定 php.ini
,只能透過指定 php.exe
的路徑來間接指定使用哪個 php.ini
。
Visual Studio Code 本身不是完整的 Android Studio 替代品,缺乏官方 Android SDK 整合。但可以透過安裝擴充套件與設定環境,進行 Android App 開發。
ANDROID_HOME
環境變數若希望輕量化開發,建議選擇 Flutter 或 React Native,在 VS Code 中即可完成大部分流程;但若需原生 Android App 深度開發與除錯,Android Studio 仍是主要工具。
Ctrl+Shift+D
。VS Code 使用 .vscode/launch.json
來定義執行與除錯方式,以下是不同語言的範例:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "啟動 Node.js 程式",
"program": "${file}"
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "啟動 Python 程式",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
不同語言需安裝對應擴充套件,例如:
在 VS Code 中打開 settings.json
,加入以下設定:
"terminal.integrated.defaultProfile.windows": "Command Prompt",
"terminal.integrated.profiles": {
"Command Prompt": {
"path": "C:\\Windows\\System32\\cmd.exe"
},
"PowerShell": {
"path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
}
}
cmd.exe
。若你安裝了 Git Bash、WSL 或其他 shell,也可以在 profiles
區段中一併加入,方便切換。
VS Code 的「執行與除錯」使用的終端機可以透過 launch.json
中的 console
與 internalConsoleOptions
來控制。
"terminal.integrated.defaultProfile.windows": "PowerShell",
"terminal.integrated.profiles": {
"PowerShell": {
"path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
},
"Command Prompt": {
"path": "C:\\Windows\\System32\\cmd.exe"
}
}
{
"version": "0.2.0",
"configurations": [
{
"name": "啟動 Python 程式 (使用 cmd)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"windows": {
"command": "cmd.exe"
}
}
]
}
cmd.exe
裡執行。email: [email protected]