In normal mode I can hit Ctrl
+ E
which deletes the rest of the current word and goes to insert mode.
I want to delete the entire word, regardless of the cursor position (within the word of course).
Ctrl-O in insert mode will allow you to run a single normal mode command and automatically return back to insert mode. x deletes the key under the cursor.
Open a new or existing file with vim filename . Type i to switch into insert mode so that you can start editing the file. Enter or modify the text with your file. Once you're done, press the escape key Esc to get out of insert mode and back to command mode.
You can use "change inner word" by typing "ciw" to delete a word your cursor is on.
The "inner" and "a" commands are great in Vim, also try "ci{" inside a {} block, or "ca{" if you also wish to remove the {} characters too. To translate these commands to English to remember them better, try: "change inner { block" and "change a { block".
Documentation at http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objects
Answer to your follow-up question: viwp
v -> start visual mode iw -> select the 'inner word' p -> paste - in visual mode it replaces the visually selected text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With