With Vim editor, before deleting lines or words, I'd like to view what I delete before committing a big mistake. Could anyone have an idea how could it possible to do that? Is there exist a command-line for that? If so, how could I do that?
2 Answers
As @ThomasDickey wrote there's a visual mode that you can enter by pressing v. This starts selection. After entering visual mode you can move the cursor around to select the extent of the text you want to delete. If you then press x it will delete everything selected, including the character under the cursor, and exit visual mode.
You can exit visual mode at any time by pressing Esc.
You can enter visual block mode by pressing Ctrl-v. This enables you to delete a rectangular block of text, or to insert (using Shift-i) into multiple lines at once.
If you're executing a global search and replace, such as
:%s/replaceme/withthis/g Then you may tag on a c (for "confirm"):
:%s/replaceme/withthis/gc This will ask for confirmation for each occurance of replaceme before carrying out the substitution.
V) to highlight the text and delete the selection.uto undo. And if you have undofiles enabled, you can undo even if you save and quit.