Another task you will probably use often when working with vi is deleting text. You can use many methods to delete text from vi. The easiest of them is from insert mode; just use the Delete and Backspace keys to delete any text you like. This works the same way you would do it from, for example, a word processor. Then, some options are available from vi command mode as well:
• Use x to delete a single character. This has the same effect as using the Delete key while in insert mode.
• Use dw to delete the rest of the word. That is, dw will delete anything from the current position of the cursor to the end of the word.
• Use dd to delete a complete line. This is a useful option that you will probably like a lot.
Was this article helpful?