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