I was on line 93 and realized I wanted to delete line 89. I typed :d89
in hopes that line 89 wold be deleted. It didn't work.
Does anyone know a good way to accomplish this type of interaction? I am a comfortable Vim user but have not (yet) taken the leap to writing plugins...
Thanks.
Press the Esc key to go to normal mode. Place the cursor on the first line you want to delete. Type 5dd and hit Enter to delete the next five lines.
To delete a line, we'll use the sed “d” command. Note that you have to declare which line to delete.
Press 'v' to enter a select mode, and use arrow keys to move that around. To delete, press x. To select lines at a time, press shift+v. To select blocks, try ctrl+v.
Make the vi/vim text editor show or hide line numbers Press ESC key. At the : prompt type the following command to run on line numbers: set number. To turn off line numbering, type the following command at the : prompt set nonumber.
The address of a colon-command (eg: the line number) comes first.
:89d
Note that this will also cause you to navigate to the location of the change. You can use ``
to jump back.
If you'd prefer to have this be a single command you can define a custom command. eg:
command! -range -nargs=0 Delete <line1>,<line2>d|norm ``
This defines a command called Delete
that deletes the addressed range (<line1>,<line2>d
) and then navigates back (norm ``
).
You can call it like:
:89Delete
You can actually invoke it with any unique prefix, so you may be able to get it down to:
:89D
:89d
will delete the 89th line.
:89,91d
will delete the 89th 90th and 91st line.
These functions also work in the Vrapper plugin for Eclipse, and the Vim Extension for Visual Studio Code.
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