vscode
配置参考
按下 cmd+shift+p, 搜索setting.json和keybindings.json,参考这个仓库的配置
我的配置
setting.json
json
{
"workbench.colorTheme": "Default High Contrast",
"editor.fontSize": 22,
"terminal.integrated.fontSize": 24,
"editor.codeLensFontSize": 5,
"markdown.preview.fontSize": 24,
"chat.editor.fontSize": 24,
"notebook.markup.fontSize": 24,
"notebook.output.fontSize": 24,
"scm.inputFontSize": 24,
"code-runner.runInTerminal": true,
"workbench.iconTheme": "material-icon-theme",
"explorer.confirmDelete": false,
"editor.lineNumbers": "relative",
//关于vim的配置文件,参考:https://zhuanlan.zhihu.com/p/188499395
"vim.commandLineModeKeyBindingsNonRecursive": [],
"vim.insertModeKeyBindings": [],
// 定义空格键为我的前置键
"vim.leader": "<space>",
"vim.vimrc.enable": true,
"vim.handleKeys": {
"<C-a>": false,
"<C-f>": false,
"<C-n>": false,
"<C-c>": false
},
"vim.hlsearch": true,
"vim.normalModeKeyBindingsNonRecursive": [
// NAVIGATION
// switch b/w buffers
{ "before": ["<S-h>"], "commands": [":bprevious"] },
{ "before": ["<S-l>"], "commands": [":bnext"] },
// splits
{ "before": ["leader", "v"], "commands": [":vsplit"] },
{ "before": ["leader", "s"], "commands": [":split"] },
// NICE TO HAVE
{ "before": ["leader", "w"], "commands": [":w!"] },
{ "before": ["leader", "q"], "commands": [":q!"] },
{ "before": ["leader", "x"], "commands": [":x!"] },
{
"before": ["[", "d"],
"commands": ["editor.action.marker.prev"]
},
{
"before": ["]", "d"],
"commands": ["editor.action.marker.next"]
},
{
"before": ["<leader>", "c", "a"],
"commands": ["editor.action.quickFix"]
},
{ "before": ["leader", "f"], "commands": ["workbench.action.quickOpen"] },
{ "before": ["leader", "p"], "commands": ["editor.action.formatDocument"] },
{
"before": ["g", "h"],
"commands": ["editor.action.showDefinitionPreviewHover"]
}
],
"vim.visualModeKeyBindings": [
// Stay in visual mode while indenting
{ "before": ["<"], "commands": ["editor.action.outdentLines"] },
{ "before": [">"], "commands": ["editor.action.indentLines"] },
// Move selected lines while staying in visual mode
{ "before": ["J"], "commands": ["editor.action.moveLinesDownAction"] },
{ "before": ["K"], "commands": ["editor.action.moveLinesUpAction"] },
// toggle comment selection
{ "before": ["leader", "c"], "commands": ["editor.action.commentLine"] }
],
"editor.formatOnSave": true,
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// go config
"go.formatTool": "gofmt",
"go.useLanguageServer": true,
// go配置,强行指定goroot目录,不然每次打开文件都有报错:https://github.com/golang/vscode-go/issues/971
"go.goroot": "/opt/homebrew/opt/go@1.22/libexec",
"go.testExplorer.showDynamicSubtestsInEditor": true,
"go.inferGopath": true,
/*
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
*/
"git.openRepositoryInParentFolders": "always",
"terminal.integrated.defaultProfile.osx": "zsh",
"redhat.telemetry.enabled": true,
// java设置编译版本
// 并在有多个版本的情况下,可以通过 settings.json 配置文件,设置 java.home 属性来指定所需的 JDK 路径。
"java.jdt.ls.java.home": "/opt/homebrew/Cellar/openjdk@17/17.0.12/libexec/openjdk.jdk/Contents/Home",
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/opt/homebrew/Cellar/openjdk@17/17.0.12/libexec/openjdk.jdk/Contents/Home",
"default": true
}
],
"explorer.confirmDragAndDrop": false,
"solidity.telemetry": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"diffEditor.ignoreTrimWhitespace": false,
"diffEditor.hideUnchangedRegions.enabled": true,
"explorer.confirmPasteNative": false,
"makefile.configureOnOpen": false,
"breadcrumbs.enabled": false,
"gitlens.graph.minimap.enabled": false,
"http.electronFetch": true,
"gitlens.terminalLinks.showDetailsView": false,
"gitlens.terminal.overrideGitEditor": false
}
keybindings.json
json
// Place your key bindings in this file to override the defaults
[
// NAVIGATION
{
"key": "ctrl+shift+j",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+shift+k",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
{
"key": "ctrl+shift+n",
"command": "workbench.action.terminal.new",
"when": "terminalFocus"
},
{
"key": "ctrl+shift+w",
"command": "workbench.action.terminal.kill",
"when": "terminalFocus"
},
// FILE TREE
{
"command": "workbench.action.toggleSidebarVisibility",
"key": "ctrl+e"
},
{
"command": "workbench.files.action.focusFilesExplorer",
"key": "ctrl+e",
"when": "editorTextFocus"
},
{
"key": "n",
"command": "explorer.newFile",
"when": "filesExplorerFocus && !inputFocus"
},
{
"command": "renameFile",
"key": "r",
"when": "filesExplorerFocus && !inputFocus"
},
{
"key": "shift+n",
"command": "explorer.newFolder",
"when": "explorerViewletFocus"
},
{
"command": "deleteFile",
"key": "d",
"when": "filesExplorerFocus && !inputFocus"
},
// EXTRA
{
"key": "ctrl+shift+5",
"command": "editor.emmet.action.matchTag"
},
{
"key": "ctrl+z",
"command": "workbench.action.toggleZenMode"
}
]
重点快捷键
- cmd + j: 弹出终端(下方的终端)
- ctrl + e:弹出文件目录(vscode左侧的explorer)
- n:新建文件(当光标在explorer的时候)
- N:新建文件夹(当光标在explorer的时候)
- r: 重命名文件(当光标在explorer的时候)
- d:删除文件(当光标在explorer的时候)
- space + v : 分屏
- space + h :光标移到左边分屏group
- space + l :光标移到右边分屏group
终端item2
复制的问题
如果用鼠标进行复制,会失败,会有warning.
-
打开 iTerm2 设置 (Cmd + ,)。
-
进入 Profiles -> Terminal。
-
确保 Mouse Reporting 被禁用。
但是如果禁用的话,就会无法用鼠标来上下滚动终端了,所以既想用鼠标,又想复制终端内容的话,就按下 +y 来复制