1

Here's an example:

console.log("basename of"path.basename(__filename))
console.log(path.dirname(__filename))

With my cursor on path in the first line, I've tried:

dt2)

but then my cursor jumped to the next line, at __filename)), which is last character of that line. I also Googled around and tried:

dt2/)<Enter>

Nothing happened, and I have to manually cancel the highlighting of search the results.

3

If you want to delete till the second occurence:

d2t)

Which translates to:

d2t)

d    " Delete
  t  " till
 2   " second occurence of
   ) " )
3
  • Oh, I thought dt2) is more intuitive, thanks a lot!
    – job_start
    Jul 10 at 10:36
  • 2
    @job_start dt2) translates to delete till the character 2 Jul 10 at 10:38
  • 1
    Welcome to Vi and Vim! The reason for the cursor movement is what you pointed out in that last comment: vim sees two commands. (1) dt2, which fails (assuming 2 is not in the line after the cursor). (2) ), which moves to the end of the "sentence"
    – D. Ben Knoble
    Jul 10 at 20:00

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.