vim is one of the text editors. Unlike a general text editor, Vim was supposed to be operated only with CUI and keyboard, so all operations are possible with only the keyboard. The basic operation method is the same as vi, you can edit the text by using different modes according to the situation, and you can realize a wide variety of functions by creating a combination of small commands on the spot.
Since vim is a text editor derived from vi, it mainly uses Linux commands.
** Basic commands ** The activated state is normal mode, and if you enter "i" </ font> from that state, it will switch to input mode. Enter "esc" </ font> from the input mode to return to normal mode.
To quit Vim, type ":" </ font> to switch to command line mode and then "q" </ font> Enter and enter. You can now finish.
If you want to ignore the changes and exit, enter ": q!" </ Font>. If you add!, You can ignore the change and exit. If you use Vim to rewrite and save the file, you can save and exit by pressing "wq" </ font> after:. Note that: w saves and Vim doesn't quit. If you want to change the file name and save it by overwriting, you can change and save it by following: w with the file name you want to change.
** Mobile commands ** In normal mode, enter "gg" </ font> to move to the top. On the contrary, if you want to move to the bottom, you can move it immediately by entering "G" </ font>.
You can move to the beginning of the line by entering "^" </ font>. Conversely, you can move to the end of the line by entering "$" </ font>.
** Find / replace command ** After entering "/" </ font> in normal mode, enter the word you want to search for and press enter to move to that word's position.
Switch to command mode with:. "s" </ font> followed by "/" </ font> and the word or character you want to replace in the line. After that, enter / and the changed character or word. In this case, only the first matching character will be replaced. If you want to replace the first and subsequent matching characters in the line at once, enter / and "g" </ font> afterwards. Example): s / a / A / g Replace all "a" with "A"
** Cancel command ** Enter "u" </ font> to restore. If you want to change the state after processing before pressing u, you can change the state with control + r.
Since vim is an editor that handles command operations, at first I thought it was difficult to get to and the threshold was high. I got the impression that it is more convenient to use it than I expected to hear the explanation. Also, since I can use vi at work, I was able to learn various commands that lead to it.
Despite being a standard editor, it has high performance and light behavior, and it can be used in any environment, so I heard that once you get used to it, you will not be able to return to other editors, so I definitely want to be able to use it.
Recommended Posts