2

I have a vim script that does the following:

normal 3f,
normal lvnh"+y

But if I search for anything other than /,/ before hand, the n in normal lvnh"+y matches whatever I searched for last instead of the intended ,.

So why does it do this, and how do I get it to search for a , instead? Not a search and replace, but just a search for a ,?

  • why do you want your n to do anything else? I think you need to search again for /,/ before using n – nobe4 Apr 26 '16 at 13:57
  • @Nobe4 Because I want to say on the same line and select to the next , – leeand00 Apr 26 '16 at 13:59
  • I'm not sure I understand, do you want to stay on the same line ? – nobe4 Apr 26 '16 at 14:01
  • @Nobe4 Yes, I'm in a CSV and trying to switch to visual mode and select from the character I'm at to the next matched , in the line. – leeand00 Apr 26 '16 at 14:06
  • 4
    @leeand00 I think you confused n which allows to repeat the last search made via / and ; which allows to repeat the last f movement. – statox Apr 26 '16 at 14:06
10

You confused nwhich repeat the last search (made via / or ?) and ; which allows to repeat the last f, F, t or T movement.

As a bonus n and ; go forward while N and , go backward.

See :h n and :h ; as references.

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.