Vim - Delete from character to end of line
Problems
This below text is searching result in Vim with ag
command. Sometime, I want to delete from char | to end of line. So that, I can delete duplicated lines to find out where searching patterns are.
app/views/mailers/1.html.slim|1 col 14| | Sample text 1
app/views/mailers/2.html.slim|4 col 14| | Sample text 2
app/views/mailers/3.html.slim|10 col 14| | Sample text 3
app/views/mailers/4.html.slim|12 col 14| | Sample text 4
app/views/mailers/5.text.slim|1 col 88| | Sample text 5
Solution
A global command would be a good fit
:g/|/norm nD
Explain:
:g : Start a Global Command (:h :g for extra help on global commands)
/| : Search for |
/norm nD : Execute nD in Normal Mode where
n - jumps to the match
D - delete to the end of the line