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.
-
1Welcome to Vi and Vim!– D. Ben Knoble ♦Mar 24, 2021 at 0:17
1 Answer
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.)
-
4It's worth mentioning that
cgn
can be repeated with.
, as in/wrongword<CR>cgnrightword<Esc>......
– D. Ben Knoble ♦Mar 24, 2021 at 0:17