If you know the contents of this article, you will be able to ** basic operations and Vim-like things **.
For example ... Fast cursor movement, Intuitive deletion of the range you want to delete, etc.
What I learned in Udemy's Vim Master class.
** I think it is suitable for those who "know how to switch between command mode and insert mode, but don't know anything else" **.
For those who say "What's that?", Please see the above Vim Master class and Video around here. VimMaster class is highly recommended.
1. Move cursor (command mode) 2. Delete / Overwrite 3. Display adjustment 4. Edit (Command Mode / Insert Mode / Macro) 5. Replace / Search 6. Save / Exit 7. Specify range 8. VISUAL mode
--Move the cursor in command mode.
Key | What you want to do |
---|---|
j | To the bottom line |
2j moves down 2 lines(Same for khl) | |
k | To the top line |
h | To the left |
l | To the right |
Key | What you want to do |
---|---|
w | To the next word |
b | To the previous word |
$ | To the end of the line |
0 | To the beginning of the line |
G, :$<enter> | Move to the end of the sentence |
gg, :1<enter> | Move to the beginning of the sentence |
50G, 50gg, :50<enter> | Move to line 50 |
ctrl + f | to the next page(forward) |
ctrl + b | To the previous page(back) |
Key | What you want to do |
---|---|
x | Delete the character on the cursor |
X (shift + x) | Delete to the left of the cursor |
You can replace the current cursor position with the character to the right with xp(p is paste) | |
r "c" | The character of the current cursor"c" (Any single letter)Replace with |
ex) make->For modification to take, move the cursor to m and rt |
Key | What you want to do |
---|---|
dw | Delete one word |
3dw | Delete 3 words |
D (shift + d) | Delete from the current position to the end of the line |
d$Same meaning as | |
d0 | Delete from the current position to the beginning of the line |
dj | Delete current line and lines below it |
dk | Delete current line and lines above it |
j,k isMove cursorSame meaning as the item of | |
dd | Delete current line(Including line breaks) |
10dd | Delete 10 lines from the current line |
:10,20d<enter> | Deleted lines 10 to 20 |
d/"hoge" | From the current cursor"hoge"Delete up to the front of |
"/"Means search.hogeIs | |
dt. | Next from the current cursor position.Delete up to (.Is OK with your favorite character) |
t is next to the current line"."Point to the cursor position immediately before | |
das | Delete the sentence where the cursor is currently placed |
s represents sentense It means that a is like all. That is, delete all sentence->Delete one sentence |
|
dap | Delete paragraph 1 |
p represents paragraph | |
di](or[) | [...]Delete inside(Place the cursor in parentheses) |
ci](or[) | [...]After deleting the inside, go to insert mode |
Key | What you want to do |
---|---|
c | Enter insert mode after deletion. You can use the command in the same way as d |
For example ci[Then[]Delete the characters in and then enter insert mode | |
C | Insert mode by deleting from the current position to the end of the line (Corresponds to D deleting from the current position to the end of the line) |
cc | Delete the current line and go to Insert mode (Corresponds to dd deleting the current line) |
cw | Delete the word on the current cursor and go to Insert mode |
cD, c$ | Insert mode by deleting the characters after the current cursor |
Key | What you want to do |
---|---|
R(shift + r) | When you type a character, the character at the current cursor position is replaced with the character you typed. |
<esc>Return to command mode with |
Key | What you want to do |
---|---|
z<enter> | Move the cursor to the top of the screen |
zz | Move the cursor to the center of the screen |
Key | What you want to do |
---|---|
. | Repeat the last edit |
u | Undo last edit(Windows Ctrl+z) |
Ctrl + r | ReDo (Windows Ctrl+y) |
p | From the current cursorRight sidePaste to |
P (shift + p) | From the current cursorleftPaste to |
Key | What you want to do |
---|---|
i | Go to Insert mode at the current character position |
I | Move to the beginning of the current line and go to Insert mode |
a | Go one character forward to Insert mode |
ex) $Use this when you want to insert at the end of a sentence after moving with | |
A | Move to the end of the current line and go to Insert mode |
o | Change to Insert mode with a line break below the current line |
5o "hoge" <esc> | From the current line down"hoge"5 lines added |
O (shift + o) | Insert mode with a line break on one line |
J (shift + j) | Remove the line break at the end of the current line and insert one space. |
In other words, add one space between the current line and the next line and combine them. | |
gJ | Remove line breaks without inserting space |
Key | What you want to do |
---|---|
qa | Start recording macro in a register (part a is b,c,d,...And any register name is OK) |
q | Stop recording macros |
@a | Play a register macro |
:10,30 normal @a <enter> | a macro for register 10-Applies to line 30 |
":10,30"Is 10-Means line 30 |
Key | What you want to do |
---|---|
f + c (One character) | Next to the current linecMove to |
;The next character in the line, ","To the previous character | |
t + c (One character) | Next to the current linecofTo the frontMove |
* | Move to the position where the word on the current cursor appears next(Search by exact word match) |
Key | What you want to do |
---|---|
:%s/hoge/fuga/g | The whole sentencehogeTofugaConversion to. Multiple times in one linehogeReplace even if (/First in line without ghogeOnly replace) |
:1,5s/hoge/fuga/ | 1-Up to the 5th linehogeBy replacing. In addition, it should be noted%Is 1,$Represents |
:/cat/,/dog/s/hoge/fuga/g | catWhendogOf the line betweenhogeTofugaReplace with |
:/cat/,$s/hoge/fuga/g | catAfter thathogeTofugaReplace with |
--Use backslashes (\) to escape special characters (/ &!. ^ * $ ?).
--For example, if you want to replace "INCL \ hoge.txt" with fuga.md, enter:% s/INCL \\ hoge/fuga \ .md/g and enter
-[Supplement] \ is the same as
--For the selection range, refer to Specify Range (@Link in Page).
Key | What you want to do |
---|---|
:wq | Save and exit vim |
:q! | Exit without saving. Ignore changes. |
:w | Save(vim does not quit) |
-Used in combination with another command such as:% s
Key | What you want to do |
---|---|
:10,20 | 10-Up to line 20 |
:% | Whole sentence |
:.,$ | From the current position to the end of the sentence |
.Is the line at the current cursor position,$Means the end of the sentence |
Key | What you want to do |
---|---|
v | Visual mode(Select by character) |
Shift + v | Visual Line mode(Select by line) |
ctrl + v | Visual Block mode(Select with rectangle) |
gv | Reproduce the previous selection |
Recommended Posts