3 ms·
> Pretend the following quoted text is in a text file: "hello world from mars." The cursor is over the first character in the second word of the text file and
by ldh0011 4y ago
> Pretend the following quoted text is in a text file: "hello world from mars." The cursor is over the first character in the second word of the text file and I am editing the text file with vim. I am in normal mode in vim. If I type dw, what does the text file contain now?
> If you are in normal mode in vim and you type dw, vim will interpret this as a command to delete the current word (which is "world") from the text file. After the command is executed, the text file will contain the following text: "hello from mars.".
The dw command deletes the word that the cursor is currently on. In this case, the cursor is over the first letter of the second word in the file, so the dw command will delete the second word in the file. If you want to delete the next word after the cursor, you can use the de command instead.
It is important to note that the dw and de commands only delete the characters of the word, not the spaces or other punctuation that may be present. In the example you provided, the period after the word "mars" will remain in the text file after the dw command is executed.