Common Vim/Vi operations (version 2) and vimvi Version 2
Colleagues around you are either using vim or Emacs. If you use ultraedit, you are embarrassed to say hello to others. What plug-ins are there? syntax highlighting and spelling check, everything that can be opened to it is a word: Cool.
If you say so, you have to learn how to do it for half a year. Half a year! It's far from getting started. It's good to learn to move the cursor. You don't have to worry about it, it's just moving around !!!
Vim/Vi Introduction
Vi is installed by default for all Linux/UNIX systems, and vim is installed by default for mainstream Linux systems.
Vim/Vi is a powerful full-screen text editor, the most common text editor on Linux/UNIX. It is used to create, edit, and display text files; vi supports almost all languages.
Vim/Vi has no menu and only commands.
Official Website: www.vim.org
Vim/Vi Working Mode
INSERT command
Command function
A attaches text behind the cursor
A adds text at the end of the line
I insert before the cursor
I insert text at the beginning of the line
O Insert a new row under the cursor
O Insert a new line to the cursor
Locating command
Command function
H shifts one character to the left
J. Move one row down
K move one row up
L move one character to the right
$ Move to the end of a row
0 move to the beginning of the row
H move to the top of the screen
M moves to the center of the screen
L move to the bottom of the screen
Quick Positioning
Command function
: Set nu display row number
: Set nonu cancel row number
Move gg to the first line
Move G to the last row
NG to n
: N to row n
DELETE command
X: Delete the cursor character
Nx Delete n characters
Dd deletes the row where the cursor is located, and ndd deletes n rows.
DG deletes all rows from the current row to the end of the file, including the current row
D. Delete the content from the cursor position to the end of the line.
: N1, n2d Delete n1 ~ N2 row
Copy command
Yy and Y copy the current row
Nyy, nY copy n rows
Dd: Cut the current row. ndd: Cut the current row and the next n rows.
P paste under the current row
P [uppercase] pasted on the current row
Replace or cancel command
R replaces the character at the cursor
R replaces the character from where the cursor is located until Esc ends.
U cancel the previous operation. First, you have not saved the file. The file is still in memory and has not been synchronized to the hard disk.
Replace or SEARCH Command
/String: searches for the specified string backward. case-insensitive: set ic is ignored during search. Cancel: set noic
N turning back
N forward from the back
: % S/old/new/g Replace the specified string in full text, and old is the keyword to be replaced.
: N1, n2s/old/new/g Replace the specified string within a certain range
: % S/old/new/c Replace the specified string in full text, but will ask
Save and exit
ZZ: wq shortcut
: W new_filename save as the specified file
: Wq! Forcibly Save the modification and exit [root/file owner]
: Q! Do not save and exit
Is vim used in linux the same as vi?
Vim is vi improved
Strictly speaking, they are quite different. However, only vim is installed on linux, so you do not need to go into details. After vim is installed, a connection named vi is usually created.
For linux beginners, vim is not very easy to use. You can give some common operation methods to introduce the advantages of vim, or recommend other useful editors.
Vim is extended from vi. It includes all vi usage and adds many new usages. For example, it displays different colors for comments and parameters, and can also be used in other cases. there are a lot of sp or block selection, etc, I suggest you learn vi first. The reason is simple. vi is supported in all nuix and linux versions without installation.
In addition to vi and vim, there are also Emacs, KVIM, Arachnophilia, Bluefish, Komodo Edit, NEdit, Gedit, Kate, and Quanta Plus editors, which can be selected based on your preferences.