Is there a VIM command / key combination that would do something like dt/mystring
(which doesn't work)?
dta
tries to find letter a
on current line, but I'd like to delete everything up to searched string (possibly on some other line).
In order to delete lines matching a pattern in a file using vim editor, you can use ex command, g in combination with d command. To remove lines that contains the string amos , in vim command mode, type the command below and press Enter. This will delete all lines containing the specified keywords.
Basic Find and Replace In Vim, you can find and replace text using the :substitute ( :s ) command. To run commands in Vim, you must be in normal mode, the default mode when starting the editor. To go back to normal mode from any other mode, just press the 'Esc' key.
To delete one character, position the cursor over the character to be deleted and type x . The x command also deletes the space the character occupied—when a letter is removed from the middle of a word, the remaining letters will close up, leaving no gap. You can also delete blank spaces in a line with the x command.
Try this
d/mystring
It won't delete the string itself.
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