3

I'm trying to navigate to next dot in a file using windows version of vim:

f.

but it doesn't do anything as well as all other similar commands:

F.
d.
D.

What is correct way to do it?

5
  • 6
    f. doesn't move the cursor to the next dot in the file but to the next dot on the line. If your dot is not on the same line as your cursor, it can't work. If you want to move to the next dot in the file, you can try /\.. Now, if your cursor is on the same line as the dot, then maybe the problem comes from a shadowing mapping, what's the output of :nmap f ?
    – saginaw
    Nov 17 '15 at 16:30
  • 4
    There exist plugins, that allow the f and t command (and their upper case commands) to search not only in the current line, but also in the next line. Basically, this is done by mapping the f command to a search function. Nov 17 '15 at 18:24
  • Can you update your comment with the name or link to that plugin? I'd like to give it a try. Or just make it an answer with the actual binding?
    – d3day
    Nov 18 '15 at 12:12
  • 2
    If you want to replace/extend the built-in functionality for f and F, you probably need to install additional plugins. I asked the same question a while ago (vi.stackexchange.com/questions/4486/…) and got a lot of good answers. Not only f and F get extended in most plugins mentioned in that thread, but also t and T (till forwards and backwards). For example to delete a sentence, you would press df. (or if you wanna keep the full stop dt.).
    – cbaumhardt
    Nov 18 '15 at 18:32
  • @cbaumhardt thanks, will check it. I guess that's what I need here.
    – d3day
    Nov 19 '15 at 17:23
2

You can use the Clever-F or Vim-Sneak plugins to make the f and t motions automatically search over multiple lines, because usually they will only search within the current line.

4

The f command only works within the current line. But you can use the sentence motions ( "one sentence back" and ) "next sentence" to navigate across multiple lines.

Although this only works if the dot is followed by a space, tab or linebreak as mentioned in the help :h (

A sentence is defined as ending at a '.', '!' or '?' followed by either the end of a line, or by a space or tab. Any number of closing ')', ']', '"' and ''' characters may appear after the '.', '!' or '?' before the spaces, tabs or end of line. A paragraph and section boundary is also a sentence boundary.

If you can't hit your dot this way you should use the search function /\. Remember to escape the dot character because it has a special meaning in the search function. Otherwise you would search for every character.

4
  • how can I rebind all f and t to use this kind of search instead of default behavior?
    – d3day
    Nov 18 '15 at 13:20
  • you can create your own operator pending mapping. however, since the / and ? are working out of box, why not just use them?
    – Kent
    Nov 19 '15 at 12:31
  • @Kent because it's too many keystrokes I guess. f. is 2 keys and ?\.<CR> is 4; not that efficient to me. Unless I'm missing something here.
    – d3day
    Nov 19 '15 at 17:22
  • 1
    @d3day, you know about n and N, right? Because if you type /\.<CR> once, you can use n any number of times after that. (You should also know the ; and , commands if you don't already.)
    – Wildcard
    Nov 24 '15 at 18:26

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.