RCHE7 Management II-3 using the VIM editor

Source: Internet
Author: User
Tags switches

Different versions of Vim:

1.vim-minial provides VI and related commands. In the minimum installation of Rhel 7

2.vim-enhanced provides VIM commands. Provides features such as syntax highlighting, file type plug-ins, and spell checking

3.VIM-X11 provides Gvim, which is a vim version that can be run in its own graphics window rather than in the terminal

Three main modes of VIM:

Mode Function
Command mode File navigation, cut and paste, and simple commands. Undo, Redo, and other operations are also performed in this mode
Insert mode General text editing. Substitution mode is a variant of the insert pattern
Ex Mode Used to save, exit, and open files, as well as search, replace, and other more complex operations. This mode can insert the output of the program into the current file, as well as configure vim and so on

To switch to insert mode, the system provides the available commands that correspond to different keys

Key Results
I Switch to insert mode and start inserting (inserting) before the current cursor position
A Switch to insert mode and start inserting (attach) after the current cursor position
I Moves the cursor to the beginning of the current line and switches to insert mode
A Moves the cursor to the end of the current line and switches to insert mode
R Start with the character under the cursor and switch to replace mode. When in replace mode, no text is inserted, and each word entered nonspacing replaces the characters in the current document
O Opens a new row below the current line and switches to insert mode
O Opens a new row above the current line and switches to insert mode

Move

Key Results
W Move the cursor to the beginning of the next word (W will skip the punctuation)
B Move the cursor to the beginning of the previous word (b will skip the punctuation)
Move the cursor to the beginning of the current or previous sentence
Move the cursor to the beginning of the current or next sentence
{ Move the cursor to the beginning of the current/previous paragraph
} Move the cursor to the beginning of the current next paragraph

*********************************

in command mode

$: Jump to end of line

^: Challenge to the beginning of the line (press the number key 0 can also)

GG: Jump to the first line

G: Jump to the last line

YY: Copy one line

Nyy: Copy n rows

P: Paste

DD: Delete a row

NDD: deleting n rows

Jump directly to the last line

# VI + passwd

Jump directly to line 20th

# VI +20 passwd

Inserts the execution result of the command into the file being edited

: R! Uname-a

If you do not want to insert the execution results into the file you are editing, just look at

:! Uname-a

Take the contents of other files to the file being edited

: r/etc/passwd

Saves 1-5 lines of the current file to the new file Newname.txt

: 1,5 W Newname.txt

Delete Nth line: nd

Delete 1-10 rows: 1,10d

Add line number: Set Nu

Remove line number: Set Nonu

Edit two files simultaneously (toggle cursor between two files: ctrl+w first, then press left and RIGHT ARROW keys)

Vim-o t1.txt T2.txt simultaneously saved (: Wqall)

Search in command mode (n: Search up; N: Search down)

/All Keywords

For example:/nologin

Replace

: s/root/root/g #替换当前行

:%s/root/root/g #替换所有

: 1,5s/root/root/g #替换1-5 rows

Vim's help tutorial: Vimtutor

Look at the Chinese lang=zh_cn. Utf-8;vimtutor

RCHE7 Management II-3 using the 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.