Vim Common variables

Source: Internet
Author: User

For vim to better support Python to write code, modify the tab default 4 spaces There are two ways to set up:

1. VIM/ETC/VIMRC

1 Set ts=4

2 Set sw = 4

2. VIM/ETC/VIMRC

1 Set ts=4

2 Set Expandtab

3 Set Autoindent

The second is recommended, which results in 4 spaces when you press the TAB key, which has the best compatibility.


Eclipse Set Soft tab (with 4 space characters instead) and default Utf-8 file Encoding (Unix)
For these two purposes, the following is done for Eclipse compatibilityThe configuration:

Description :

The following settings are available in the menu "window--Preferences", the English version of Eclipse, the Chinese version of the menu options for the camera.

first of all , the text editing often need to use the tab key indentation ,

Use 4 space characters instead,

To make sure that the indent format is still correct when you open with VI or VIM.

The setup steps are as follows:

1. Open option:Text Editors, Editors , General

Find Displayed tab widthon the right:

Check the following "Insert spaces for tabs"

Click OK after saving, create a new HTML file to enter a few tab keys and press the left and RIGHT arrow keys to move the cursor test,

found that the original tab has been replaced with 4 space characters.

Add line number:

Enter ": Set nu" in the command mode of VI
or modify the VI configuration file "Vi VIM/ETC/VIMRC", where you add "set Nu"
Enter ": Set nu" in the command mode of VI, there is a line number.
But to write this setting in the VI configuration file,
# VI ~/.VIMRC
In this file, add
Set Nu
It's all right.
Set Nu--To display line no
Set Nonu--not to display line no

CTRL + G to know the line number of the cursor line

Shift+g can go to the last line. Enter line number under: To reach the corresponding row

To search up from the current cursor position, use the following command:

/pattern Enter

Where pattern represents a specific sequence of characters to search for.

To search down from the current cursor position, use the following command:

? pattern Enter

When the ENTER key is pressed, vi searches for the specified pattern and positions the cursor at the first character of the pattern.

To search for additional matches for place, press N or N:

N, continue searching for place in the same direction.

N, search in the opposite direction.

If VI does not find the specified pattern, the cursor position is unchanged and the following message is displayed at the bottom of the screen:

Pattern: Not Found

Search for special matches
In the example above, VI finds any sequence containing place, including displace, placement, and replaced.

To find a single place, type the word and add a space before and after it:

/Place Enter

To find place that appears only at the beginning of the line, add a caret (^) before the word:

/^place Enter

To find place only at the end of a line, add a currency symbol ($) after the word:

/place$ Enter

Use ^
To search for this character with the caret (^) or currency symbol ($) Verbatim, add a backslash (/) before the character. Backslash Command VI searches for special characters.

Use $
Special characters are characters that have special features in VI (for example, ^, $, *,/, and.). For example, $ usually means "go to the end of the line," but if $ is immediately preceded by A/, then $ is just a normal character.

Use
For example,/(no/$ money) searches up the character sequence (no $ money). Immediately before the escape character (/) command VI searches the currency symbol verbatim.

Undo command:

: U

Restore command:

: Red

Vim Common variables

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.