1

I want to replace the 50th occurrence of Alex with Alex(the father) using vim.

The problem is this: after I execute the replace command, I want to search again for the word Alex and I do not want the replaced one to be displayed anymore. So when I do gg49/Alex and press 'n' I want vim to skip Alex(the father) and jump to the 51st occurance of Alex (51st in the original document).

So what I want is that vim does not show me the sub-string Alex, only the exact match. Is there any way to do this?

1 Answer 1

1

You can do this search with a negative lookahead against a left parenthesis to avoid matching Alex when it is followed by anything that starts with (.

/\<Alex\>\((\)\@!
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.