Best of VIM tips-serialization 6 search (E)

Source: Internet
Author: User
Tags rewind

[Translation]

"Search for declaration of subroutine/function under cursor

"Find the subroutine under the cursor/Function Declaration

: Nmap gx yiw/^/ (sub/<bar> function/)/S/+ <C-R> "<CR>

[Annotation]

: Help: NMAP

: Help IW

: Help <bar>

Most of the content in this ing is described earlier. The idea is to first copy the word under the cursor to the unknown register, and then add the sub prefix or function prefix before the word for search.

NMAP is used to create a normal key ing.

IW is used to select a word. You can use ": help object-select" to query other text objects.

<Bar> represents the "|" character. This representation is often used in map commands. For more information, see ": Help <> ".

After understanding the principle of key ing, you can modify it as needed.

 

[Translation]

"Multiple File Search

"Multi-file search

: Bufdo/searchstr/: Use: rewind to recommence search

Use: rewindStart searching again

[Annotation]

: Help: bufdo

: Help: rewind

This command performs search in each buffer in the buffer list.

: The rewind command jumps to the first file in the parameter list. The parameter list refers to multiple file names that you give when starting Vim. For details, see ": Help argument-list ".

 

[Translation]

"Multiple File Search better but cheating

"Better file search skills

: Bufdo % S/searchstr/&/GIC: Say n and then a to stop

Input nEnterTo stop searching

[Annotation]

: Help: S

: Help S //&

: Help: s_flags

This command is quite skillful. It is actually used to replace the command for searching in multiple buffers. It is much better to use than the tip friends above.

After entering this command, it will traverse Each conformity item one by one. To end the search, press. Although this command is easy to find, it will be replaced once it exits midway through a, causing the change mark of the file to be set (the actual content of the file has not changed, because the original content is used for replacement ).

The replacement section will detail the S command.

 

[Translation]

"How to search for a URL without backslashing

"How to find a URL without using a backslash

? Http://www.vim.org/: (First) Search backwards !!!Clever huh!

First, search up!!!Smart!!!

[Annotation]

: Help?

When searching for strings such as directories or website links, because the content contains "/", if you use the "/" command to search, you need to escape the "/" in it, very troublesome.

If "?" is used, You can bypass escape characters by searching!

If you are looking for a string like "C:/A/B/C/D/E", doing so may be simpler:/<C-R> = escape ('C: /A/B/C/D/E ','/')

The above <C-R> is to be input by CTRL-R.

 

[Translation]

"Specify what you are not searching for (vowels)

"Specify not to search for anything

// C/V ([^ aeiou] &/a) {4}: Search for 4 consecutive consonants

Search4Consecutive consonants

[Annotation]

: Help // C

: Help // v

: Help //

This regular expression is used to find four consecutive consonants.

It uses two metacharacters. "/C" indicates that the content after it is case-insensitive, "/V" indicates that all '0'-'9', 'a'-'Z ', characters other than 'A'-'Z' and '_' are treated as special metacharacters, that is, "(" is equivalent to "/(", "&" is equivalent to "/&", and "{" is equivalent to "/{". This reduces the number of escape characters "/", which is much easier to input. If the literal meaning of these characters is used after "/V", you must add the Escape Character "/" to the character to obtain the original meaning.

 

[Translation]

// %> 20l/% <30 lgoat: Search for goat between lines 20 and 30 * n *

In20Line30Line SearchGoat

[Annotation]

: Help // % L

This regular expression is used to search within the specified row range.

"/%> 20l" indicates more than 20 rows, and "/% <30l" indicates less than 30 rows.

 

[Translation]

/^./{-} Home./{-}/zshome/E: Match only the 2nd occurence in a line of "home" * n *

Only match the "home" that appears for the second time in a row"

[Annotation]

This regular expression only matches the "home" that appears for the second time in the row. The metacharacters used in this regular expression are described earlier.

 

[Translation]

: % S/home./{-}/zshome/alone: Substitute only the occurrence of home in any line * n *

Only replace (Second time)"Home" appears"

[Annotation]

: Help: S

This command replaces the "home" that appears for the second time in all lines of the file ". Because the ": s" command does not use the "G" option, only the first matching string in the line is replaced.

Therefore, for a line like this, "My home directory is/home/easwy. his home directory is/home/test ", even if" home. "^" is not used in/{-}/zshome to specify the first line. It still replaces the "home" that appears for the second time ".

 

[Reference]

1. http://www.rayninfo.co.uk/vimtips.html

2. http://groups.google.com/group/Vim-cn/msg/f72fba0645955101?

3. Vim Help File

4. http://vimcdoc.sourceforge.net/

 

[Note]

This article can be freely used for non-commercial purposes. Indicate the source for reprinting.

Link: http://blog.csdn.net/easwy

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.