0

I have hlsearch activated. Sometimes I search for terms I want to correct or delete via / and then selecting for the individual instance via n. Is there a command to delete the current word on which my cursor is on and which is highlighted via 'hlsearch'? I cannot use dw as sometimes the word is part of a camel case or snake case word.

1
4

gnd (or dgn) deletes the next occurrence of the last searched term (deleting at the cursor position if it matches the search). See :help gn.

(The hlsearch setting is irrelevant to this command.)

1
  • 3
    It's worth mentioning that cgn can be repeated with ., as in /wrongword<CR>cgnrightword<Esc>......
    – D. Ben Knoble
    Mar 24 at 0:17

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.