zl程序教程

您现在的位置是:首页 >  工具

当前栏目

解决mac下vscode等应用中vim光标无法快速移动

VimVSCode应用Mac 解决 快速 无法 移动
2023-09-11 14:18:38 时间

在使用vscode 或者jupyterlab的时候,可能会习惯将编辑器的键盘布局映射为vim的,但出现了一个问题,macbook的长按‘hjkl’移动光标的功能好像不能用了,想要移动光标只能一下一下的敲,非常不方便,全局开启\关闭和分应用开启\关闭这个功能的方法如下:

# 全局开启
defaults write -g ApplePressAndHoldEnabled -bool false
# 全局关闭
defaults write -g ApplePressAndHoldEnabled -bool true
# vscode开启
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool true
# firefox开启
defaults write org.mozilla.firefox ApplePressAndHoldEnabled -bool false
# firefox关闭
defaults write org.mozilla.firefox ApplePressAndHoldEnabled -bool true

 

那么另一个问题来了,命令中com.microsoft.VSCode、org.mozilla.firefox这些怎么知道呢?
这就需要导出defaults文件,在里面找

# 导出
defaults read > defaults.txt

参考:
https://www.theguild.nl/how-to-enable-or-disable-the-press-and-hold-menu-in-mac-os-x/
http://blog.fireyang.com/2018/01/16/mac-visual-studio-code-vim-hold-key-bug/

https://blog.csdn.net/MacwinWin/article/details/105157077