Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between dw and daw in Vim?

Tags:

vim

When I delete a word, I use dw, but I found out that there is daw, which can be memorized as “delete a word”.

Is there any difference between dw and daw?

like image 870
shin Avatar asked Dec 06 '13 04:12

shin


People also ask

What does Daw do in Vim?

dw deletes from the current position of the cursor to the beginning of the next word. daw deletes the word + trailing whitespace of the word the cursor is on top of regardless of where the cursor is.

What is DW in Vim?

dw means "cut from here to next word".

What is VIW in Vim?

viw - select 'inner' word.

How do I delete a word in Vim?

To delete a word, position the cursor at the beginning of the word and type dw . The word and the space it occupied are removed. To delete part of a word, position the cursor on the word to the right of the part to be saved. Type dw to delete the rest of the word.


2 Answers

From the documentation:

For example, compare "dw" and "daw": "dw" deletes from the cursor position to the start of the next word, "daw" deletes the word under the cursor and the space after or before it.

like image 187
matth Avatar answered Sep 21 '22 13:09

matth


:h daw

you will see more information.

"dw" deletes from the cursor position but the "daw" deletes the word under the cursor.

"daW" delete a WORD

:h word

A word consists of a sequence of letters, digits and underscores, or a
sequence of other non-blank characters, separated with white space (spaces,
tabs, ). This can be changed with the 'iskeyword' option. An empty line
is also considered to be a word.

:h WORD

A WORD consists of a sequence of non-blank characters, separated with white
space. An empty line is also considered to be a WORD.

like image 37
henices Avatar answered Sep 17 '22 13:09

henices