On Windows:
Alt+← .. navigate back
Alt+→ .. navigate forward
On Mac:
Ctrl+- .. navigate back
Ctrl+Shift+- .. navigate forward
On Ubuntu Linux:
Ctrl+Alt+- .. navigate back
Ctrl+Shift+- .. navigate forward
visual studio code (vsc) 對開發node.js,javascript,python,html,golang等比較友好,同時支持git瀏覽及分屏對比,運行速度快,因此是值得一用的編輯器。javascript
這個插件能夠導入下面的 Git 命令,以便您能夠在命令面板中使用。和 Atom 中實用很是類似。html
https://marketplace.visualstudio.com/items?itemName=bibhasdn.git-easy前端
當你須要 require 本地文件時,這個插件將爲你提供基於你輸入的文件路徑的自動補全的選項。vue
https://marketplace.visualstudio.com/items?itemName=JerryHong.autofilenamejava
添加對 ESLint 的支持,並在安裝和重啓 VS Code 後自動開始工做。node
https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslintpython
用代碼片斷加快 ES6 開發速度,例如輸入 imd
能夠自動生成以下代碼:git
https://marketplace.visualstudio.com/items?itemName=xabikos.JavaScriptSnippetses6
簡單的項目管理器,能夠在你的編輯器中快速切換項目。github
https://marketplace.visualstudio.com/items?itemName=alefragnani.project-manager
這個插件能夠對選中的代碼行進行排序。也提供不區分大小寫、反向和惟一等排序功能。
https://marketplace.visualstudio.com/items?itemName=Tyriar.sort-lines
一個高級的連續測試運行器,當您對您正在工做的文件進行測試時,它會在你的編輯器中建立經過測試或測試失敗的視覺反饋。
https://marketplace.visualstudio.com/items?itemName=WallabyJs.wallaby-vscode
你頗有可能在多臺電腦上進行編碼工做。在電腦上移植你的插件和設置是垂手可得的事,這要歸功於 Shan Ali Khan 的設置同步擴展。
https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync
可視化的 Git 歷史記錄插件。
https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory
添加對 EditorConfig 的支持,所以當您格式化文件時,它會引用此約定。
https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
在 TypeScript 和 JavaScript 文件中自動生成詳細的 JSDoc 註釋。
https://marketplace.visualstudio.com/items?itemName=joelday.docthis
VS Code 擴展,在 import 導入語句中自動完成npm 模塊。
https://marketplace.visualstudio.com/items?itemName=christian-kohler.npm-intellisense
對齊文本,使代碼根據 =
,:
等對齊。
對齊前:
對齊後:
https://marketplace.visualstudio.com/items?itemName=steve8708.Align
目前 VS Code 中的最好用的 vim 插件。不是下載最多的 vim 插件,但它使用的是多指針,不像那些下載最多的插件。
https://marketplace.visualstudio.com/items?itemName=auiworks.amvim
快速修改突出顯示的選中文本的命名格式。 camelCase(駱駝拼命名),PascalCase(首字母大寫),kebab-case(中劃線命名),underscore_delimited(下劃線命名),CONSTANT(大寫命名)等。
https://marketplace.visualstudio.com/items?itemName=zhengxiaoyao0716.intelligence-change-case
能夠更換側邊欄中漂亮的圖標。
https://marketplace.visualstudio.com/items?itemName=robertohuertasm.vscode-icons
快速修改突出顯示的選中文本的命名格式。 camelCase(駱駝拼命名),PascalCase(首字母大寫),kebab-case(中劃線命名),underscore_delimited(下劃線命名),CONSTANT(大寫命名)等。
https://marketplace.visualstudio.com/items?itemName=zhengxiaoyao0716.intelligence-change-case
對於Visual Studio Code開發工具,有一款優秀的GoLang插件,它的主頁爲:https://github.com/microsoft/vscode-go
這款插件的特性包括:
go-symbols
)本插件的安裝教程,請查看《Windows環境下vscode-go安裝日記》
https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code
If you are on Windows or Linux, running Go: Install/Update Tools
would have installed delve for you. If you don't want to run that command or you are on OS X, you can manually install delve as per the Installation Instructions. On OS X it requires creating a self-signed cert to sign the dlv
binary.
Based on how you install delve it will either end up in your PATH
or GOPATH/bin
. If dlv
binary is in your GOPATH/bin
and this GOPATH is not set as an environment variable, then make sure your PATH points to this GOPATH/bin
so that the Go extension can find the dlv
binary.
Once delve is installed, you can either press F5
or go to the Code debug viewlet and select the configuration gear.
You will now see a launch.json
file created for your workspace, which will contain the configurations for debugging. By default, there would be a single configuration as below:
{
"version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "mode": "debug", "remotePath": "", "port": 2345, "host": "127.0.0.1", "program": "${fileDirname}", "env": {}, "args": [], "showLog": true } ] }
Ignore remotePath
, host
and port
if you are not remote debugging.
The program
option is mandatory.
${workspaceFolder}
to debug package at the root of the workspace that is opened in VS Code${file}
to debug the current file.The mode
parameter can be set to:
debug
to compile the contents of the program folder and launch under the debugger. [default]test
to debug tests in the program folder. To debug a single test, pass -test.run
and the Test name as args. Additionally, you can pass -test.v
to get verbose output as well.exec
to run a pre-built binary specified in program, for example "program":"${workspaceRoot}/mybin"
.remote
to attach to a remote headless Delve server. You must manually run Delve on the remote machine, and provide the additional remotePath
, host
and port
debug configuration options pointing at the remote machine.In version 0.6.66 or lesser of the Go extension, the debugger cannot read your settings. It figures out the GOPATH from either the environment variables or from the path provided in the program
option. If you have set multiple GOPATHs in the go.gopath
setting, pass the same in the env
option of the launch.json
as an environment variable.
As of 0.6.67 version, the debugger will inherit the GOPATH from settings. Run Go: Current GOPATH
command to see the GOPATH being used by the Go extension and the debugger.
As of 0.6.54 version of the Go extension, you can now make use of snippets while editing the launch.json file. Type "Go" and you will get debug configuration snippets for debugging current file/package, a test function etc.
Set showLog
attribute in your debug configuration to true
. You will see logs in the debug console from delve.
Set trace
attribute in your debug configuration to verbose
. You will see logs in the debug console from the Go extension's debug adapter. These logs will be saved to a file whose path will be printed at the beginning in the debug console.
If you want to dig deeper and debug the debugger using source code of this extension, read building-and-debugging-the-extension
To remote debug using VS Code, you must first run a headless Delve server on the target machine. For example:
$ dlv debug --headless --listen=:2345 --log
Any arguments that you want to pass to the program you are debugging must be passed to this Delve server that runs on the target machine. For example:
$ dlv debug --headless --listen=:2345 --log -- -myArg=123
Note: Do not pass the flag
–api-version=2
to dlv. The Go extension doesn't support v2 of delve APIs yet.
Then, create a remote debug configuration in VS Code launch.json
.
{
"name": "Remote", "type": "go", "request": "launch", "mode": "remote", "remotePath": "${workspaceRoot}", "port": 2345, "host": "127.0.0.1", "program": "${workspaceRoot}", "env": {} }
When you launch the debugger with this new Remote
target selected, VS Code will send debugging commands to the dlv
server you started previously instead of launching it's own dlv
instance against your app.
The above example runs both the headless dlv
server and the VS Code debugger locally on the same machine. For an example of running these on different hosts, see the example of debugging a process running in a docker host at https://github.com/lukehoban/webapp-go/tree/debugging.
Like the error message says, the extension cannot find dlv
. Remember, the debug adapter cannot read the VS Code settings.
Solution: Add the location where dlv is installed to your PATH. You can find this location by running which dlv
or where dlv
The debugger is not using the right GOPATH. This shouldnt happen, if it does, log a bug.
Solution: Until the bug you logged is resolved, the work around is to add the GOPATH as an env var in the env
property in the launch.json
file.
You have dlv
running just fine from command line, but VS Code gives this access related error. This can happen if the extension is trying to run the dlv
binary from a wrong location. The Go extension first tries to find dlv
in your $GOPATH/bin and then in your $PATH.
Solution: Run which dlv
in the command line. If this doesnt match your GOPATH/bin
, then delete the dlv
file in your GOPATH/bin
You may see this in the debug console, while trying to run in the test
mode. This happens when the program
attribute points to a folder with no test files.
Solution: Ensure that the program
attribute points to the folder that contains the test files you want to run.
This usually happens in OSX due to signing issues. See the discussions in please see #717, #269 and derekparker/delve/357
Solution: You may have to uninstall dlv and install it manually as per instructions
This error can show up for Mac users using delve of version 0.12.2 or above. Not sure why, but doing a xcode-select --install
has solved the problem for users who have seen this issue.
Check the version of delve api being used in the remote delve process. v2 is not yet supported in the Go extension. So if you have –api-version=2
being passed to dlv
, remove that flag and try again
F1
或 Ctrl+Shift+P
: 打開命令面板。在打開的輸入框內,能夠輸入任何命令,例如:
Backspace
會進入到 Ctrl+P
模式Ctrl+P
下輸入 >
能夠進入 Ctrl+Shift+P
模式在 Ctrl+P
窗口下還能夠:
?
列出當前可執行的動做!
顯示 Errors
或 Warnings
,也能夠 Ctrl+Shift+M
:
跳轉到行數,也能夠 Ctrl+G
直接進入@
跳轉到 symbol
(搜索變量或者函數),也能夠 Ctrl+Shift+O
直接進入@
根據分類跳轉 symbol
,查找屬性或函數,也能夠 Ctrl+Shift+O
後輸入:進入#
根據名字查找 symbol
,也能夠 Ctrl+T
Ctrl+Shift+N
Ctrl+Shift+W
Ctrl+N
Ctrl+Tab
3
個) Ctrl+\
,也能夠按住 Ctrl
鼠標點擊 Explorer
裏的文件名3
個編輯器的快捷鍵 Ctrl+1
Ctrl+2
Ctrl+3
3
個編輯器之間循環切換 Ctrl+
Ctrl+k
而後按 Left
或 Right
Ctrl+[
、 Ctrl+]
Ctrl+C
、 Ctrl+V
複製或剪切當前行/當前選中內容Shift+Alt+F
,或 Ctrl+Shift+P
後輸入 format code
Alt+Up
或 Alt+Down
Shift+Alt+Up
或 Shift+Alt+Down
Ctrl+Enter
Ctrl+Shift+Enter
visual studio code 快捷鍵:
0、回到上次光標的位置:
On Windows:
Alt+← .. navigate back
Alt+→ .. navigate forward
On Mac:
Ctrl+- .. navigate back
Ctrl+Shift+- .. navigate forward
On Ubuntu Linux:
Ctrl+Alt+- .. navigate back
Ctrl+Shift+- .. navigate forward
Home
End
Ctrl+End
Ctrl+Home
F12
Alt+F12
Ctrl+Shift+]
Shift+End
Shift+Home
Ctrl+Delete
Shift+Alt+Left
和 Shift+Alt+Right
Alt+Shift+鼠標左鍵
,Ctrl+Alt+Down/Up
Ctrl+Shift+L
Ctrl+D
下一個匹配的也被選中 (在 sublime 中是刪除當前行,後面自定義快鍵鍵中,設置與 Ctrl+Shift+K
互換了)Ctrl+U
Shift+F12
Ctrl+F12
F2
,輸入新的名字,回車,會發現全部的文件都修改了Error
或 Warning
:當有多個錯誤時能夠按 F8
逐個跳轉diff
: 在 explorer
裏選擇文件右鍵 Set file to compare
,而後須要對比的文件上右鍵選擇 Compare with file_name_you_chose
Ctrl+F
Ctrl+H
Ctrl+Shift+F
F11
Ctrl +/-
Ctrl+B
Ctrl+Shift+E
Ctrl+Shift+F
Ctrl+Shift+G
Ctrl+Shift+D
Ctrl+Shift+U
File -> AutoSave
,或者 Ctrl+Shift+P
,輸入 auto
打開默認鍵盤快捷方式設置:
File -> Preferences -> Keyboard Shortcuts
,或者:Alt+F -> p -> k
修改 keybindings.json
:
// Place your key bindings in this file to overwrite the defaults [ // ctrl+space 被切換輸入法快捷鍵佔用 { "key": "ctrl+alt+space", "command": "editor.action.triggerSuggest", "when": "editorTextFocus" }, // ctrl+d 刪除一行 { "key": "ctrl+d", "command": "editor.action.deleteLines", "when": "editorTextFocus" }, // 與刪除一行的快捷鍵互換 { "key": "ctrl+shift+k", "command": "editor.action.addSelectionToNextFindMatch", "when": "editorFocus" }, // ctrl+shift+/多行註釋 { "key":"ctrl+shift+/", "command": "editor.action.blockComment", "when": "editorTextFocus" }, // 定製與 sublime 相同的大小寫轉換快捷鍵,需安裝 TextTransform 插件 { "key": "ctrl+k ctrl+u", "command": "uppercase", "when": "editorTextFocus" }, { "key": "ctrl+k ctrl+l", "command": "lowercase", "when": "editorTextFocus" } ]
vscode 自定義配置參考:
{ "editor.fontSize": 18, "files.associations": { "*.es": "javascript", "*.es6": "javascript" }, // 控制編輯器是否應呈現空白字符 "editor.renderWhitespace": true, // 啓用後,將在保存文件時剪裁尾隨空格。 "files.trimTrailingWhitespace": true, // File extensions that can be beautified as javascript or JSON. "beautify.JSfiles": [ "", "es", "es6", "js", "json", "jsbeautifyrc", "jshintrc" ] }
官方快捷鍵大全:https://code.visualstudio.com/docs/customization/keybindings