Essential for beginners of CentOS: Linuxvi command

Source: Internet
Author: User
In the current text editor era, the default Linux editor is still vi or vim. The Linuxvi command discussed in this article will help novice administrators better use vi. This cannot be separated from Linuxvi or its updated version vim. Why? Because vi is usually available regardless of the Linux server status. If the server encounters a problem and stops working, vi can fix it. Some commands are based on vi and use vi as the default editor. The crontab command is used to schedule work. mongodo grants administrator privileges,

In the current text editor era, the default Linux editor is still vi or vim. The Linux vi commands discussed in this article will help novice administrators better use vi.

This is inseparable from Linux vi or its latest version of vim. Why? Because vi is usually available regardless of the Linux server status. If the server encounters a problem and stops working, vi can fix it.

Some commands are based on vi and use vi as the default editor.CrontabCommand is used to schedule work,MongodoGrant Administrator privileges andEdquotaEditing a file system quota is a key part of vi. The vi editor function promotes script writing, so the new Linux administrator thinks vi is very useful.

If possible, select Linux vim. The new version of the text editor uses the availability function, such as statement highlighting. In some Linux versions, vim is enabled more automatically than vi. in other versions, the administrator must specify vi or vim.

The vi commands discussed in this article apply to the Linux vi and vim Editors.

Two Linux vi modes

Linux vi has two modes, so it is a little difficult for new users. When you start vi to edit the document for the first time, you will enter the command mode vi ~ /Mydocument. However, before entering the command, you may want to enter some text. in this case, you need to enter the input mode.

The following command helps the administrator switch between the vi and vim commands and the input mode:

UseAEnter input mode

Used at the current position of the cursorIEnter input mode

UseOOpen a new row

After entering text in input mode, use: Wq!Write the changes to the disk and exit. Do not forget the commands starting with a colon. make sure that letters are entered in the correct order and you cannot exit and then write them to the disk. Or use an alternative command: ZZ.

Sometimes the session in this article is not smooth. In that case, refer to the following practices:

UseUUndo the last modification (you can use it multiple times)

UseCtrl-RRedo the undo behavior

Use: Q!As an emergency exit. It allows you to quickly exit from existing documents.

The Linux text file to be edited may become larger and larger. To place the cursor in the correct position, use:

GgBack to the first line of the document

: NumberLocate a specific number

/TextGo to the place where "text" appears for the first time

GGo to the end of the existing document

Some editing commands can also be used in vi command mode:

VEnter the visualization mode. In visual mode, you can move the arrow key to select text.

DDelete existing selections

YCopy existing options

PPaste existing selections

DdDelete a row. Linux text editing usually needs to remove the entire line.

To search for and replace the given text, use: % S/oldtext/newtext/g

The "oldtext" section of the vi command should be the text you are looking. "Newtext" is the part you want to replace. This is a simple method for large-scale replacement in the document.

You can find many other available commands, but as a beginner in vi, it is a good idea to pay attention to the absolute minimum value. Using each Linux vi command to edit a text increases the risk of getting lost, so that you cannot find a suitable solution.


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.