I would like to remove everything after a text highlight in a line for
all the lines in a file.

What are the commands to be used in Vim. I would appreciate your help.

000000,0000000,000000
000000,0000000,000000

I want to remove everything after "," for all the lines.

You have two commas...if you want to delete everything after the first comma, you can use

        :%s/,.*/,

If you want to delete everything after the first comma *including* the comma, you can use

        :%s/,.*

If you want to delete everything after the 2nd comma, you can use

        :%s/,[^,]*,\zs.*/

And if you want to delete everything after the 2nd comma (but including the comma, you can just use

        :%s/,[^,]*\zs,.*/

Or, if all your columns align, you can use visual-block mode with control+V to create a block across the characters in question, and then just hit "d" to delete.

I'm sure there are plenty of other ways to do it, but that should get you started.

-tim



Reply via email to