Linux text editor (mainly vi / vim)

Reference Catalog for Linux learning sequence: https: //www.cnblogs.com/lv1572407/p/11815911.html

 

There are different text editors different operating systems, such as Notepad in the Windows system.
In fact, the Linux operating system also has its own unique text editor.
Now commonly used in the Linux operating system (CentOS and RedHat), the presence of two commonly used text editor is gedit and vi (after extension changed to vim).
gedit is a text-based graphical editor; and vi / vim text-based command line is compiled into the program.
I think vi / vim more convenient to use when editing text. So then we have to explain in detail vi / vim using methods and techniques.

First, give us a brief look at a variety of modes vi editor. In the network resources, it was mentioned vi / vim there are three modes in; also suggested that there are four models; even more. In fact, this is only my personal understanding is different, there is no right or wrong.
In my opinion, we have no need to learn how many modes exist in vi / vim, we just need to do it in a variety of familiar modes can switch freely use. As the old saying puts it: sword in hand, heart, sword can be.

Of course, just in order to facilitate the entry of people, or simply to explain to you about the. Then follow three modes explain to you.

Recommendation: Do not try to use all the skills all recite. On the one hand editing skills as much as it is impossible to memorize all; two aspects can even memorized, you need to think about when re-use and more waste of time. Just frequently used to.

1. Three modes
command mode to edit text operation command
edit mode command mode by entering the Edit mode, modifying the text input through the keyboard
to find and modify text line mode via the tail end of line mode

2. Common Commands Command Mode
(1) into the edit mode
i insert mode before the cursor enters
a cursor mode is inserted after entering
I first enter insert mode cursor line
A into insert mode end of the line cursor
o inserting a blank line below cursor
O insert blank rows above the cursor
(2) text replacement
r replace one character
R continuous character Alternatively
(3) copy, cut, delete, paste
yy copy cursor line
x delete (shear) character cursor
dd delete (cut) the current cursor line
D delete (cut) the cursor position to the end of the line
d ^ deleted (shear) the cursor position to the beginning
paste p to the cursor on the line
paste P to the cursor on the next line
(4) text Action undo
u undo
ctrl + r cancel undo operation
(5) text visualization
v standard visualization
V visualization row
ctrl + V block visualized
tips1: command portion may be used in conjunction with a digital (e.g.: 3yy copy the contents of the current line to a lower three lines)
Tips2: these parameters do not need to memorize mandatory, as long as the can is often used.

3. edit mode (edit the text can be input via the keyboard into the edit mode)

4. The end of line parameter common mode
(1) keyword queries
: / keyword
: / keyword / keyword search match IG
(2) Set the text format
: set list display flag end of the line for the end of the line to see if there is extra space
: set nolist cancel the display end of line flag
: set nu set the line number
: set nonu setting cancellation line number
: set ai automatically start completion tabs
: set noai cancel the automatic completion tabs
: set ic setting slightly capitalization
: set noic capitalization sensitive promoter
: set ts = 4 set the tab width
: n cursor jumps to the n-th row
: noh cancel text highlighting
: r read the contents of another file
(3) save and exit the text
: w save the current text editing, save can not be undone
: w /tmp/1.txt currently edited text file as
: wq normal save and exit
: wq forced to save and exit!
: q quit without saving
: q without saving! Force quit

Guess you like

Origin www.cnblogs.com/lv1572407/p/11816000.html