How do I search from the end of file using VIM? I want to search for the last occurrence of XXXX in the open file.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
My suggestion is to use a range combined with searching backwards via
?.Overview:
1?XXXXis the range.1means first line of the file.?XXXXmeans search backwards from the first line (wrapping around) until you find the patternXXXXAs ZyX mentioned this relies on
wrapscanto be set, which it is by default. See:h 'wrapscan'for more information.