vscode-vim常用快捷键

Key

✅ - command done

✅ ⭐️ - command done with VS Code specific customization

⚠️ - some variations of the command are not supported

🔢 - command accepts numeric prefix

Custom commands

  • gh - show the hover tooltip.
  • gb - add an additional cursor at the next place that matches *.
  • gd - goto local declaration of identifier under the cursor

Left-right motions

StatusCommandDescription
🔢 hleft (also: CTRL-H, BS, or Left key)
🔢 lright (also: Space or Right key)
0to first character in the line (also: Home key)
^to first non-blank character in the line
🔢 $to the last character in the line (N-1 lines lower) (also: End key)
g0to first character in screen line (differs from “0” when lines wrap)
g^to first non-blank character in screen line (differs from “^” when lines wrap)
🔢 g$to last character in screen line (differs from “$” when lines wrap)
gmto middle of the screen line
🔢 |to column N (default: 1)
🔢 f{char}to the Nth occurrence of {char} to the right
🔢 F{char}to the Nth occurrence of {char} to the left
🔢 t{char}till before the Nth occurrence of {char} to the right
🔢 T{char}till before the Nth occurrence of {char} to the left
🔢 ;repeat the last “f”, “F”, “t”, or “T” N times
🔢 ,repeat the last “f”, “F”, “t”, or “T” N times in opposite direction

Up-down motions

StatusCommandDescription
🔢 kup N lines (also: CTRL-P and Up)
🔢 jdown N lines (also: CTRL-J, CTRL-N, NL, and Down)
🔢 -up N lines, on the first non-blank character
🔢 +down N lines, on the first non-blank character (also: CTRL-M and CR)
🔢 _down N-1 lines, on the first non-blank character
🔢 Ggoto line N (default: last line), on the first non-blank character
🔢 gggoto line N (default: first line), on the first non-blank character
🔢 %goto line N percentage down in the file; N must be given, otherwise it is the % command
🔢 gkup N screen lines (differs from “k” when line wraps)
🔢 gjdown N screen lines (differs from “j” when line wraps)

Text object motions

StatusCommandDescription
🔢 wN words forward
🔢 WN blank-separated WORDs forward
🔢 eN words forward to the end of the Nth word
🔢 EN words forward to the end of the Nth blank-separated WORD
🔢 bN words backward
🔢 BN blank-separated WORDs backward
🔢 [(N times back to unclosed ‘(’
🔢 [{N times back to unclosed ‘{’
🔢 ])N times forward to unclosed ‘)’
🔢 ]}N times forward to unclosed ‘}’

Pattern searches

StatusCommandDescriptionNote
✅ ⭐️🔢 /{pattern}[/[offset]]<CR>search forward for the Nth occurrence of {pattern}Currently we only support JavaScript Regex but not Vim’s in-house Regex engine.
✅ ⭐️🔢 ?{pattern}[?[offset]]<CR>search backward for the Nth occurrence of {pattern}Currently we only support JavaScript Regex but not Vim’s in-house Regex engine.
🔢 nrepeat last search
🔢 Nrepeat last search, in opposite direction
🔢 *search forward for the identifier under the cursor
🔢 #search backward for the identifier under the cursor
🔢 g*like “*”, but also find partial matches
🔢 g#like “#”, but also find partial matches

Marks and motions

StatusCommandDescription
m{a-zA-Z}mark current position with mark {a-zA-Z}
`{a-z}go to mark {a-z} within current file
`{A-Z}go to mark {A-Z} in any file
`{0-9}go to the position where Vim was previously exited
``go to the position before the last jump
`[go to the start of the previously operated or put text
`]go to the end of the previously operated or put text
`.go to the position of the last change in this file
🔢 CTRL-Ogo to Nth older position in jump list
🔢 CTRL-Igo to Nth newer position in jump list

Various motions

StatusCommandDescription
%find the next brace, bracket, comment, or “#if”/ “#else”/"#endif" in this line and go to its match
🔢 Hgo to the Nth line in the window, on the first non-blank
Mgo to the middle line in the window, on the first non-blank
🔢 Lgo to the Nth line from the bottom, on the first non-blank

Scrolling

StatusCommandDescription
🔢 CTRL-Dwindow N lines Downwards (default: 1/2 window)
🔢 CTRL-Fwindow N pages Forwards (downwards)
🔢 CTRL-Uwindow N lines Upwards (default: 1/2 window)
🔢 CTRL-Bwindow N pages Backwards (upwards)

Inserting text

StatusCommandDescription
🔢 aappend text after the cursor (N times)
🔢 Aappend text at the end of the line (N times)
🔢 iinsert text before the cursor (N times) (also: Insert)
🔢 Iinsert text before the first non-blank in the line (N times)
giinsert at the end of the last change
🔢 oopen a new line below the current line, append text (N times)
🔢 Oopen a new line above the current line, append text (N times)

in Visual block mode:

StatusCommandDescription
Iinsert the same text in front of all the selected lines
Aappend the same text after all the selected lines

Insert mode keys

leaving Insert mode:

StatusCommandDescription
Escend Insert mode, back to Normal mode
CTRL-Clike Esc, but do not use an abbreviation
CTRL-O {command}execute {command} and return to Insert mode

moving around:

StatusCommandDescription
cursor keysmove cursor left/right/up/down
shift-left/rightone word left/right
shift-up/downone screenful backward/forward
Endcursor after last character in the line
Homecursor to first character in the line

Special keys in Insert mode

StatusCommandDescriptionNote
CTRL-Einsert the character from below the cursor
CTRL-Yinsert the character from above the cursor
✅ ⭐️CTRL-Ainsert previously inserted textWe apply previously document change made in previous Insert session and we only apply changes that happen under cursor
✅ ⭐️CTRL-@insert previously inserted text and stop Insert modeAs above
CTRL-R {0-9a-z%#:.-="}insert the contents of a register
CTRL-Ninsert next match of identifier before the cursor
CTRL-Pinsert previous match of identifier before the cursor
BS or CTRL-Hdelete the character before the cursor
Deldelete the character under the cursor
CTRL-Wdelete word before the cursor
CTRL-Udelete all entered characters in the current line
CTRL-Tinsert one shiftwidth of indent in front of the current line
CTRL-Ddelete one shiftwidth of indent in front of the current line

Deleting text

StatusCommandDescription
🔢 xdelete N characters under and after the cursor
🔢 Deldelete N characters under and after the cursor
🔢 Xdelete N characters before the cursor
🔢 d{motion}delete the text that is moved over with {motion}
{visual}ddelete the highlighted text
🔢 dddelete N lines
🔢 Ddelete to the end of the line (and N-1 more lines)
🔢 Jjoin N-1 lines (delete EOLs)
{visual}Jjoin the highlighted lines
🔢 gJlike “J”, but without inserting spaces
{visual}gJlike “{visual}J”, but without inserting spaces
:[range]d [x]delete [range] lines [into register x]

Copying and moving text

StatusCommandDescription
"{char}use register {char} for the next delete, yank, or put
"*use register * to access system clipboard
:regshow the contents of all registers
:reg {arg}show the contents of registers mentioned in {arg}
🔢 y{motion}yank the text moved over with {motion} into a register
{visual}yyank the highlighted text into a register
🔢 yyyank N lines into a register
🔢 Yyank N lines into a register
🔢 pput a register after the cursor position (N times)
🔢 Pput a register before the cursor position (N times)
🔢 ]plike p, but adjust indent to current line
🔢 [plike P, but adjust indent to current line
🔢 gplike p, but leave cursor after the new text
🔢 gPlike P, but leave cursor after the new text

Changing text

StatusCommandDescriptionNote
🔢 r{char}replace N characters with {char}
✅ ⭐️🔢 Renter Replace mode (repeat the entered text N times){count} is not supported
{visual}r{char}in Visual block, visual, or visual line modes: Replace each char of the selected text with {char}

(change = delete text and enter Insert mode)

StatusCommandDescription
🔢 c{motion}change the text that is moved over with {motion}
{visual}cchange the highlighted text
🔢 ccchange N lines
🔢 Schange N lines
🔢 Cchange to the end of the line (and N-1 more lines)
🔢 schange N characters
{visual}cin Visual block mode: Change each of the selected lines with the entered text
{visual}Cin Visual block mode: Change each of the selected lines until end-of-line with the entered text
{visual}~switch case for highlighted text
{visual}umake highlighted text lowercase
{visual}Umake highlighted text uppercase
g~{motion}switch case for the text that is moved over with {motion}
gu{motion}make the text that is moved over with {motion} lowercase
gU{motion}make the text that is moved over with {motion} uppercase
{visual}g?perform rot13 encoding on highlighted text
g?{motion}perform rot13 encoding on the text that is moved over with {motion}
🔢 CTRL-Aadd N to the number at or after the cursor
🔢 CTRL-Xsubtract N from the number at or after the cursor
🔢 <{motion}move the lines that are moved over with {motion} one shiftwidth left
🔢 <<move N lines one shiftwidth left
🔢 >{motion}move the lines that are moved over with {motion} one shiftwidth right
🔢 >>move N lines one shiftwidth right
🔢 gq{motion}format the lines that are moved over with {motion} to ‘textwidth’ length

Complex changes

StatusCommandDescriptionNote
🔢 ={motion}filter the lines that are moved over through ‘equalprg’
🔢 ==filter N lines through ‘equalprg’
{visual}=filter the highlighted lines through ‘equalprg’
✅ ⭐️ ⚠️:[range]s[ubstitute]/{pattern}/{string}/[g][c]substitute {pattern} by {string} in [range] lines; with [g], replace all occurrences of {pattern}; with [c], confirm each replacementCurrently we only support JavaScript Regex and only options gi are implemented

Visual mode

StatusCommandDescription
vstart highlighting characters or stop highlighting
Vstart highlighting linewise or stop highlighting
CTRL-Vstart highlighting blockwise or stop highlighting
oexchange cursor position with start of highlighting
gvstart highlighting on previous visual area

Text objects (only in Visual mode or after an operator)

StatusCommandDescription
🔢 awSelect “a word”
🔢 iwSelect “inner word”
🔢 aWSelect “a WORD”
🔢 iWSelect “inner WORD”
🔢 a], a[select ‘[’ ‘]’ blocks
🔢 i], i[select inner ‘[’ ‘]’ blocks
🔢 ab, a(, a)Select “a block” (from “[(” to “])”)
🔢 ib, i), i(Select “inner block” (from “[(” to “])”)
🔢 a>, a<Select “a <> block”
🔢 i>, i<Select “inner <> block”
🔢 aB, a{, a}Select “a Block” (from “[{” to “]}”)
🔢 iB, i{, i}Select “inner Block” (from “[{” to “]}”)
🔢 atSelect “a tag block” (from <aaa> to </aaa>)
🔢 itSelect “inner tag block” (from <aaa> to </aaa>)
🔢 a’Select “a single quoted string”
🔢 i’Select “inner single quoted string”
🔢 a"Select “a double quoted string”
🔢 i"Select “inner double quoted string”
🔢 a`Select “a backward quoted string”
🔢 i`Select “inner backward quoted string”
🔢 iaSelect “inner argument” from the targets.vim plugin
🔢 aaSelect “an argument” from the targets.vim plugin

Repeating commands

StatusCommandDescriptionNote
✅ ⭐️🔢 .repeat last change (with count replaced with N)Content changes that don’t happen under cursor can not be repeated.
q{a-z}record typed characters into register {a-z}
qstop recording
🔢 @{a-z}execute the contents of register {a-z} (N times)
🔢 @@repeat previous @{a-z} (N times)

options

StatusCommandDescriptionNote
:se[t] {option}set boolean option (switch it on), show string or number option
:se[t] no{option}reset boolean option (switch it off)
:se[t] inv{option}invert boolean option
:se[t] {option}={value}set string/number option to {value}
:se[t] {option}+={value}append {value} to string option, add {value} to number option
✅ ⭐️:se[t] {option}-={value}remove {value} to string option, subtract {value} from number optionWe don’t support string option here.
:se[t] {option}?show value of {option}

Since the list is too long, now we just put those already supported options here.

StatusCommandDefault ValueDescription
tabstop (ts)4. we use Code’s default value tabSize instead of Vimnumber of spaces that <Tab> in file uses
hlsearch (hls)falseWhen there is a previous search pattern, highlight all its matches.
ignorecase (ic)trueIgnore case in search patterns.
smartcase (scs)trueOverride the ‘ignorecase’ option if the search pattern contains upper case characters.
iskeyword (isk)@,48-57,_,128-167,224-235keywords contain alphanumeric characters and ‘_’. If there is no user setting for iskeyword, we use editor.wordSeparators properties.
scroll (scr)20Number of lines to scroll with CTRL-U and CTRL-D commands.
expandtab (et)True. we use Code’s default value insertSpaces instead of Vimuse spaces when <Tab> is inserted
autoindenttrueKeep indentation when doing cc or S in normal mode to replace a line.

Undo/Redo commands

StatusCommandDescriptionNote
🔢 uundo last N changesCurrent implementation may not cover every case perfectly.
🔢 CTRL-Rredo last N undone changesAs above.
Urestore last changed line

External commands

StatusCommandDescription
:sh[ell]start a shell
:!{command}execute {command} with a shell

Ex ranges

StatusCommandDescriptionNote
,separates two line numbers
✅ ⭐️;idem, set cursor to the first line number before interpreting the second oneThe cursor movement is not included.
{number}an absolute line number
.the current line
$the last line in the file
%equal to 1,$ (the entire file)
*equal to ‘<,’> (visual area)
'tposition of mark t
+[num]add [num] to the preceding line number (default: 1)
-[num]subtract [num] from the preceding line number (default: 1)

Editing a file

StatusCommandDescriptionNote
✅ ⭐️:e[dit] {file}Edit {file}.We will open file in a new Tab of current Grouped Editor instead of opening in current tab.

Multi-window commands

StatusCommandDescriptionNote
✅ ⭐️:e[dit] {file}Edit {file}.We will open file in a new Tab of current Grouped Editor instead of opening in current tab.
✅ ⭐️<ctrl-w> hlSwitching between windows.As we don’t have the concept of Window in VS Code, we are mapping these commands to switching between Grouped Editors.
:sp {file}Split current window in two.
✅ ⭐️:vsp {file}Split vertically current window in two.
<ctrl-w> sSplit current window in two.
✅ ⭐️<ctrl-w> vSplit vertically current window in two.
✅ ⭐️<ctrl-w> oClose other editor groups.
:newCreate a new window horizontally and start editing an empty file in it.
✅ ⭐️:vne[w]Create a new window vertically and start editing an empty file in it.

Tabs

StatusCommandDescriptionNote
:tabn[ext] 🔢Go to next tab page or tab page {count}. The first tab page has number one.
{count}<C-PageDown>, {count}gtSame as above
:tabp[revious] 🔢Go to the previous tab page. Wraps around from the first one to the last one.
:tabN[ext] 🔢Same as above
{count}<C-PageUp>, {count}gTSame as above
:tabfir[st]Go to the first tab page.
:tabl[ast]Go to the last tab page.
:tabe[dit] {file}Open a new tab page with an empty window, after the current tab page
:tabnew {file}Open a new tab page with an empty window, after the current tab page
✅ ⭐️:tabc[lose][!] 🔢Close current tab page or close tab page {count}.Code will close tab directly without saving.
✅ ⭐️:tabo[nly][!]Close all other tab pages.! is not supported, Code will close tab directly without saving.
:tabm[ove][n]Move the current tab page to after tab page N.

Folding

Fold methods

The folding method can be set with the ‘foldmethod’ option. This is currently not possible as we are relying on Code’s Fold logic.

Fold commands

Pretty much everything fold-related is blocked by this issue.

StatusCommandDescription
zoOpen one fold under the cursor.When a count is given, that many folds deep will be opened.
zOOpen all folds under the cursor recursively.
zcClose one fold under the cursor. When a count is given, that many folds deep are closed.
zCClose all folds under the cursor recursively.
zaWhen on a closed fold: open it. When on an open fold: close it and set ‘foldenable’.
zMClose all folds: set ‘foldlevel’ to 0. ‘foldenable’ will be set.
zROpen all folds. This sets ‘foldlevel’ to highest fold level.

主要参考官方:
https://github.com/VSCodeVim/Vim/blob/HEAD/ROADMAP.md
把一些个人觉得相对不重要的以及没有实现的快捷键去掉了

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值