Create a text file under Linux (Vi/vim command with detailed instructions)

Source: Internet
Author: User
Tags exit in

VI test.txt

Or

Vim Test.txt

Vim is an upgraded version of VI, with more commands and stronger functionality.

The following is a collection of vim usage, when you want to implement the exit in Vim, the first thing to do is to press "ESC", and then enter ": Wq"

 One or one-like mode: Delete, copy and paste Class command x,x x for backward deletion of one character, X for previously deleted one character NX(n stands for number)Remove n characters back DD Delete current line d Delete all characters from the current line, try to be empty row ndd(n stands for number)Remove all data from the row to the first row of the cursor in the row where the cursor is located d1g Delete all the numbers of the line that the cursor is on to the last line According to YY copy cursor line y1g copy cursor row to the first row of all data YG copy cursor line to the last All data of the row Ynj(n represents a number) copy cursor line down n+1 Row Dnj(n represents a number) Delete cursor line down n+1 line P,P p Pastes the copied data on the next line of the cursor, and p pastes the copied data on the top row of the cursor J combines data from the row of the cursor with the next row of U Restore previous Action(undo) Second, edit mode command I,I I inserts the input text at the current cursor, I inserts the input text A for the first non-null character in the line where the cursor is located,A is the input text that is inserted at the next character in the current cursor, A is the input text prompt the next character in the line where the cursor is positioned o,o to begin inserting characters at the beginning of the line at the start of the row where the cursor is located , O to insert the character R at the beginning of the line that contains the cursor,R R is the character that replaces the cursor, R is the text that the cursor refers to, until exit ESC exits, return to normal mode three, command mode h                            Move Cursor left one character J cursor down one character K cursor up one character l Move the cursor one character to the right ctrl+f screen down one page Ctrl+b screen up one page Ctrl+D screen upside down half page Ctrl+u screen up half page+The cursor moves to the first non-null character of the next line-the cursor moves to the first non-empty character n space of the current line(n stands for number)the cursor moves n characters to the right of the current line0 (number 0) the cursor moves to the first character of the current line (can be a null character,attention and-distinction)The $ cursor moves to the last character of the current line (can be a null character,note with-differentiate) H the first non-null character of the line that the cursor moves to the top of the current screen m cursor moves to the first non-empty character of the line in the middle of the current screen The first non-null character of the line that the cursor moves to the bottom of the current screen the G cursor moves to the first non-empty character of the last line of the article Ng(n stands for number)The cursor moves to the first non-null character of the nth row of the article n the first non-empty character of the N-line that the cursor moves down from the current line/word looks for word strings after the cursor? Word finds word strings before the cursor: S/word1/word2/G Find word1 on the current line of the cursor and replace it with Word2: N1, n2s/word1/word2/G find word1 between line N1 and line N2 and replace it with word2:%s/word1/word2/g The entire article find word1 and replace it with Word2: wSave the edited data to a hard disk file: w[filename] Saves the edited data to another file on the hard disk: R[filename] reads data from another file while editing the data, adding the contents of the filename file to the row below the cursor line: Wq or: xSave and exit: Qexit, apply to unmodified files: Q! Force quit, apply to modify file after not save exit: Setnu Display line number: SetNonu Cancel line number: N1, n2 w [filename] Saves the contents of the N1 to N2 row into a file named filename

Reference:

Http://www.jb51.net/LINUXjishu/143474.html

Create a text file under Linux (Vi/vim command with detailed instructions)

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.