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?
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.
f
and t
to use this kind of search instead of default behavior?
/
and ?
are working out of box, why not just use them?
f.
is 2 keys and ?\.<CR>
is 4; not that efficient to me. Unless I'm missing something here.
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.)
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
?f
andF
, 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 onlyf
andF
get extended in most plugins mentioned in that thread, but alsot
andT
(till forwards and backwards). For example to delete a sentence, you would pressdf.
(or if you wanna keep the full stopdt.
).