20
头图

Vim

Vim is a very good editor, an ancient artifact. When you are familiar with this editor, will your competiveness be much higher in an instant?
First install vim
Of course, learning an editor is to facilitate yourself and improve efficiency, but the learning curve of vim, a text editor, is steep
But hard training will bring you efficiency
And when I use the git command, it is indeed a very powerful development combination to cooperate with vim. Although vim has no code hints, it actually has a lot of plug-ins for use. When we submit the code with git, we use vim to do it. It is very convenient to resolve conflicts and edit the code
VIM download
vim
Start vim

image

i
Insert mode, press ESC to return to Normal mode
Anyway, if you don’t know what mode you are in, just keep pressing ESC to return to Normal mode. The following function keys are all triggered in Normal mode.

image

At this time, the Insert mode is the same as the Notepad

image

Operating vim will often switch between these two modes, just like you switch between tabs and edit content window in Notepad

image
image

It’s just that most of it has become a keyboard operation
So in Normal mode, all the keys on the keyboard become the corresponding function keys, just like when we press c and ctrl+c, c becomes the corresponding function key in the back

x
In Normal mode, press x to delete a character under the current cursor

image

In fact, this is equivalent to the backspace key in Insert mode

:wq
Save+exit vim(:w save:q exit) followed by the file name

image

This is equivalent to the file in Notepad -> (Save) Save As

dd
Delete the current line and save the deleted line to the clipboard, which is also commonly used in IDEs. Quickly delete a line of code without long pressing backspace.

p
Paste the clipboard, this function is quite common, if you copy something outside, you can paste it directly by pressing p on the vim interface

yy
Copy the current line to the clipboard

da811428-28e3-11e6-92a6-cf371a09e4e9

help
Display help for related commands

image

:q
quit
:q!
Exit without saving

image

a
Insert after the cursor, if the cursor is not at the end, it will automatically freeze the frame for you to enter the end

image

o
Insert a new line after the current line, which is equivalent to hitting the Enter key at the end of a line in Notepad

image

0
Press the number 0 to go to the beginning of the line, which is the opposite of a

image

^
This is to combine shift+6 to the position of the first non-blank character in the line (the so-called blank character is a space, tab, line feed, carriage return, etc.)

$
The cursor switches to the end of the line

/pattern
Search string for pattern

If multiple matches are found, press n to locate the next one

u
Undo is Undo
Basic IDEs with this function are available, quite commonly used, as convenient as ctrl+z when I use PS

ctrl+r\
Redo is Redo

:e <file path/file name>
Open a file. In cmd, I often cd to the specified directory, and then dir displays and then uses vim to open the corresponding file for editing

image

:w
save

image

A written prompt will appear after saving

image

: saveas <file path/file name>
Save as

image

After the save is successful, the written prompt will also appear

image

One thing to note is that if you just save or save as but never exit vim editing, the file will always be in the folder with the following suffix

image

But if you save and exit, it will become the file name and suffix defined when saving

image

:x
ZZshift+z
:wq
The above three are all to save and exit. Note that ZZ does not need to enter a colon and enter
image

:q!
Exit without saving
:qa
Forcibly exit all files being edited, even if other files have changed

:bn
:bq
Sometimes we need to open multiple files, that is, when one file is already open, we can continue to use :e to open other files. When opening multiple files, we can use the above two commands to switch to the next or previous document

image

.
This command can repeat the last command you ran

N<command>
It’s invisible when you hit this, which means blind hitting.
N is to enter a number. For example, if I enter 9p, the following picture will appear

image

G
Position the cursor at the head of the last line

image

w
Go to the beginning of the next word.
e
To the end of the next word.

  • If you think the word is by default, then use lowercase e and w. By default, a word consists of letters, numbers and underscores
  • If you think that words are separated by blank characters, then you need to use uppercase E and W.

*and#
When you put the cursor on catwsscat and press * or #, it will move to the previous or next match of the word

  • *On the left side of the keyboard is to match the previous word
  • On the right side of the keyboard is to match the next word

image

%
Match bracket movement, support (, {, [, you need to move the cursor to the bracket first

image

v
After entering the visual selection, press the up, down, left, and right arrow keys on the keyboard to automatically select for you

qq 20160603100040

Visual selection
J → connects all the rows (turns into one row)
<or> → indent left and right
= → automatically indent (this is really convenient)

finally

I have been busy recently. I have time to continue to organize later. Thank you for taking the time to read. I look forward to finding a good front-end job. Come on! thanks. If this article can bring you a hint of help or inspiration, please don't be stingy with your praise and Star, yours is definitely my biggest motivation to move forward 💞 attach a link to the notes, read more high-quality articles in the past, you can check it out, and if you like, you can give I like to encourage it: https://github.com/Wscats/articles/issues/27


wscats
7.1k 声望13k 粉丝

分享和总结不易,求关注一下⭐️