This is the 29th day of my participation in the August Wenwen Challenge.More challenges in August
The words written in the front
As a front-end engineer, THE ViM editor is not a necessary skill. I first learned it because I need to help students modify some project configurations, so I can only use it briefly.
Last month on site for some reason to go to other company, and I match is a very powerful Java small sister, skilled in vim coding, his skin fair-skinneds in vain, long fingers and hands on the keyboard as elves dance scene, I deeply in the powerful and charm of vim, therefore decided to learn it in the system, in this to make a record, Looking forward to mutual encouragement.
Of course, learning VIM requires perseverance, a lot of practice and patience to overcome the steep learning curve, so be prepared, set flags and make plans first.
Ok, for the blog, I plan to update it in stages. Every time I learn it to a certain extent, I will summarize it. My plan is to complete the relevant blog within one month, that is, to complete the study of VIM in one month, and then carry out practical exercises later.
This section focuses on basic VIM operations
Install vim
Vim is an editor and is usually used for terminals
-
Linux, MAC and other systems have viM. You can enter VIM on the terminal to access VIM.
-
Windows users can install Gvim to try it out, or try to install a virtual machine to work with Linux.
I met vim
Enter vim a.txt at the terminal to access the a.txt file contents.
Vim has four modes for users to perform different operations.
- The default mode
- Insert mode
- Command line mode
- Visual mode
By opening A.txt, we enter vim’s default mode, also known as normal mode
Normal mode: the default mode of VIm, which can be used to browse files quickly. In this mode, the letters 'I', 'A', 'O', 'S', 'I', 'a', 'O', 'S' can be used to enter insert mode, or ':' can be used to enter command mode, or 'v' can be used to enter visualization mode, and 'v' can be used to enter row visualization modeCopy the code
If we want to edit the contents of the file, we go into edit mode, also known as INSERT mode
Insert mode: Vim's insert mode, which is equivalent to other editors, allows you to type anything on the keyboard and use the Esc key to return to normal modeCopy the code
When we use VIm to edit the file, we need to store it, this time we need to use the command line mode, also known as the Command mode
Command mode: Vim command mode, which allows you to perform some command operations (press Enter after entering a command), such as :w to save the current file, q to exit vim when you have not performed any operation on the current file, and exit Vim when you want to exit! Q means to discard the current changes and exit. When you modify the current file but do not want to save it and exit, use :wq to save the changes and exit. Set nu means to set the line number of the current file and display the current line number before each line, just like in Excel. Vs is for left and right split screen operation. Sp is for up and down split screen operation. There are many commands, which will be covered laterCopy the code
If you need batch operations, such as selecting the same text in multiple places, use visual mode, also known as ** Visual mode **
Visual mode: ViM visual mode, this mode can be batch selection and operation, such as CTRL + V: start select block text V: start select line textCopy the code
A simple memory
Since Vim is purely keyboard manipulation, there is a lot to remember. Here are some common methods.
I => insert: the cursor enters the insert mode at the current position. A => AppEnd: the cursor enters the insert mode after the current character. O => Open a line below: the cursor creates a new line below the current line to enter the insert mode. Delete the current character and enter insert mode I => INSERT before line: cursor enters insert mode at the beginning of the current line A => append after line: cursor enters insert mode at the end of the current line O => open A line above: S => Slice a line: Deletes the current line and enters the insertion mode. W => write: saves the written content. Q => quit: stops. Set nu => set number of lines sp => split: split vs => vertical split: vertical split (left and right)Copy the code
This is novice for VIm more commonly used content, complete memory is not difficult, but want to achieve complete mastery, also need to form muscle memory, to achieve the degree of blind playing good, ha ha ha, share!