To do this, you must first sharpen the tool-vim-tips.

Source: Internet
Author: User

1) Why can't other people's methods work for me?

(2) how to find the last edited file?

(3) how to copy and paste it?

(4) how to replace multiple files?

(5) how to open all fold once?

(6) how to select or copy the word where the cursor is located?

(7) how to count the searched strings?

(8) how to remove the highlighted search?

(9) How can I solve the problem of garbled chinese menus in gvim in Linux?

(10) How to highlight the edited File Syntax?

(11) How to quickly insert multiple rows of numbers 0-99?


========================================================== ==============================================

(1) Why can't other people's methods work for me?


It is estimated that this is the most difficult question to answer. :-)

First, check whether your vim version is new enough and whether the functions are complete. Use the: Version command to view your

Vim version and functions. In a common situation, if you are using the RedHat system, be sure to install

The RPM package of vim-enhance, otherwise it will be incomplete vim.


(2) how to find the last edited file?


CTRL + O (press twice)


(3) how to copy and paste it?


Method 1: First Ma marks the current position as a, move to the new location, and then copy from position a to position

The content of the current location. The difference between 'and': 'is a character, and' is a behavior unit. This method should be for all vi

Applicable. (If not, please correct it .)

Method 2: Press V, V, or Ctrl + V to enter the visual mode, move the cursor to select a piece of content, and press y. Differences:

V is a unit of characters, V is a unit of behavior, and CTRL + V is a block selection. This method is only applicable to vim.

You can use J to merge the upper and lower rows into one row.


E) converts a paragraph into uppercase letters.

~ Case sensitivity (a-> A, A->)

U converts lowercase letters to uppercase letters (A-> A, A->)

U is written in uppercase and lowercase (a-> A, A->)


(4) how to replace multiple files?


Generally, sed or Vim can be used. For example, to replace the *. c file in the current directory:

Method 1:

For I in *. C; do

Sed-I-e's/oldvalue/newvalue/G' $ I

Done

Method 2:

Vim *. c

: Argdo % S/oldvalue/newvalue/g


(5) how to open all fold once?


ZR or: Set foldlevel = 999


(6) how to select or copy the word where the cursor is located?


In vim, IW or aw is used to represent a word. The two are slightly different.

Select the word where the cursor is located: VIW (V enters visual mode, then IW)

Copy the word of the cursor: yiw


(7) how to count the searched strings?


To count the occurrence frequency of a pattern in the buffer, set 'report' to 0, and then

Use the replace command to replace the mode with itself. The number of replicas reported by VIM is the number of occurrences of the mode. Example:

: Set Report = 0

: % S/./&/g characters

: % S/\ I \ +/&/g words

: % S/^ lines

: % S/The/&/g "the" anywhere

: % S/\ <The \>/&/g "the" as a word

You may want to reset 'hlsearch' or use ": nohlsearch ".


(8) how to remove the highlighted search?


Method 1: nohlsearch

Method 2:/awertgvcxz (find a string that certainly does not exist)

After the highlighted search (: Set hlsearch) is set, you can disable the highlighted search permanently through: Set nohlsearch.

Display. You can also temporarily disable the highlighted feature by using nohlsearch. The highlighted feature is automatically restored during the next search.


(9) In Linux, how does one solve the problem of garbled chinese menus in gvim?


Take vim6.3 as an Example

Source/usr/local/Vim/share/Vim/vim63/delmenu. Vim

Source/usr/local/Vim/share/Vim/vim63/menu. Vim


A single menu. vim or nothing is garbled.

In addition, some netizens reported that such problems were not encountered.


(10) How to highlight the edited File Syntax?


It should be explained that there are many variants of VI, which do not provide such a function.

It is often its derivative versions, such as vim. The following describes how to highlight the syntax in vim.


First, determine the operating system you are using. If it is windows, the default configuration file

You can work now. If not, you can click the syntax menu and select the one that suits you.

File type (by default, gvim of the new version disables the file type, which needs to be clicked, and

Start with a letter and select a type)

If it is Linux, check whether it is RedHat. For RedHat, install

Vim-enhanced RPM package. After doing this, you can use syntax on to enable syntax highlighting.

If necessary, use: Set filetype =... to set your file type.

If you use a graphical interface, such as gvim, you can perform syntax on and set filetype operations.

Select from the menu with the mouse, the same as in windows.

If you are using Vim in the console, you should also make sure that the supported color is set on your terminal.


(11) How to quickly insert multiple rows of numbers 0-99?


Enter the following code in the command line, or save the code to an external file, and then the source file:

Let I = 0

While I <1, 100

Put = I

Let I = I + 1

Endw

If the number of digits is not enough, you can use ctrl-V to select and insert 0 to the I.


※Modify: · thinelephant: modify this article at Jun 30 11:03:43 · [from: 211.100.11. *]

※Source: · BBS shuimu Tsinghua station smth.org · [from: 211.100.11. *]



Sender: Vale (shangu · waiting stream), email area: Vim

Question: strong features that are hard to find in VIM

Mailing station: BBS shuimu Tsinghua station (Mon May 31 10:54:41 2004), within the station


When I first used vim, I did not know some functions. I regret doing so much physical work after I found out.


1. * (Super Star)

Look down for & lt; word> under (or near) the cursor. Search for # above #. If you search for G *, whole word is not restricted.


1. C-R (MAGIC insert)

In insert mode, the C-R (Register) inserts contents in register, an interesting Reg is "= ".

Suppose you want to enter 12 K of the specific number of bytes, do not open the calculator, try this "<C-R> = 1024*123 <CR> ",

"125952" is coming out!

In addition, the C-R C-W and C-R C-A in the command line are required techniques, they place the cursor under the <word> and <word>

The command line saves you countless typing tasks.


3. C-X (Auto complete)

In the insert mode, the C-X C-P/n/L/F and so on automatically complete the previous word, line, file name, etc., is required for programming

Command. Where C-P and C-N can be used without C-X.


4. [P &] P (smart paste)

Paste automatically adjusts the indent of the source row based on the indent of the target row. It is useful when copying code segments.


5. C-O (fast out, fast in)

In insert mode, you can execute a normal command after using the C-O, and then immediately return the insert mode, saving

It is troublesome to use ESC.


6. [I (fast grep)

The [I display file contains all <word> rows under the cursor. I often use it to browse the reference of an ID in a program.

There are also many related commands: H include-Search


7. Object-select

IW, aw, IB, I], I}... are very useful! See help.

: H object-select



Write so much first, and then add it later.


--

The world puts off its mask of vastness to its lover.

It becomes small as one song, as one kiss of the eternal.



※Source: · BBS water Mu Tsinghua station http://smth.org · [from: 210.82.111. *]


Sender: ann77 (ANN), email area: Vim

Question: My commonly used Vim Functions

Mailing station: BBS shuimu Tsinghua station (Fri May 28 13:39:08 2004), within the station


I can think of it right away.


1.


FX

X represents any character.

This is the fastest way to move in one row. Then use

; (Semicolon)

Continue to move.


Reverse movement seems to be t, but I have a bad memory,

I can't remember it, so

0fx

Return to the beginning of the line with 0, in F


2.

Add a move command to any operation command. To perform operations on a certain range.

For example

DFX

Delete to the next place where x appears. X can contain any character.

Operation Commands include D (CUT), y (copy), P (paste), V (select)

Mobile Commands include hjkl, F,/, GG, and G.


3.

You can repeat any command combination by using some numeric keys.

For example:

D123j

Delete the following 123 rows.


4. Macro record Function

For example, merge all odd and even rows in the file. Follow the sequence below

Gg

Qq

J

Q

100000000 @ Q


5. C-P

In insert mode

When writing a program, any super-long variable name is not a problem.

If there is a this_is_very_long_variable_name

Yes

This <C-P>

90% of the possibility is to automatically complete the name.


As a result, when I write a program, the variable name grows and the input speed increases. :)


6. C-x C-P

When writing a program ABC. H

When I wrote # include "ABC. H ",

Actually, yes.

# Include "A <c-x> <c-P>"


In 90%, You can automatically complete the file name.



6. Input External commands

: R! Ls

You can read the list of files in the current directory.

This function is very useful if you are familiar with Bash.

For example

Input

Case 1

Case 2

....

Case 1000:

The method is

: R! For (I = 0; I <100; I ++); Do echo "case $ I"; done


7. Use External commands to process text.

I am in ~ /. Vimrc writes a row.

Map = ggvg :! Indent-nut-St-Kr 2>/dev/null <CR> G


By pressing =, I can use the external command indent to beautify my C program.

I think,

You can also sort data by external commands.

For example

Use V to select the region to be sorted

Then press an exclamation point.

: '<,'>! Sort


8

I am in ~ /. Written in vimrc

Map <left>: BP <CR>

Map <right>: BN <CR>

Map <F4>: BD <CR>


You can use the left and right coordinates to switch the buffer.

F4 shut down the buffer.


9

I am in ~ /. Written in vimrc

Runtime ftplugin/man. Vim


You can place the cursor on a function, and then use

\ K

View online help.

Use

: Man getuid

Check the getuid function manual.


10.

: Make

You can use the external command make to compile the project.

: CW

View error information,

: CN

: CP

Jump between error messages.


11.

], [[, [],] [Commands can be moved between functions.

Add to favorites

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.