I have a line of strings (10 to 20):
title = models.CharField(max_length=250)
...
field20 = models.DateField()
How can I use Vim's find and replace to remove everything from the equal sign until the end of line, so the text turns into:
title
...
field20
I'm familiar with the visual select find and replace (:s/\%Vfoo/bar/g), so I'd like to do something like (:s/\%V< = until $>//g), but this is what I am unsure how to find in Vim:
= until $
I looked at the vimregex wiki, and tried the following with no success:
:s/\%V = (.*?)$//g
Are you looking for this:
:%s/=.*/
?
It's the same as
:%s/=.*//
but the ending / can be omitted. You don't need the g
btw because the pattern to the end of the line can match just once.
If you also want to remove the whitespace before the =
use:
:%s/[[:blank:]]*=.*/
Note: If you think [[:blank:]]
is hard to type, you can use \s
instead. Both stand for space or tab.
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