mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
19 KiB
19 KiB
Left-right motions
Status | Command | Description |
---|---|---|
✅ | 🔢 h | left (also: CTRL-H, , or key) |
✅ | 🔢 l | right (also: or key) |
✅ | 0 | to first character in the line (also: key) |
✅ | ^ | to first non-blank character in the line |
✅ | 🔢 $ | to the last character in the line (N-1 lines lower) (also: key) |
g0 | to 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) | |
gm | to 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
Status | Command | Description |
---|---|---|
✅ | 🔢 k | up N lines (also: CTRL-P and ) |
✅ | 🔢 j | up N lidown N lines (also: CTRL-J, CTRL-N, , and ) |
🔢 - | up N liup N lines, on the first non-blank character | |
🔢 + | up N lidown N lines, on the first non-blank character (also: CTRL-M and ) | |
🔢 _ | up N lidown N-1 lines, on the first non-blank character | |
✅ | 🔢 G | up N ligoto line N (default: last line), on the first non-blank character |
✅ | 🔢 gg | up N ligoto line N (default: first line), on the first non-blank character |
✅ | 🔢 % | up N ligoto line N percentage down in the file; N must be given, otherwise it is the |
🔢 gk | up N screen lines (differs from "k" when line wraps) | |
🔢 gj | own N screen lines (differs from "j" when line wraps) |
Text object motions
Status | Command | Description |
---|---|---|
✅ | 🔢 w | N words forward |
✅ | 🔢 W | N blank-separated |
✅ | 🔢 e | N words forward to the end of the Nth word |
✅ | 🔢 E | N words forward to the end of the Nth blank-separated |
✅ | 🔢 b | N words backward |
✅ | 🔢 B | N blank-separated |
✅ | 🔢 ge | N words backward to the end of the Nth word |
✅ | 🔢 gE | N words backward to the end of the Nth blank-separated |
🔢 ) | N sentences forward | |
🔢 ( | N sentences backward | |
✅ | 🔢 } | N paragraphs forward |
✅ | 🔢 { | N paragraphs backward |
🔢 ]] | N sections forward, at start of section | |
🔢 [[ | N sections backward, at start of section | |
🔢 ][ | N sections forward, at end of section | |
🔢 [] | N sections backward, at end of section | |
🔢 [( | N times back to unclosed '(' | |
🔢 [{ | N times back to unclosed '{' | |
🔢 [m | N times back to start of method (for Java) | |
🔢 [M | N times back to end of method (for Java) | |
🔢 ]) | N times forward to unclosed ')' | |
🔢 ]} | N times forward to unclosed '}' | |
🔢 ]m | N times forward to start of method (for Java) | |
🔢 ]M | N times forward to end of method (for Java) | |
🔢 [# | N times back to unclosed "#if" or "#else" | |
🔢 ]# | N times forward to unclosed "#else" or "#endif" | |
🔢 [* | N times back to start of comment "/*" | |
🔢 ]* | N times forward to end of comment "*/" |
Various motions
Status | Command | Description |
---|---|---|
✅ | % | find the next brace, bracket, comment, or "#if"/ "#else"/"#endif" in this line and go to its match |
🔢 H | go to the Nth line in the window, on the first non-blank | |
M | go to the middle line in the window, on the first non-blank | |
🔢 L | go to the Nth line from the bottom, on the first non-blank | |
🔢 go | go to Nth byte in the buffer | |
:[range]go[to] [off] | go to [off] byte in the buffer |
These only work when 'wrap' is off:
Status | Command | Description |
---|---|---|
🔢 zh | scroll screen N characters to the right | |
🔢 zl | scroll screen N characters to the left | |
🔢 zH | scroll screen half a screenwidth to the right | |
🔢 zL | scroll screen half a screenwidth to the left |
Inserting text
Status | Command | Description |
---|---|---|
✅ | 🔢 a | append text after the cursor (N times) |
✅ | 🔢 A | append text at the end of the line (N times) |
✅ | 🔢 i | insert text before the cursor (N times) (also: ) |
✅ | 🔢 I | insert text before the first non-blank in the line (N times) |
🔢 gI | insert text in column 1 (N times) | |
✅ | 🔢 o | open a new line below the current line, append text (N times) |
✅ | 🔢 O | open a new line above the current line, append text (N times) |
in Visual block mode:
Status | Command | Description |
---|---|---|
I | insert the same text in front of all the selected lines | |
A | append the same text after all the selected lines |
Insert mode keys
leaving Insert mode:
Status | Command | Description |
---|---|---|
✅ | end Insert mode, back to Normal mode | |
CTRL-C | like , but do not use an abbreviation | |
CTRL-O {command} | execute {command} and return to Insert mode |
moving around:
Status | Command | Description |
---|---|---|
✅ | cursor keys | move cursor left/right/up/down |
✅ | shift-left/right | one word left/right |
✅ | shift-up/down | one screenful backward/forward |
✅ | cursor after last character in the line | |
✅ | cursor to first character in the line |
Special inserts
Status | Command | Description |
---|---|---|
:r [file] | insert the contents of [file] below the cursor | |
:r! {command} | insert the standard output of {command} below the cursor |
Deleting text
Status | Command | Description |
---|---|---|
✅ | 🔢 x | delete N characters under and after the cursor |
🔢 |
delete N characters under and after the cursor | |
✅ | 🔢 X | delete N characters before the cursor |
✅ | 🔢 d{motion} | delete the text that is moved over with {motion} |
✅ | {visual}d | delete the highlighted text |
✅ | 🔢 dd | delete N lines |
✅ | 🔢 D | delete to the end of the line (and N-1 more lines) |
✅ | 🔢 J | join N-1 lines (delete s) |
{visual}J | join the highlighted lines | |
🔢 gJ | like "J", but without inserting spaces | |
{visual}gJ | like "{visual}J", but without inserting spaces | |
:[range]d [x] | delete [range] lines [into register x] |
Copying and moving text
Status | Command | Description |
---|---|---|
"{char} | use register {char} for the next delete, yank, or put | |
:reg | show 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}y | yank the highlighted text into a register |
✅ | 🔢 yy | yank N lines into a register |
✅ | 🔢 Y | yank N lines into a register |
✅ | 🔢 p | put a register after the cursor position (N times) |
✅ | 🔢 P | put a register before the cursor position (N times) |
🔢 ]p | like p, but adjust indent to current line | |
🔢 [p | like P, but adjust indent to current line | |
🔢 gp | like p, but leave cursor after the new text | |
🔢 gP | like P, but leave cursor after the new text |
Changing text
Status | Command | Description |
---|---|---|
⚠️ | 🔢 r{char} | replace N characters with {char} |
🔢 gr{char} | replace N characters without affecting layout | |
🔢 R | enter Replace mode (repeat the entered text N times) | |
🔢 gR | enter virtual Replace mode: Like Replace mode but without affecting layout | |
v_b_r |
(change = delete text and enter Insert mode)
Status | Command | Description |
---|---|---|
✅ | 🔢 c{motion} | change the text that is moved over with {motion} |
✅ | {visual}c | change the highlighted text |
✅ | 🔢 cc | change N lines |
🔢 S | change N lines | |
⚠️ | 🔢 C | change to the end of the line (and N-1 more lines) |
🔢 s | change N characters | |
{visual}c | in Visual block mode: Change each of the selected lines with the entered text | |
{visual}C | in Visual block mode: Change each of the selected lines until end-of-line with the entered text | |
✅ | 🔢 ~ | switch case for N characters and advance cursor |
{visual}~ | switch case for highlighted text | |
{visual}u | make highlighted text lowercase | |
{visual}U | make 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} |
| :1234: CTRL-A | add N to the number at or after the cursor
| :1234: CTRL-X | subtract 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 | :[range]ce[nter] [width] | center the lines in [range] | :[range]le[ft] [indent] | left-align the lines in [range] (with [indent]) | :[range]ri[ght] [width] | right-align the lines in [range]
Visual mode
Status | Command | Description |
---|---|---|
✅ | v | start highlighting characters |
✅ | V | start highlighting linewise |
CTRL-V | start highlighting blockwise | |
o | exchange cursor position with start of highlighting | |
gv | start highlighting on previous visual area | |
✅ | v | highlight characters or stop highlighting |
✅ | V | highlight linewise or stop highlighting |
CTRL-V | highlight blockwise or stop highlighting |
Text objects (only in Visual mode or after an operator)
Status | Command | Description |
---|---|---|
✅ | 🔢 aw | Select "a word" |
✅ | 🔢 iw | Select "inner word" |
🔢 aW | Select "a | WORD |
🔢 iW | Select "inner | WORD |
🔢 as | Select "a sentence" | |
🔢 is | Select "inner sentence" | |
🔢 ap | Select "a paragraph" | |
🔢 ip | Select "inner paragraph" | |
🔢 ab | Select "a block" (from "[(" to "])") | |
🔢 ib | Select "inner block" (from "[(" to "])") | |
🔢 aB | Select "a Block" (from "[{" to "]}") | |
🔢 iB | Select "inner Block" (from "[{" to "]}") | |
🔢 a> | Select "a <> block" | |
🔢 i> | Select "inner <> block" | |
🔢 at | Select "a tag block" (from to ) | |
🔢 it | Select "inner tag block" (from to ) | |
🔢 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" |
Repeating commands
Status | Command | Description |
---|---|---|
✅ | 🔢 . | repeat last change (with count replaced with N) |
q{a-z} | record typed characters into register {a-z} | |
q{A-Z} | record typed characters, appended to register {a-z} | |
q | stop recording | |
🔢 @{a-z} | execute the contents of register {a-z} (N times) | |
🔢 @@ | repeat previous @{a-z} (N times) | |
:@{a-z} | execute the contents of register {a-z} as an Ex command | |
:@@ | repeat previous :@{a-z} | |
:[range]g[lobal]/{pattern}/[cmd] | execute Ex command [cmd] (default: ":p") on the lines within [range] where {pattern} matches | |
:[range]g[lobal]!/{pattern}/[cmd] | execute Ex command [cmd] (default: ":p") on the lines within [range] where {pattern} does NOT match | |
:so[urce] {file} | read Ex commands from {file} | |
:so[urce]! {file} | read Vim commands from {file} | |
:sl[eep] [sec] | don't do anything for [sec] seconds | |
🔢 gs | goto Sleep for N seconds |
Marks and motions
Status | Command | Description |
---|---|---|
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 position when last editing this file | |
`[ | 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 start of the (previous) Visual area | |
`> | go to the end of the (previous) Visual area | |
`. | go to the position of the last change in this file | |
'{a-zA-Z0-9[]'"<>.} | same as `, but on the first non-blank in the line | |
:marks | print the active marks | |
🔢 CTRL-O | go to Nth older position in jump list | |
🔢 CTRL-I | go to Nth newer position in jump list | |
:ju[mps] | print the jump list |
Complex changes
Status | Command | Description |
---|---|---|
🔢 !{motion}{command} | filter the lines that are moved over through {command} | |
🔢 !!{command} | filter N lines through {command} | |
{visual}!{command} | filter the highlighted lines through {command} | |
:[range]! {command} | filter [range] lines through {command} | |
🔢 ={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 replacement | |
:[range]s[ubstitute] [g][c] | repeat previous ":s" with new range and options | |
& | Repeat previous ":s" on current line without options | |
:[range]ret[ab][!] [tabstop] | set 'tabstop' to new value and adjust white space accordingly |
Special keys in Insert mode
Status | Command | Description |
---|---|---|
CTRL-V {char}.. | insert character literally, or enter decimal byte value | |
or or CTRL-M or CTRL-J | begin new line | |
CTRL-E | insert the character from below the cursor | |
CTRL-Y | insert the character from above the cursor | |
CTRL-A | insert previously inserted text | |
CTRL-@ | insert previously inserted text and stop Insert mode | |
CTRL-R {0-9a-z%#:.-="} | insert the contents of a register | |
CTRL-N | insert next match of identifier before the cursor | |
CTRL-P | insert previous match of identifier before the cursor | |
CTRL-X ... | complete the word before the cursor in various ways | |
or CTRL-H | delete the character before the cursor | |
delete the character under the cursor | ||
CTRL-W | delete word before the cursor | |
CTRL-U | delete all entered characters in the current line | |
CTRL-T | insert one shiftwidth of indent in front of the current line | |
CTRL-D | delete one shiftwidth of indent in front of the current line | |
0 CTRL-D | delete all indent in the current line | |
^ CTRL-D | delete all indent in the current line, restore indent in next line |
Scrolling
Status | Command | Description |
---|---|---|
🔢 CTRL-E | window N lines downwards (default: 1) | |
🔢 CTRL-D | window N lines Downwards (default: 1/2 window) | |
🔢 CTRL-F | window N pages Forwards (downwards) | |
🔢 CTRL-Y | window N lines upwards (default: 1) | |
🔢 CTRL-U | window N lines Upwards (default: 1/2 window) | |
🔢 CTRL-B | window N pages Backwards (upwards) | |
z or zt | redraw, current line at top of window | |
⚠️ | z. or zz | redraw, current line at center of window |
z- or zb | redraw, current line at bottom of window |