command lab
  • TOP
  • BLOG
  • vim

  • [Practice of vim] Basic mobile commands you should learn first

[Practice of vim] Basic mobile commands you should learn first

For those who are going to learn vim, I will introduce and explain the basic commands of the mobile system that should be remembered first. This site is for learning shortcuts and commands efficiently and intuitively. We also have a function to practice vim commands intuitively. Please use it by all means.

Click here for vim command practice

Press the START button below to enter practice mode.
* Input mode switching ctrl + shift + alt + space
Guide mode
Repeat mode

Cursor movement

It is a unique cursor movement command that should be called a symbol of vim. It can be said that this is the first wall to hit when learning the operation of vim. You may think that most people have to move with k or j without using arrow keys (→, etc.), but the biggest advantage of this operation method is that the cursor does not move away from the home position. It means that you can move. It is also a big advantage of vim that most operations can be performed without leaving the home position.

Move to ↑k
Move to ↓j
Move to →l
Move to ←h

Move cursor on display

Many people may find it difficult to hear the movement of the cursor on the display, but this is a command that is required when automatic line breaks are turned on. In the above k and j commands, automatic line breaks are ignored when the number of characters in a line is large, so the following command is required to move the automatic line breaks up and down.

Move to ↑ on the displaygk
Move to ↓ on the displaygj

Jump to the beginning/end of the line

This command moves to the beginning/end of a line. It is a command that should be remembered as a mast when using vim because it is a command that is often used unexpectedly. The difference between ^ and 0 is that ^ is a command to move to the first character that ignores the indent, and 0 is a command to move to the 0th character including the indent, that is, the first column.

To the beginning of the line (first character)^
To the beginning of the line (first column)0
To end of line$

Move word by word

This is a move command in word units. If you can input this command intuitively, it is a wonderful vimmer. Although it may not be possible to move as you would expect in Japanese, it is a very cooperative command when moving between code such as javascript.

Go to beginning of wordw
Return to beginning of wordb
Go to end of worde
Return to end of wordge

Move to beginning/end of file

Command to move to the first and last line in the file. This is also a scene to use unexpectedly, and it is very convenient to remember.

To the top of the filegg
To the end of the fileG

Move to specified line

This command allows you to jump to the specified line. There are two ways, one is to enter :: to jump from the command mode, and the other is to jump without entering the command mode. Personally, I prefer commands that start with:. Is it enough to remember who you like?

Move to line XX:〇〇 Enter
Move to line XX〇〇G

The cursor is currently in the center of the screen

This command is a little different from moving and scrolling, and it brings the cursor position to the center of the screen. It is used when you want to see the upper and lower codes. It is a command that is convenient for you to know.

The cursor is currently in the center of the screenzz

Move to a specific character in a line

A command to move to a specific character in a line. When you can type this command freely, the mouse turns out. It can be said that this is a command that cannot be avoided in order to master vim.

Search one character of 〇 in the forward direction of the linef〇
Repeat one character search in the forward direction;
Repeat one character search in the opposite direction,
Search for 1 character in the reverse direction of the lineF〇

Search string in file

This command works in the same way as the search of ctrl+f usually called in the editor. Since there are commands for forward and backward respectively, it can be said that you are an advanced person of vim if you use them properly depending on the situation.

Search string in forward direction/〇〇 enter
Search string in reverse direction?〇〇 enter
Repeat string search forwardn
Repeat string search in reverse directionN

Move to the place where you jumped

This command can be used when you want to go back to where you were just before, when you are jumping for searching or moving lines. The reason why vim is loved is that these commands are provided.

Return to where you jumpedctrl + o
Go to the place where you jumpedctrl + i

Scroll commands

Since vim is basically created on the assumption that the mouse is not used, naturally scrolling will also be done with commands. Actually, you can also scroll with the scroll wheel of the mouse, but since it is far from the home position, it is annoying. If you also master scroll commands, you will be able to code at explosive speed without leaving your home position.

Move up half screen ctrl + u
Move down half screenctrl + d
Move up one screenctrl + b
Move down one screenctrl + f

Move changed part

This command returns you to the changed part. vim saves the history of changes, so you can move along the history of changes, which is a very convenient command.

Go back one place changedg;
Proceed the changed part g,