Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete All Characters After "." In Each Line

Tags:

vim

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

like image 712
Lucas Avatar asked Jun 08 '14 22:06

Lucas


People also ask

How do I remove all characters from a string after a specific character?

Use the String. slice() method to remove everything after a specific character, e.g. const removed = str. slice(0, str. indexOf('[')); .

How can I remove all text after a character in bash?

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.

How do you delete everything after a character in Python?

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.


2 Answers

With substitutions:

:%s/\..*/./ 

With :normal command:

:%norm f.lD 
like image 87
Qeole Avatar answered Oct 01 '22 00:10

Qeole


Various additional :normal solutions:

:%norm )Dx :%norm $T.D :%norm f.C. :%norm 0/\. /e<C-v><CR>D 

:normal

like image 30
romainl Avatar answered Oct 01 '22 00:10

romainl