I have a text file with about 2,000 lines of text and I want to remove a large portion of each line of text.
The text is in this format:
Important Text that I care about. Stuff I want to delete
I am pretty new to vim and have been reading some manuals on vim commands but I am still unsure as to how to delete all of the text after the "." in each line.
Can someone give me a quick command that would do this?
Thanks
Use the String. slice() method to remove everything after a specific character, e.g. const removed = str. slice(0, str. indexOf('[')); .
In Bash (and ksh, zsh, dash, etc.), you can use parameter expansion with % which will remove characters from the end of the string or # which will remove characters from the beginning of the string. If you use a single one of those characters, the smallest matching string will be removed.
We used the str. split() method to remove everything after a character ( ! in the examples). The str. split() method splits the string into a list of substrings using a delimiter.
With substitutions:
:%s/\..*/./
With :normal
command:
:%norm f.lD
Various additional :normal
solutions:
:%norm )Dx :%norm $T.D :%norm f.C. :%norm 0/\. /e<C-v><CR>D
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