Linux learning 2-vi Editor

  1. First add the operation of gedit

    • ctrl + z: Undo
    • ctrl + c: Copy
    • ctrl + v: Paste
    • ctrl + t: Indent
    • ctrl + q: quit
    • ctrl + s: Save
    • ctrl + r: Replace
    • ctrl + tab: switch
    • ctrl + w: Close Tab
  2. Vi editor three basic modes

    • FigureHere Insert Picture Description

    • The picture shows the conversion between the three modes, according to the arrow marked can switch between the three states, each mode have different functions:

      • Normal Mode: The cursor movement, copy, paste, delete;
      • Edit Mode: Edit the file
      • Command-line mode: Find and Replace
    • Three modes tips

      • When not know which mode is, press esc to return to normal mode (regardless of the mode, press the esc key must be returned to the normal mode)
  3. vi Command Summary

    3.1 General Mode
    • turn on: vi + 文件名
    • New: vi + 新文件名
    • Save and Exit :wq
    • Exit without saving: :q!
    • drop out: :q
    • After editing should return to normal mode. Save the file:w
    3.2 Edit mode

    From the normal mode into the editing mode the following three commonly used keys, press after targeted to different positions:

    • iKey, inserted from the front of edit cursor
    • aA cursor inserted from the rear, than the `` `$ rearward command again:
    • oOpen up a new line from the next line of the Bank, and navigate to the beginning of the line
    3.3 cursor
    • Under normal modehjkl to move the cursor
      • H:left
      • J:under
      • K:on
      • L:right
    • Under normal mode : to quickly locate a row
      • Header: Nggthe cursor to the first N trekking ( 3ggto line 3)
      • End of the file: Gend of Go to File
      • Specify a row
    • Under normal mode
      • 0: Locate the beginning of the line
      • $: Positioning the end of the line
      • f+x: Navigate to the next there is a xplace
    • Under normal mode, text copy, paste, delete, undo
      • yy : Copy the line (yank)
      • nyy: N-1 and subsequent row diverted replication
      • p: Paste
      • dd: Delete the row
      • ndd: N-1 line and delete diverted back
      • u : Revocation
      • x Delete character position of the cursor
    • Command-line mode Find and Replace command
      • Seek /+查找字符
      • Find Search after: nforward search Nis negative to the search (it is generally the first to jump to the first trekking then search)
      • Replace 1: :%s /原字符/新字符/g:
      • Replace 2::%s /原字符/新字符/gc
      • s(substitute); g(global); c(confirm)
Published 58 original articles · won praise 20 · views 50000 +

Guess you like

Origin blog.csdn.net/GENGXINGGUANG/article/details/104883230