Daily Liunx command, VI and VIM usage

Source: Internet
Author: User

Although today is National day, but study can not stop, today is learning is liunx, more important 2 editor, VI and Vim, perhaps someone asked why to learn these 2? There is no easy-to-use Nano.

Mainly because there are some other liunx version, there is no built-in Nano, this if you suddenly touch can not start quickly, and VI is each LIUNX version is built-in, all this learning is necessary,

Some basic applications of VI, such as create a new file with VI, and open:

Vi/tmp/testing #新建一个testing文件, and open

VI is divided into three basic modes:

1. General mode (default)

2. Edit mode (accessible by pressing I,I,O,O,A,A)

3. Command-line mode (by pressing/,? ,: All can be entered)

Some function keys in normal mode (common)

Number 0: Return to the beginning of the cursor,

Symbol $: Go to the end of the line where the cursor is located,

N (plus left and RIGHT ARROW keys): N is the number, go to the left N character Place

N[enter]: Go to the N-line position below the cursor

G: Jump to the end of this file,

1g/gg: Jumps to the first line of this file,

N1,n2s/word1/word2/g: Find Word1 This string between N1 to N2 and replace it with WORD2

N1,N2S/WORD1/WORD2/GC: Find Word1 This string between N1 to N2 and replace it with WORD2, asking the user if they want to replace

1, $s/word1/word2: from the first line to the last row, find word1 and replace it with WORD2

Related to copy, delete, paste:

DD: Delete the line where the cursor is located,

NDD: Remove the n line from the bottom of the cursor,

D1G: Deletes data from the beginning of the cursor to the first row,

DG: Deletes data from the beginning of the cursor to the last row,

D0: Deletes data from the beginning of the cursor to the beginning of the line,

d$: Deletes data from the beginning of the cursor to the end of the line,

  

YY: The line in which the secondary cursor is located,

Nyy: Copy from the next n rows where the cursor is located,

Y1G: Copy the data from the beginning of the cursor to the first row of the file,

YG: Copy data from the beginning of the cursor to the last line of the file,

D0: Copy data from the beginning of the cursor to the beginning of the line,

d$: Copying data from the beginning of the cursor to the end of the line,

P: To the line where the cursor is located, paste underneath,

P: The line where you want the cursor to be pasted,

Command-line mode:
: W writes the edited text to the disk,

: w! Forced write, but still related to your permissions on the file,

: Wq writes and Exits,

: ZZ If this file is not edited and does not need to be saved leave, there is, save-"leave

Daily Liunx command, VI and VIM usage

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.