Linux study notes --

Source: Internet
Author: User
Vi undo redo on forward and backward press u in vi to undo an operation u undo the previous operation Ctrl & amp; 43; r indicates that the command mode is enabled by default when the previous undo operation is started: Move the cursor with h (left) j (top) k (bottom) l (right. C vi undo and redo it before and after

You can undo one operation by pressing u in vi.

U undo the previous operation
Ctrl + r restore the undo operation in the previous step

At the beginning, the command mode is entered by default:

Move the cursor with h (left) j (top) k (bottom) l (right.

Ctrl + f flip down, Ctrl + B flip up. In addition, use the upper, lower, left, and right buttons of the keyboard, as well as the pageup and pagedown keys.

Key I inserts the current cursor position, or key a inserts the cursor behind it. Enter the input mode, edit it, and press Esc to return to the command mode.

X deletes the current character, and dd deletes (cut) the current row twice.

Cw deletes the current word and enters the editing mode.

U (undo) undo.

Below is relatively uncommon:

O inserts a row behind the current row, and O inserts a row before the current row. Same as I and a, and enters the input mode at the same time.

The number key 0 jumps to the beginning of the line and $ to the end of the line.

Shift + j combines the current row and the next row into one row.

Ndd cut N rows (N is a number ).

Yy copies the current row. Nyy copies N (N is a number) rows. Press p to paste.

: N jumps to row N. Directly jump N to the nth row after the current row. N can be negative.

In command mode, enter/word (press enter) to search for the character word in the file. Press n (next) to jump to the next searched character.

Use the ": s/replaced character/g" command to search for replacement. For example, ": s/^ M/g" deletes the line ^ M at the end of the windows file. The input method of "^ M" is to press Ctrl + v, then press Ctrl and drop the v key, and then press M.

Delete all: press esc and then dG
Copy all: press esc and then ggyG
Select all highlight: press esc, and then ggvG or ggVG

What command is used to locate a line in vi? NG or: n
N is the row number.

The cat command is used to connect files or standard input and print. This command is often used to display the file content, connect several files, or read and display the content from the standard input. it is often used with the redirection symbol.

1. command format:

Cat [option] [file]...

2. command functions:

Cat has three main functions:

1. display the entire file at a time: cat filename

2. create a file from the keyboard: cat> filename can only create new files, but cannot edit existing files.

3. merge several files into one file: cat file1 file2> file

4. example:

Example 1: add the line number of the log2012.log file and enter the log2013.log file.

Command:

Cat-n log2012.log log2013.log

Output:

[root@localhost test]# cat log2012.log 2012-012012-02======[root@localhost test]# cat log2013.log 2013-012013-022013-03======[root@localhost test]# cat -n log2012.log log2013.log      1  2012-01     2  2012-02     3     4     5  ======     6  2013-01     7  2013-02     8     9    10  2013-03    11  ======[root@localhost test]#
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.