In most text editors, I can select text by clicking and dragging with my mouse, and then using Ctrl-C to copy that text, or Backspace to delete it.
However, since vim runs in the console, if I highlight some text with the mouse, my vim commands don't affect what I have selected.
What is the equivalent way to select text in vim?
Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy.
5.1. We can select and delete specific texts using the Shift + V keys and then using the dd command. Let's delete the line Welcome to Linux! – Line 4. First, we'll need to open a vi session and press v to be in the VISUAL LINE mode.
You can use * and/or # to search for the word under the cursor or viw to visually select the word under the cursor.
In vim, text is selected by entering Visual mode. This can be done in multiple ways.
:set mouse=a.Once you have selected the text you want, you can use all sorts of commands on them. Some of the more useful ones are:
You can learn more about Visual mode by typing :help v while inside vim.
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