はじめに
Vi コマンドについてまとめる。
Vi Editor
| command | Explain |
|---|---|
| vi file | Edit file |
| vim file | Same as vi, but more features |
| view file | Starts vim in read-only mode |
| command | Explain |
|---|---|
| k | Up one line |
| j | Down one line |
| h | Left one character |
| l | Right one character |
| w | Right one word |
| b | Left one word |
| ^ | Go to the beginning of the line |
| $ | Go to the end of the line |
| command | Explain |
|---|---|
| i | Insert at the cursor position |
| I | Insert at the beginning of the line |
| a | Append after the cursor position |
| A | Append at the end of the line |
| command | Explain |
|---|---|
| :w | Writes the file |
| :w! | Forces the file to be saved |
| :q | Quit |
| :q! | Quit without saving changes |
| :wq! | Write and quit |
| :x | Same as :wq |
| command | Explain |
|---|---|
| :n | Positions the cursor at line n |
| :$ | Positions the cursor on the last line |
| :set nu | Turn on line numbering |
| :set nonu | Turn off line numbering |
| :help | Get help |
| Mode | Key |
|---|---|
| Command | Esc |
| Insert | i I a A |
| Line | : |
| Repeating Commands | |
|---|---|
| 5k | Move up a line 5 times |
| 80i Text Esc | Insert Text 80 times |
| 80i_Esc | Insert 80 "_" characters |
| command | Explain |
|---|---|
| x | Delete a character |
| dw | Delete a word |
| dd | Delete a line |
| D | Delete from the current position |
| command | Explain |
|---|---|
| r | Replace the current character |
| cw | Change the current word |
| cc | Change the current line |
| c$ | Change the text from the current position |
| C | Same as c$ |
| ~ | Reverses the case of a character |
| command | Explain |
|---|---|
| yy | Yank(copy) the current line |
| y[position] | Yank the [position] |
| p | Paste the most recent deleted or yanked text |
| command | Explain |
|---|---|
| /[pattern] | Start a forward search |
| ?[pattern] | Start a reverse search |
| n/N move |