6

It is easy to move to a specific character on the same line with t or f.

However often it is useful to move to the specific character that is positioned on a different line.

Consider this example:

smth smth smth
bla bla bla 
|

more bla bla bla

maybe some more bla

the end ```

here | represents the cursor.

Is there an easy way to move the cursor to the three ticks after the end?

What seems to be required is for f or t commands to ignore the new line symbol. But I don't know how to achieve that.

4 Answers 4

5

If you want f and t to work beyond the line where the cursor is you could use the ft_improved plugin. This allows you to use the f and t for not only inside the current line, but move to whatever line, where the character is found.

But as others have written I think /{char} works nicely for that. The only inconvenience would be if you have hlsearch set. In that case all occurrences of {char} would become highlighted as a side effect.

1
  • 1
    Thanks. I got convinced that it's not really that useful to use this approach as in such situation one can resort to /{char}. But I accepted your answer in place of the previous one because it answers the original question instead of saying why one should not do it. Commented Feb 7, 2015 at 20:51
5

You could check out the EasyMotion plugin. With that you could do something like

<Leader><Leader>f`

which would show you all of the backticks you could possibly jump to and give you a shortcut for doing so.

1
  • EasyMotion is absolutely mindblowing! Commented Mar 8, 2015 at 10:32
5

IMO it isn't useful to move to a character on a separate line. There are only 26 characters in the english language and it doesn't take a lot of characters before most of the characters repeat enough times for them to not be unique.

Although in rare case it is still possible to encounter such a situation but I think making that assumption would be wrong.

In my opinion when you have to move to another section within the same file you have to resort to other better motions that vim provides. There are far too many options at your disposal to list here but the most common that comes to my mind is via searching. You can always enable incsearch and just start searching with /t and that would be a better way to get to your character on another line than the character motions like f,t.

1
  • Thanks for the answer. This seems to be reasonable. I thought maybe I was missing some modifiers, but /<char> is good enough. Commented Feb 6, 2015 at 17:31
5

A search would do:

/`<cr>

Your Answer

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

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