vim tips
2022-10-08
cursor movement
| Act | Repeate | Reverse | Intent |
|---|---|---|---|
| {edit} | . | u | Make a change |
| f{char}/t{char} | ; | , | Scan line for next character |
| F{char}/T{char} | ; | , | Scan line for next character |
| /pattern | n | N | Scan document for next match |
| ?pattern | n | N | Scan document for previous match |
| :s/target/replacement | & | u | Perform substitution |
| qx{changes}q | @x | u | Execute a sequence of changes |
substitution
| Act | |
|---|---|
| :%s/old/new/gc | substitution and conform |
| {number} | add {number times(default 1)} to the first digital on current line |
| {number} | substruct {number times(default 1)} to the first digital on current line |
normal mode:
| Trigger | Effect |
|---|---|
| c | Change |
| d | Delete |
| y | Yank into register |
| ~ | Swap case for character |
| g~ | Swap case |
| gu | Make lowercase |
| gU | Make uppercase |
| > | Shift right |
| < | Shift left |
| = | Autoindent |
Insert mode:
| act | intent |
|---|---|
<C-[> |
Switch to normal mode(the same as ) |
<C-o> |
Switch to normal mode(temporarily back to normal mode) |
visual mode:
| act | intent |
|---|---|
| gv | Reselect the last visual selection. |
| o | Go to other end of highlighted text. |
| .(dot) | Repeate the last visual operation |
| > | indentation |
| U | converts characters to uppercase |
| gUit | converts characters to uppercase in tags |
Command mode:
| act | intent |
|---|---|
| :[range]delete(d)[x] | Delet specified lines [into reister x] |
| :[range]yank(y)[x] | Yank specified lines [into reister x] |
| :[range]put(p)[x] | Put the text from register x after the specified line |
| :[range]copy(t) | Copy the specified lines to below the line |
| {address} | spcified by {address} |
| :[range]move(m) | Move the specified lines to below the line |
| {address} | spcified by {address} |
| :[range]join(j) | Join the specified lines |
| :[range]normal | Execute Normal mode {commands} on each |
| {commands} | specified line. |
| :[range]substitute(s) | Replace occurrences of {pattern} with {string} |
| /{pattern}/{string}/ | on each specified line. |
| [flags] | |
| :[range]global/ | Execute the Ex command [cmd] on all specified |
| {pattern}/[cmd] | lines where the {pattern} matches. |
| % | Global range |
Register:
| act | intent |
|---|---|
| “0 | yank default register |
| “_ | black hole register |
| “+ | system clipboard |
| “* | system selection(middle mouse button) |
| “= | expression register |
| “% | name of the current file |
| “# | name of the alternate file |
| “. | last inserted text |
| “: | last Ex command |
| “/ | last search pattern |
Macro:
| act | intent |
|---|---|
| @@ | |
| q{captal letter} | append command for exist macro |
Search:
| act | intent |
|---|---|
| /{characters}/b | seach {characters} and couror jump to the begin of the characters |
| /{characters}/e | seach {characters} and couror jump to the end of the characters |