Linux Basics (iv): text editor vim

Source: Internet
Author: User

first, the common operation(i) Vim mode of operation


1.VIFile: Enter Command mode 2,Iao: Enter insert mode
    • ESC: Exit Insert, enter command mode
3, ":": Enter edit mode
    • Enter: End run, enter command mode
5.Wq: Exit

(ii) command 1, insert command:AIO
    • A: Insert the word specifier the cursor
    • A: Insert at the end of the line where the cursor is located
    • I: Insert the word match either in the cursor position
    • I: Insert at the beginning of the cursor
    • o: Insert a new line under the cursor
    • O: Insert a new line on the cursor
2. Positioning command:
    • : Set Nu: Sets line number
    • : Set Nonu: Cancel line number
    • GG: to the first line
    • G: to the last line
    • NG: to Nth row
    • : N: to Nth row
    • $: Move to end of line
    • 0: Move to the beginning of the line
3. Delete command
    • X: Delete the character at cursor location
    • NX: Delete the n characters after the cursor is located
    • DD: Delete Row of cursor, NDD delete n rows
    • DG: Delete the line from the cursor to the end of the file
    • D: Delete the cursor at the end of the line
    • : n1,n2d: Delete the specified range of rows


4. Copy and Cut commands
    • YY: Copy when moving forward
    • Nyy: Copy the current row following n rows
    • DD: cut when moving forward
    • NDD: Cuts the current row following n rows
    • P, p: Paste



5. Replace and Cancel commands




6. Search and Replace commands
    • Set IC and set Noic
    • %s: full-text replacement
      • %s/dd/sam/g
    • Start line, terminating line substitution
      • 5,6s/sam/rabbby/c
    • g do not inquire; C-Inquiry




7. Save and exit
    • ZZ: Save changes and exit




second, the use of skills1. Import command Execution results
    • : r "file name"
      • : R file2
    • :! LS: Execute the LS command without exiting the edit
    • : R! Date: The result of date execution can be imported into the currently edited text
2. Define shortcut keys
    • map"shortcut key" "Trigger command"
      • Map ^p i#<esc>: Add comments
      • Map ^b 0x: Delete comments
      • Map: ^h [email protected]<esc>: Insert email address
    • ^:ctrl V
3, Continuous line comment
    • : n1,n2s/^/#/g
      • : 1,4s/^/#/g,1 to 4 lines add # comment
      • : 1,4s/#//g, remove #
    • : n1,n2s/^#//g, get rid of the beginning #
    • : n1,n2s/^/\/\//g
      • 1,4s/^/\/\//g, beginning Add//comment
4. Replace
    • : AB mymail [email protected]
5.configuration of shortcut keys is written: 1) Address:
    • /root/.vimrc
    • /home/sam/.vimrc
2) operation
    • Direct Write command
    • Set Nu




Linux Basics (iv): text editor 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.