VSCode-Cookbook

发布时间 2023-06-27 19:31:07作者: Gao科技

使用portable mode

https://code.visualstudio.com/docs/editor/portable
方便搬运,管理数据.

vscode在windows, 要remote ssh不能联网的linux(A)? 先在能联网的linux(B)中把改装的都装好,能用,再把~/.vscode-server从B搬到A.

https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions

portable升级, 只要把data目录移到新的vscode中就行.

Update Portable VS Code
On Windows and Linux, you can update VS Code by copying the data folder over to a more recent version of VS Code.
On macOS, automatic updates should work as always, no extra work needed.
-- Portable Mode in Visual Studio Code

submodule

"submodules which won't be opened automatically", 把这个选项调大一点, 默认10: git.detectSubmodulesLimit.

Tips and Tricks

https://code.visualstudio.com/docs/getstarted/tips-and-tricks
https://code.visualstudio.com/docs/editor/codebasics, 多光标,列模式,...

  • ctrl-p, 直接查找文件; 也可以输入#, @, >, 分别是C-T, C-S-O, C-S-P; 还可以输入?.
  • 命令行: code -n, new window; code --diff file1 file2, 不支持比较文件夹; code -h; 选项不多; Command Line
  • errors/warnings: C-S-M, A-F8, F8, S-F8
  • split: C-\ (右边), C-K C-\ (下面), in explorer: A-click, C-Enter
  • 切换group, C-1, 2, 3, ...;
  • ctrl-alt-left/write, 把tab移到左边/右边的group
  • to match one or more characters in a path segment
    ? to match on one character in a path segment
    ** to match any number of path segments, including none
    {} to group conditions (for example {/*.html,/*.txt} matches all HTML and text files)
    [] to declare a range of characters to match (example.[0-9] to match on example.0, example.1, …)
    -- Basic Editing in Visual Studio Code

https://code.visualstudio.com/docs/getstarted/userinterface
https://code.visualstudio.com/docs/getstarted/settings#_default-settings
https://code.visualstudio.com/docs/getstarted/settings#_languagespecific-editor-settings

key bindings

https://code.visualstudio.com/docs/getstarted/keybindings
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf

Ctrl-K Ctrl-S: 查询如"Ctrl+T", 可查找键盘冲突
用户修改过的: @source:user

中英文等宽

14寸1920x1080, Win10, 设置如下(前两个字体就够了), 字号14,16都可以. 需要下载UbuntuMono字体.

如果分表率低如14寸1366x768,可尝试

Inconsolata, '黑体'

目录的git history

左侧Explorer, 右键一个目录, Open Folder History.

Have a look at the recent GitLens version (11.4.0, released on 2021-04-08) : https://github.com/eamodio/vscode-gitlens/blob/main/CHANGELOG.md
This VSCode extension has just introduced a way to display the git history of a folder. Right click on a folder in the file explorer tree, select Open Folder History and you should then see the expected log in a dedicated view.
-- How can I view the Git history for a folder, in Visual Studio Code? - Stack Overflow

foam/Zettelkasten

https://github.com/foambubble/foam
https://zettelkasten.de/posts/overview/
https://www.buildingasecondbrain.com/

c/c++

https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
https://code.visualstudio.com/docs/cpp/cpp-debug
https://code.visualstudio.com/docs/editor/debugging

https://code.visualstudio.com/docs/editor/integrated-terminal
https://www.growingwiththeweb.com/2017/03/mastering-vscodes-terminal.html

完整打印字符串, 默认打印前200字符:

"Configurations": [
	{
		...
		"type": cppdbg",
		...
		"setupCommands": [
			{
				"text": "set print element 0"
			}
		]
	}
]

调式core文件:https://stackoverflow.com/questions/55736235/how-do-you-debug-a-linux-core-dump-using-vscode

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cppdbg",
            "request": "launch",
            "name": "Open a core dump(c/c++)",
            "program": "<Path to the program here>",
            "coreDumpPath": "${input:coreFileName}",
            "cwd": "${workspaceFolder}",
            "MIMode": "lldb" // or gdb, if you are using gdb
        }
    ],
    "inputs": [
      {
        "id": "coreFileName",
        "type": "promptString",
        "description": "Enter core file path"
      }
    ]
}

  1. 使用一个命令打开特定文件? 不支持: https://github.com/microsoft/vscode/issues/134949
    1. 有一个插件, HTML Related Links, 没试过: https://stackoverflow.com/questions/57080345/keybinding-to-open-a-specific-file-in-vscode

markdown

vim

2015年vscode发布, 慢慢从emacs转向vscode, 直接在centos6/7 gnome里面跑;
2022/12/9, 丢掉了vscode vim插件(主要是模式切换中文搞不定,im-select不好用), 解放了.

git

svn

Git svn rebase : checksum mismatch, https://stackoverflow.com/questions/3156744/git-svn-rebase-checksum-mismatch

See what was the revision number of the last change on the file:
git svn log chrome/test/functional/search_engines.py
Reset svn to be closest parent before that revision:
git svn reset -r62248 -p
Do a git svn fetch!
Dance at your success.

remote-ssh


Bad Owner or Permissions on username.ssh\config file

Actually I solved this problem in vscode-remote by modifying remote.SSH.configFile ...
IdentityFile C:/Users/lilei/.ssh/id_rsa
-- Bad Owner or Permissions on username.ssh\config file · Issue #3210 · microsoft/vscode-docs · GitHub


hyper-v虚拟机,主机没联网,ssh建立连接特别慢,2分钟?
抓了包,发现是dns,换个dns? 或者修改/etc/ssh/sshd_config, useDNS no, systemctl restart sshd.