Tools - Editor - Visual Studio Code

闷骚的程序员

快捷键

https://code.visualstudio.com/docs/reference/default-keybindings

C –> Ctrl

S –> Shift

M –> Alt

Cmd –> Command

基础编辑

功能Mac OS X
在下方插入行Cmd-Enter
在上方插入行Cmd-S-Enter
行下移Option-Down
行上移Option-Up
行注释Cmd-/
块注释Option-S-a
文件格式化Option-S-f
选中内容格式化Cmd-k f
跳到定义F12
查看定义Option-F12
查看引用S-F12
跳到实现Cmd-F12
Quick FixCmd-.
参数提示Cmd-S-Space

导航

功能Mac OS X
搜索 SymbolsCmd-t
搜索文件Cmd-p
命令面板Cmd-S-p
后退C–
前进C-S–

文件管理

功能Mac OS X
打开文件Cmd-o

显示

功能Mac OS X
开关侧边栏Cmd-b
资源管理器Cmd-S-e
搜索Cmd-S-f
运行和调试Cmd-S-d
面板Cmd-j
Output面板Cmd-S-u
Markdown 侧边预览Cmd-k v
TerminalC-`

使用 VSCode 作为 mergetool

编辑 ~/.gitconfig 文件,添加如下内容:

[merge]
    tool = vscode
[mergetool "vscode"]
    cmd = code --wait $MERGED

需要的时候执行 git mergetool 就会调起了。

参考:https://blog.kulman.sk/using-vscode-as-git-merge-tool/

使用 VSCode 作为 git commit message 编辑器

git config --global core.editor "code -w"

VSCodeVim 支持按键重复

在 macOS,默认情况 VSCodeVim 模式下是不支持按键重复的,比如你在 Normal 模式下长按 L,结果光标只向右移动了一次,而没有像你预期的那样一直移动。

启用按键重复的方法在插件的 REAME 有说明,链接:https://github.com/VSCodeVim/Vim#mac

方法:

按需执行下面的某一行命令并重启 VSCode。

$ defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false         # For VS Code
$ defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false # For VS Code Insider
$ defaults write com.visualstudio.code.oss ApplePressAndHoldEnabled -bool false    # For VS Codium
$ defaults delete -g ApplePressAndHoldEnabled                                      # If necessary, reset global default

如果有需要,调整「系统偏好设置」—「键盘」里的「按键重复」和「重复前延迟」。

在命令行使用 code 命令启动 VSCode

默认并不支持,但可以使用以下方式开启:

command+shift+p 打开命令面板,输入 shell,选择 Shell Command: Install 'code' command in PATH

  • code . 打开当前目录;
  • code -n . 在窗口打开当前目录;
  • code -r . 复用现有窗口打开当前目录;
  • code -g <file:line:column> 打开指定文件并跳转到指定行列;

code -h 查看更多命令。

文档信息

Search

    Table of Contents

    目录