Linux Learning 5 Text editor vim

Source: Internet
Author: User

Vim has no menu, only commands

VI FileName---> Enter command mode to enter the edit mode directly, enter the end of the run, input Wq save and exit

In command mode: Enter AIO into insert mode, ESC returns to command mode

A, after the cursor A, the end of the line

I, front of cursor I, beginning of line

O, insert a new line under the cursor

Command:

___ Location Command

: Set Nu/set Nonu

Gg/g to first line, last line

ng =: N to nth row

$/0 move to end of line/beginning

___ Delete command

X/nx Delete the character of the cursor/n characters

DD/NDD, row, n rows

D/DG To line end/to end of file

: n1,n2d The row of the specified range

___ Copy and cut

Yy/nyy copying when moving forward

DD/NDD Cut

p/p paste in the line below/above the current cursor

___ Replace and Cancel

R replaces the character at which the cursor is located

R replaces the character at the point where the cursor is located, press ESC to end

U Cancel the previous action

_______ Save and exit

: W Save changes

: w new filename

: Wq Save Exit

ZZ Ibid.

: q! Exit does not save

: wq! Same as: Wq, file owner and root can be used

_______ Search and search replacements

/string searching for a specified string

: Set IC ignores case

N Find the next

:%s/old/new/g full text overrides specified character

: n1,n2s/old/new/g within the specified range ....

___ Usage Tips

: r! command

Import command Execution results

: Map

Defining shortcut keys, triggering commands

: Map ^p i#<esc>//Line Header Insert # comment. ^ is not a character, but a display after Ctrl + V input

: Map ^b 0x//Delete first character

: AB

replacement, eg,: AB mymail [email protected]

: n1,n2s/^

Front is the range, ^ represents the beginning of the line

: n1,n2s/^/#/g Continuous Line Comment

: n1,n2s/^#//g uncomment consecutive lines

: N1,n2s/^/\/\//g The beginning of the comment//. \ is the escape character, \/is the meaning.

_______

. VIMRC

Config file, in home directory

Linux Learning 5 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.