On Save
想 VS Code 在保存时,自动:
- 删除行末空格
- 在文件尾留一行空行,但删除其它多余空行
Ctrl
+ ,
打开设置,在 Text Editor -> Files,找:
- Insert Final Newline
- Trim Final Newlines
- Trim Trailing Whitespace
勾上即可。
Vim 上可用 BufWritePre
事件实现同样功能,见 [2] 配置文件中的 autocmd BufWritePre
命令和 Before_Saving
函数。
Jupyter Lab 可用插件实现,见 [4,5]。
Stop Folder Tree Auto-locating
关闭左侧目录树的自动跳转(防止打开 logs/ 等多文件的目录时,无脑跳到当前文件的位置,费事拖来拖去),参考 [3],打开设置后搜索 explorer.autoReveal
,或在 Features -> Explorer -> Auto Reveal,选 false
关闭。
Gutter Indicators
用 vscode 打开一个 git 管理的代码文件夹,如果某文件有修改,vscode 会在左侧行号旁用不同颜色的竖线展示,如:
左侧行号旁的蓝色竖线表示这些行改过。参考 [6,7],这叫 gutter indicators。但有时用 vscode 打开工程时,却没有这些竖线,如:
由下半屏的 Source Control 视图可见此 test.sh 文件有修改,上半屏的 Explorer 视图却没有用颜色竖线展示。参考 [6] 中的此条回答,不显示 gutter indicator 是因为用 vscode 打开的项目路径中包含软链接,而不是其直接路径。具体到本例,我用 vscode 打开的项目路径是:
/home/itom/codes/test-proj
然而其中 /home/itom/codes 是个软链接,即:
/home/itom/codes -> /data/itom/codes
所以 vscode 打开 /home/itom/codes/test-proj 就会不显示 gutter indicator,而换成打开 /data/itom/codes/test-proj 后,gutter indicator 就能正常显示了: