Detailed command three operating modes Linux Chinese editor three operating mode switch and the vi editor

The role of the text editor

Create or modify text files
maintain Linux systems in a variety of configuration files
Linux is the most commonly used text editor,
Linux is the most commonly used text editor
vi: UNIX-like operating system's default text editor
vim: when vim vi text editor ( generally referred to as the vi editor) enhanced version

Operating modes vi editor

Three operating modes
command mode, input mode, last line mode
switching between different modes
Detailed command three operating modes Linux Chinese editor three operating mode switch and the vi editor

3-1 Basic Operation command mode

Cursor movement
arrow keys to move (↑, ↓, ←, → ) Function: to move around
Page Down function or Ctrl + F: flipping down the contents of an entire page
Page Up or Ctrl + B Function: flipping up overnight content
Home key or "^", ten-key "0" feature: jump to the first line of
the End key or "$" key functions: jump to end of line
1G or function gg: Jump to the first line of the file
G function: Go to file end of the line
#G functionality: Jump file on # line to
: set nu function: display the line number and then editor
: set nonu: to deactivate the line numbers in the editor display

3-2 Basic Operation command mode

Copy, paste, delete,
x or Del to delete a single character at the cursor
dd delete the current cursor line
#dd delete # command line starting from the cursor line
d ^ deleted before the current cursor to the beginning of all the characters
d $ delete the current cursor position All the end of the line
yy copy the current row of the entire line to the clipboard
#yy copy # lines starting from the contents of the cursor line
P after the contents of the buffer is pasted to the cursor position
before pasting the cursor position p

3-3 Basic Operation command mode

Find the file content
/ word search string from top to bottom "word" in the document
? bottom-word search string in a file "word"
at a n-th location of the search string to match
the positioning of a N matching search string
withdrawn edit, and save and exit
u last time the cancel operation; repeating u key multi-step recovery operation
changes to the current row of U to cancel.
ZZ save the current file and exit the vi editor

2-1 Basic Operation of line mode

Save the file and exit the vi editor
: w save the change
: w / root / newfile save as another file
: q unmodified quit
: q! Abandon contents of the file and exit vi
: WQ save changes and exit
open a new file or read other file content
: e ~ / install.log open a new file for editing
: / etc / filesystems read in the current file other file content

2-2 Basic Operation of line mode

: S / old / new first character in the current row looking "old" string is replaced with "new"
: s / old / new / G in the current line to find all the strings "old" is replaced with "new " :
#, # S / Old / new new / G row number" "replace all the strings in the range of" old #, # "is the" new new "
:% S / Old / new new / G replacement in all the entire file string "old" to "new new"
: S / Old / new new / c c in the alternative command added to the end of the command, each replacement operation will prompt the user for confirmation

Guess you like

Origin blog.51cto.com/14449798/2429281
Recommended