Linux-Vim Editor Overview

Brief introduction

Description: Vim and Vi operations are the same, so do not worry about Vi's
operations Vim invalid

Vi will be set on all Linux distributions have a text editor . And also a lot of software to Vi as their default editing interface, Vim is an advanced version of Vi, Vim not only can display the contents of the text in different colors, but also for such as shell scripts, C programs and other editing functions.
Vi has three operating modes: normal mode, edit mode, command mode .

General mode

Vi with a file open directly into the normal mode , in this mode, can be used to move the cursor up and down buttons, the character delete operation may be performed, copy, paste file data.
Here's what some of the general mode of operation often used:

operating Features
h or left arrow Cursor to the left
j or down arrow The cursor moves down
or the arrow k Cursor move up
l or right arrow The cursor moves to the right
0 Move the cursor to the beginning of the line character
$ Move the cursor to the last character of the line
gg To the first line of the file
ng N-th row is moved to the file
n< space > N characters right away
x To delete a character backward
X To delete a character forward
nx N consecutive delete characters backwards
dd Delete a row character under the cursor
yy Copy the line cursor
y0 Copy the characters the cursor to the first character which trekking
and $ Copy the character under the cursor to the character at the end of which trekking
p Copy and paste the contents of the cursor on the next line
P Copy the contents of the cursor on the line paste
J The line where the cursor into one line and the next line binding
in Before a recovery operation
. Repeat the operation
[Ctrl]+r Repeat the operation

Edit mode

Edit mode is used to edit the contents of the file in edit mode, we can text editor like Windows, you can switch to the insertion point when once you have edited under Linux:

operating Features
i In the current cursor start editing
a In the current cursor character at the beginning of the next edit
O In the next line at the current cursor start editing
O On a single line at the current cursor start editing
r Replace character cursor once
[Esc] Exit edit mode to normal mode

Besides a problem in edit mode: Sometimes edit mode is automatically printed out by using the arrow keys ABCD these letters, or press Enter will show the letters, the solution is to enter the following command line:

guquan@ubuntu:~$ echo "set nocp" >> ~/.vimrc
guquan@ubuntu:~$ source ~/.vimrc

Command Mode

Command mode is generally used in the file after the completion of the editing, you can save the file, leaving the file operations such as:

operating Features
:w The editing of the data written to the file
:w! When the file is read-only attribute, the force data written to the file edit
:q Exit vi
:q! Force Quit vi, will not save the modified contents
:wq Save the modified contents, and exit vi
ZZ Exit vi, if file modified, then save the changes
:w[filename] Save As to save the edited data to another file
:r[filename] After editing the data read into the data to another file
:n1,n2 w [filename] N1 n2 lines to save the data to another file
: Not set Show Line Numbers
:set nonu Cancel Display line numbers

Three modes of conversion

For the in vi normal mode, edit mode, command mode, three modes can be mutually converted, but not edit mode and command mode for direct conversion, can only be achieved between the general mode and the edit mode, normal mode and command mode conversion.

Published 62 original articles · won praise 188 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_43743762/article/details/100804110