Some configuration files and usage of the VIM editor

Source: Internet
Author: User
Tags class operator

Some of the simplest configurations are those that can be written in the. VIMRC:

First, note that in the. vimrc file, you can use the "write off a line of configuration."

Set nocompatible "Turn off VI compatibility mode, where compatilble English means compatible

Set Nobackup "Overwrite the file, do not backup, where backup is meant to be backed up in English

Syntax on "automatic syntax highlighting; syntax means grammatical meaning;

Set number "displays line numbers;

Set Cursorline "highlights the current row, where cursor English is the meaning of the cursor;

Set ruler "Open the status bar ruler;

Set Tabstop=8 "indicates that the TAB key length is 8;

Set Cindent "Can be automatically indented, where incent represents the meaning of indentation;

Some simple shortcut keys

Description: Vimtutor is a good vim learning document that can be entered directly on the command line Vimtutor.

Delete the letter at the cursor with X;

Add with a at the end of a line;

Many commands that change text consist of an operator and an action.
The deletion command using the delete operator D is in the following format:

D Motion

which
D-delete operator.
Action object for the motion-operator (listed below).

A short list of actions:
W-does not include its first character from the current cursor position until the beginning of the next word.
e-from the current cursor current position until the end of the word, including the last character.
$-from the current cursor current position until the end of the current line.

Enter 0 (number 0) to move the cursor to the beginning of the line.

Enter $ to move the cursor to the end of the line.

Enter 2w to move the cursor forward by two words.

Enter 3e to move the cursor forward to the end of a third word.

A delete operator can be combined with an action. As above: d2w, d3e, D0, d$ and so on;

DD Delete the whole line, 2DD delete two rows;

Enter u to undo the last executed command, and enter U to undo the modification of the entire row.

Input Ctrl-r undo the Undo command, which is recovery.

Enter p after the last deleted content is placed in the cursor.

If you delete a row with DD and then press p, it will be pasted on the next line of the cursor.

To change the text until the end of a word, enter either CE or CW;

Changing the class operator works in the same way as deleting a class, which is equivalent to inserting mode. The Operation format is:

c [NUMBER] Motion

Enter CTRL-G to display the current position of the cursor in the current edit file and the file status information.

Enter uppercase G to allow the current cursor to jump directly to the last line of the file.

Enter GG to allow the current cursor to jump directly to the first line of the file.

Enter a line number, and then enter an uppercase G to jump to that line or enter: line number.

Enter R and a character to replace the character where the cursor is located.

Enter uppercase R to replace multiple characters consecutively.

Input: s/old/new/g can replace old to new, the cursor is on the line;

Input: S/old/new. Note that this command only changes the first matching string of the row where the cursor is located.

Enter: #, #s/old/new/g where #,# represents the line number of the two lines in several rows of the replace operation.

Input:%s/old/new/g is the replacement of each matching string in the entire file.

How to execute external commands within VIM: Enter:! The external command can then be executed immediately after entering an external command.

To save changes to a file, enter: W FILENAME.

Enter o to open a new line below the cursor and into insert mode.

Enter O to open a new line above the cursor and into insert mode.

W, e,$,0 can move the cursor;

Use V to enter visual mode, move cursor selection, copy text using operator y, paste text using P.

Write it here first and then add it later.

Some configuration files and usage of 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.