[Practical.vim (2012.9)]. Drew.Neil.Tip50 Study Summary

Source: Internet
Author: User

Search to Navigate

The character search commands (F{char}, T{char}, and so on) is fast and lightweight, but they has limitations. They can only search for a single character at a time, and they can only operate within the current line.
Character Search commandf{char} , t{char}And so on, very fast, but these commands can only search for one character at a time, and can only be manipulated in the current row.
Suppose that we want to position our cursor on the word ' takes ' in this sample:
Suppose we want to locate the word "takes" in the following text

We can use the search command./takes
Operate with a Search Motion
We ' re not limited to using the search command in Normal mode. We can use it from the Visual and operator-pending modes just as well to do real work. For example, suppose so we wanted to delete the text ' takes time but eventually ' from this phrase:
The use of SEARCH commands is not limited to this. We can use it in visual and operator pending patterns to do some other useful work. For example, suppose we want to delete "takes time but eventually" from the following text

To begin with, we pressvTo switch to Visual mode. Then we can extend the selection by searching for the short "GE"String, which puts the cursor where we want it in a single bound. Well, Almost-we has an off-by-one error. The selection includes the "g"At the start of the word, but we don ' t want to delete that. We ' ll usehTo back up one character. Then, have defined our selection, we'll delete it with theDCommand.
First, we entervSwitch to Visual mode, and then search through the"GE"The string expands the selection, and the cursor rests on the first character of the getsgOn But there is a problem that the last character of the selection range contains the charactersg, we do not want to delete it, so we use the command H to step back a character. Finally, then usedcommand to delete the characters in this range.
Here's an even quicker the doing the same thing:
Here's an easier way to do this.

Here, we use the /ge search motion to tell the d{motion} command "what" to delete. The search command is an exclusive motion. That means this even though our cursor ends up on the 'G' at the start of the word 'gets, ' that charact Er is excluded from the delete operation
Here, first position the cursor on the takes , and then use the /ge Search command d{motion} to tell the command where to delete. This search operation excludes motion, meaning that even if the last cursor rests on the first character g of the Get, the character is finally excluded from the delete operation.

[Practical.vim (2012.9)]. Drew.Neil.Tip50 Study Summary

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.