I would like to know how a "d3fg" command works in vi.

I have done some research on Google and found that d is delete and fg means foreground. Suppose, if we want to stop the session of vi and resume it afterwards, we can press Ctrl+z to come out of the vi session. Then type fg to go back to the same vi session.

Now I wanted to know how this d3fg works in vi editor.

  • 1
    The best way to find out what a single command in Vim does, is not google, but the help system. Simply type :h f to get help on the f command.
    – elyashiv
    Mar 1, 2015 at 20:35
  • 1
    @elyashiv not very useful when one thinks of the command as fg. What does :he fg give you?
    – muru
    Mar 2, 2015 at 11:04
  • @muru a lout of information - you find out there is no command fg (just -fg), so you conclude the command is f...
    – elyashiv
    Mar 2, 2015 at 20:40

1 Answer 1


In fact, fg is "foreground" in Bash, but not in Vi(m). d3fg means:

d - Delete until...
3 - Do the next motion 3 times
f - Go to the next occurrence of the next character pressed.
g - The character to go to.

Thus, d3fg will delete up to (including) the third letter g on the line after the cursor.

Thus the following text, with the cursor on the 0:


Becomes after d3fg:


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.