Introduction to Vim

Source: Internet
Author: User

Introduction to Vim
    • To install the Vim method:
    1. yum install -y vim-enhanced
    2. yum install -y vim*
    3. yum install -y vim"Vim-related packages will be installed, including vim-enhanced"
      Vim +n "n refers to the number of rows in the cursor"
      Command mode: Set NU Displays the number of rows of the edited content
    • Vim three modes (general mode, command mode, edit mode)
  1. General mode:
    • Cursor Movement:
      kjMove Up h l 10k 10 rows up, down, left, and right
      ctrl+fPage Down
      ctrl+bPage UP
      ggMove to First line
      GMove to the last line " 45G move to Line 45th"
      $Move to end of line
      0Move to the beginning of the line "move to the ^ 0 beginning of the line ^ to a non-whitespace first character"

    • Copy Cut paste
      xRemove backward
      XDelete " 4x Delete 4 characters backwards, can I x paste?" 】
      Dis to delete rows
      ddDelete the specified line " 3d Delete 3 lines Here Delete, actually is cut"
      pPaste in the following line
      PPaste in line above
      uUndo Restore, ctrl+r revert undo "u can restore up to 50 times"
      yyCopy entire line "3yy copied 3 Rows"
      vVisual mode, then use K J H l to select the characters you want to manipulate
  2. Edit mode
    Enter edit mode:
    iBefore entering the cursor
    IEnter the beginning
    aAfter entering the cursor
    AEnter End of line
    oAnother line under the cursor
    OAnother line on the cursor
    ESC exits edit mode

  3. VIM command line mode
    • Related commands
      wSave
      qExit
      !Mandatory execution
      set nuShow line Numbers
      set nonuClose line number
      nohlCancel highlighting
    • Find
      /Find what "look n N up"
      Find what "n look up, n look down"
    • Replace
      Format: 1,20s/ip/ip/g
      1,201 to 20 rows ( 1,$ entire document for all lines % )
      IPTo be replaced.
      ipSubstituted characters
      gThe global has no g more than one substituted character in a row, replacing only one
    • Special mode substitution:
      Replacing a directory with an /IP/123/ IP
      1,20s/\/IP\/123\//ip/g
      1,20s#/IP/123/#ip#g

Introduction to Vim

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.