Detailed explanation of file viewing and editing in CentOS

藏色散人
Release: 2020-11-19 15:26:27
forward
3538 people have browsed it

The following column of centos Basic Tutorial will introduce you to the file viewing and editing of CentOS. I hope you can learn more about it if you need it. Friends help!

Detailed explanation of file viewing and editing in CentOS

First of all, let’s introduce cat. The original meaning of cat command is concatenate, which is used to connect the contents of multiple files and output them to the standard output stream (the standard output stream defaults to for the screen). In actual application, we often use it to display file contents.

cat file1.php displays the contents of the file1.php file;

cat -n file2.py displays the contents of the file2.py file and displays the line number ;

cat file1.php file2.py displays the contents of file1.php and file2.py files;

vi is the abbreviation of "Visual Interface", and the vi editor is the most basic text editor on Linux and Unix. It can perform many text operations such as output, delete, find, replace, block operations, etc., and users can customize it according to their own needs, which is not available in other editing programs. vi is not a typesetting program. It cannot edit fonts, formats, paragraphs and other attributes like Word or WPS. It is just a text editing program. vi has no menus, only commands, and there are many commands. Due to space limitations, this article only introduces commonly used commands. vi has three basic working modes: command line mode, text input mode and last line mode.

To enter and exit vi, enter the file name to be edited in shell mode, such as: vim file1.php to edit the file.

When exiting vi, you need to enter the exit command "q" in the last line mode. If you are in text input mode, first press the "ESC" key to enter the command mode, and then enter ":" to enter the last line mode. In the last line mode, you can use the following exit command.

When exiting: 1. :q is to exit directly; 2. wq is to exit after saving; 3. :q! - does not save the content, force exit

In the last line mode, enter set number to display the line number

In the last line mode, you can use the following "nu" command (abbreviation for number) to display the line number of the line where the cursor is located and the content of the line.

vi provides two insert commands: i and I.

1. The i command inserts text starting from before the cursor position, and you can use the key to delete incorrect input during the insertion process. At this time, vi is in the insert state, and the word "-INSERT-" is displayed on the bottom line of the screen.

2. I command This command moves the cursor to the beginning of the current line and then inserts text before it.

#vi also provides many deletion commands. These commands x (lowercase) 0 delete the character at the cursor. X (uppercase) deletes the character before the cursor dd deletes the entire line where the cursor is. The D or d$ commands have the same function, they both delete the content from the cursor position to the end of the line. d0 deletes the content starting from the character before the cursor to the beginning of the line. dw deletes a word.

vi also has a text copy command yy to copy the entire line where the cursor is located. Once the line of text has been copied, it can be pasted anywhere by using the "p" command introduced above.

Related recommendations: "linux course"

The above is the detailed content of Detailed explanation of file viewing and editing in CentOS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!