VI and VIM Editor

Source: Internet
Author: User

VI

VI is a computer text editor, written by the American computer scientist Bill Joy Bill Joy, and released in 1976 with the BSD license.

Vim

Vim is a text editor developed from VI. Its code completion, compilation and error jump and other convenient programming features are particularly rich, in the programmer is widely used. And Emacs are a favorite editor for Unix-like system users. The first version of Vim was released by Blame Miller in 1991. The initial abbreviation is VI imitation, with the continuous increase of function, the official name changed to VI improved. It is now free software released in open source mode.

Usage:

vim [options] [File ...]

Options:
    • +#: Jump directly to Line # when opening a file
    • +/pattern: Immediately after opening the file, leave the cursor at the beginning of the first line that is matched to the PATTERN
    • -B: Binary mode open File
      • :%!xxd: Extended command mode, using XXD command to convert to readable hexadecimal
      • :%!xxd–r: In extended command mode, use XXD command to convert back to binary
    • -D file1 file2 ... : Open multiple file comparisons, ==vimdiff
    • -M: Open file as read-only
    • -e: Go directly to ex mode when opening files, or use ex file
Vim mode: Command mode, insert mode, extended command mode

Use ESC in any mode to return to command mode

One, Command mode

Some shortcut commands are not displayed in command mode and you need to perform a full command to see the changes

Command mode---insert mode:
    • I: Changes to insert mode at cursor position
    • I: Change to insert mode at the beginning of line
    • A: Under the cursor a word character into insert mode
    • A: Turn the end of the line into insert mode
    • O: Enter insert mode on the next line from another row
    • O: A new row enters insert mode on the previous line

Quick actions in command mode

    • ZZ: Save exit
    • ZQ: Do not save exit
    • . (point): Repeat Last Action
Cursor Jump:
             ^             k              Hint:  H key on left and move       left < h       L >               L key on right and move right.                     The J key looks like a downward arrow.             v
    • W: The first word of the next word
    • E: The ending of the current or next word
    • B: The first word of the current or previous word
    • H: Jumps to the top of the current page
    • M: Jumps to the page of the current page
    • L: Jumps to the bottom of the current page
    • ^: Jump to the first non-whitespace character at the beginning of a line
    • 0: Jump to the beginning of the line, ==home key
    • $: Jump to end of line, ==end key
    • G: Jump to the last line of the file
    • GG: Jump to the first line of the file
    • (): Jump between sentences
    • {}: Paragraph jumps
    • CTRL+F: Flip one screen down
    • Ctrl+b: Turn up one screen
    • Ctrl+d: Flip Down half screen
    • Ctrl+u: Flip up half screen
    • n| N: Search between keywords jump Next | previous
Character manipulation:
    • X: A character at the clipping cursor
    • ~: Convert Case
    • J: Remove line breaks after the current line
    • R: Replaces a single character at the cursor
    • R: Enter replace mode, replace the character of the cursor, press ESC to return to command mode
    • D: Delete
      • DD Delete entire row
      • d$ Delete from the cursor to the end of the line
      • d^ Delete from the cursor to the non-empty header
      • D0 Delete from the cursor to the beginning of the row
      • DW Delete A word to the first of the next word
      • De Deletes a word to the end of the word
      • #dd Delete # lines
      • D is deleted from the current cursor position to the end of the line, leaving blank lines, equivalent to d$
    • Y: Copy
      • Y$,y0,y^,yw,ye, #yy operations similar to the D command
      • Y copy Entire row
    • p| P: Whole line, paste below the line | top; non-full row, paste behind cursor | front
    • C: Change to insert mode after deletion, modify command
      • C$,c0,c^,cw,ce
      • CC Deletes the current line and becomes insert mode, = = S
      • C Delete the current cursor to the end of the line and switch to insert mode
    • # I string [ESC]: Paste string # times
    • 0gu$|0gu$: Replace entire line with size | lowercase
Revocation and Revocation revocation:

U: Undo Just changed

U: Undo the change of all this row after the cursor falls on this line

Ctrl-r: Undo the last Undo change

Two: Extended mode (Extended command mode)

:(colon): Command mode--extended mode

w [FiLE]: Save and Save As

Q: Exit

X: Save and exit

!: enforced, direct command can execute the command on the system,!R can read the result of the command into the file

R: Read in file

Address delimitation:: Start_pos,end_pos

    • #: Specify # Lines
    • #,#: From # line to # line
    • #,+#: # line down # line
    • 0: Indicates the first row
    • .: Indicates when the forward
    • $: Indicates the last line
    • %: Full text
    • /pattern1/,/pattern2/: Represents the row from the first time the pattern is matched to the second time the pattern is matched to the row
    • followed by an edit command, D,y,w,r, and so on to manipulate the contents of the specified range

Find replacements

S: Operating range s/What to look for/replace with content/modifier (g global; C hint whether to replace; I ignore case)

/: Delimiter can also be comma, @, etc.

Three: Find mode

/

Four: Visualization mode

V: Manipulation of characters

V: operation on Rows

CTRL + V: Action on block

Select what you are doing, and then use commands such as d,y,p to manipulate the text

Five: Multi-file mode

Vim FILE1 FILE2 ...

    • : Next Next
    • :p Rev A previous
    • : First One
    • : Last One
    • : Wall Save All
    • : Qall Quit all
    • : Wqall
VI: Multi-window Mode

Multi-file Segmentation

Vim-o|-o FILE1 FILE2 ... : Horizontal | Split two files vertically and multiple file windows

Single File segmentation

Ctrl+w,s|v in command mode: Horizontal | vertical Split window

CTRL+H|J|K|L: Toggle cursor between windows

Ctrl+w,q|o: Cancel adjacent window | All windows

: Wqall: Exit all Files and Windows

Vim Registers

There are 26 named registers and 1 unnamed registers, which often store different contents of the Clipboard, which can be shared between different sessions.

Register name A, b,..., z, format: "Registers are placed between numbers and commands;

Unspecified, no named registers will be used;

There are 10 digital registers, denoted by 0,1,...,9, 0 stores the most recently copied content, and 1 stores the most recently deleted content. When new text changes and deletions, 1 dumps to 2, 2 dumps to 3, and so on. Digital registers cannot be shared between different sessions.

The personalization of Vim

Global configuration file:/ETC/VIMRC

User profiles: ~/.VIMRC

Set: Execute in extended mode or write to config file

    • Nu Display Line number
    • IC ignores character case
    • Ai Auto Indent
    • Si smart Indent
    • Hlsearch Highlight Search
    • The list shows tab and line breaks ^i and $
    • Ff=dos|unix Enable UNIX Format | Windows format
    • textwidth=# Setting the text width
    • Cursorline set the identification line of the line where the cursor is located
    • Paste copy Preserves original format

Set all or help option-list get set

Syntax On|off syntax highlighting

Vimtutor

The official learning and practice documentation that comes with VIM

Report:

Welcome to learn to communicate with US ~

VI and VIM Editor

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.