4

Is there a way to search and replace from a specific position in the line to the end of this line?

I am here and you are there
         ^

I tried to show cursor position with ^. For instance, I don't need to replace here which is before the cursor and want to replace the second one (which is a part of there)

6

You can do it by using visual mode.

In normal mode (with the cursor where you want it)

v$ (Start visual mode and move to end of line)

Esc (Move back to normal mode)

:s/\%Vhere/xxxx/g (The substitute command needed)

The important part is the \%V, you can read more about it here:

https://vim.fandom.com/wiki/Search_only_over_a_visual_range https://vim.fandom.com/wiki/Search_and_replace_in_a_visual_selection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.