I was recently watching a more advanced vim tutorial on youtube. One of the commands used was _f. This was actually just part of a longer macro being demonstrated and the underscore wasn't commented on.

Using the letter e as an example: I tried it on a long line of text and there is indeed a difference between fe and _fe but I can't understand what is happening. _fe doesn't go to the first, second, or last occurrence of e on the line.

What is _f doing? Bonus points for why is it doing it!

EDIT to add example

The following is a single line of random text. With my curser at the beginning of the line fe arrives at the first e, which I have highlighted and demarcated.

2:5 Now no shrub of th**e** field had yet grown on the earth, and no plant of the field had yet sprouted, for the Lord God had not caused it to rain on the earth, and there was no man to cultivate the ground. 2:6 Springs would well up from the earth and water the whole surface of the ground. 2:7 The Lord God formed the man from the soil of the ground and breathed into his nostrils the breath of life, and the man became a living being.

However if I use _fe it skips over the first two instances of e and lands in the third instance.

2:5 Now no shrub of the field had y**e**t grown on the earth, and no plant of the field had yet sprouted, for the Lord God had not caused ...

I have tried it with other letters, with the similar result of not hitting the first occurrence of that letter.

  • 1
    Something is off. When I start vim with vim -u NONE and put your paragraph in (as a single long line) as the only line in a document, wherever I start the cursor off at _fe takes me to the first e. Can you confirm that skipping to the third e is the case when you start with -u NONE? Feb 26, 2021 at 16:33
  • Using -u NONE yields the expected result for _fe. I assume that means there is something in my .vimrc file causing the issue. Feb 26, 2021 at 18:15
  • 1
    Might be helpful: how do I debug my vimrc Feb 26, 2021 at 19:24
  • 1
    It sounds like something is mapping _ (or _f). Try :verbose map _ to get an idea of where that mapping might be.
    – husB
    Mar 1, 2021 at 15:27
  • Ugh. I have nnoremap _ 3 on line 185 of my .vimrc. (The reason for this is that I use vim for both Thai and English and when in the Thai keyboard the "3" key produces an underscore. I've fixed the mapping using Leader` and we are good to go until the next conflict!) ` Mar 2, 2021 at 16:51

1 Answer 1


_fe should go to the first occurrence of e on that line. Can you give an example of where it doesn't?

From :h _:

_  <underscore>         [count] - 1 lines downward, on the first non-blank
                        character linewise.

In other words, _ without a count moves to the first non-blank character of the current line, then fe goes to the first instance of e.

  • 3
    Similar to 0fe or ^fe, which I think are clearer
    – D. Ben Knoble
    Feb 26, 2021 at 14:02
  • Good point @DBenKnoble. I have to confess I’ve never used _, not least because it’s more effort to type than 0. Feb 26, 2021 at 14:12

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.