[Study Notes] basic Linux operations (6) --- Vi Text Editor

Source: Internet
Author: User

Course connection: Vi Text Editor


Vi and vim

Vi is a text editing tool on the command line interface. It provides text editing, text processing, code development, and other functions.

Vim is the strong version of vi (Code highlighting)


Run vim to start the vim editor.

Vim + target path

  • Open the file if the file exists.
  • Create a file if the file does not exist.


Vim three modes-command mode

  • After vim is started, it enters the command mode by default. In any mode, the command mode can be returned through the esc key.
  • In command mode, you can copy, paste, select, and revoke commands.

-In the insert mode, press 'I in the command mode to enter the insert mode. In the insert mode, you can enter the edit content and Press esc to return to the command mode.
-In the command mode, press the ':' key in the quiet mode. The cursor moves to the bottom. You can save or exit vim here.

Command mode
  • I insert before the cursor
  • O insert in the next row of the current row
  • Dd deletes the current row
  • Yy put the current row into the buffer (copy the current row)
  • N + yy put n rows of content into the buffer (copy the current n rows)
  • P paste the content in the buffer after the cursor
  • U undo
  • R replaces the current character
  • /Search for keywords (n-key switch)


EX Mode
  • : W save
  • : Q exit
  • : Q! Force exit without saving changes
  • : X save and exit, equivalent to: wq
  • : Set number: displays the row number.
  • :! The system command executes a system command and displays the result.
  • : Sh switch to the command line, Ctrl + d returns vim


Insert mode

After pressing 'I', you can enter any text, and esc will exit the return command mode.


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.