0%

vsCodeVim插件

https://github.com/VSCodeVim/Vim#mac

快速移动写代码,除了输入字符之外最常用的操作就是移动光标。vim除了hjkl ctrl+u ctr+f外还有更快捷的移动方式,这里介绍2个插件都是vscode自带的。

  1. vim-easymotion

设置”vim.easymotion”: true 开启这个模式。
<leader><leader> t/T <char> 能够向前/向后快速到达可见范围内的某字符()的位置。
<leader><leader> w/b 向前/向后到达可见范围内任何单词的开头。
<leader><leader> e/ge 向前/向后到达可见范围内任何单词的结尾。
<leader><leader> k/j 向前/向后到达可见范围内任何行的行首。

  1. vim-sneak

sneak模式下键入s后,再输入2个字符就可以跳转到目标位置。
s 往前跳转到目标位置。
S 往后跳转到目标位置。

链接:https://www.jianshu.com/p/cbfa86c8d8a5

3.vim-surround

Based on surround.vim, the plugin is used to work with surrounding characters like parenthesis, brackets, quotes, and XML tags.

Setting Description Type Default Value
vim.surround Enable/disable vim-surround Boolean true

t or < as <desired char> or <existing char> will do tags and enter tag entry mode. Using <CR> instead of > to finish changing a tag will preserve any existing attributes.

Surround Command Description
d s <existing char> Delete existing surround
c s <existing char> <desired char> Change surround existing to desired
y s <motion> <desired char> Surround something with something using motion (as in “you surround”)
S <desired char> Surround when in visual modes (surrounds full selection)

Some examples:

  • "test" with cursor inside quotes type cs”‘ to end up with 'test'
  • "test" with cursor inside quotes type ds” to end up with test
  • test with cursor on word test type ysaw) to end up with (test)

苹果系统问题 To enable key-repeating

1
2
3
4
5
6
7
# For VS Code
$ defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false
# For VS Code Insider
$ defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false

# 还原设置
$ defaults delete -g ApplePressAndHoldEnabled