Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim - delete everything between tab characters

Tags:

vim

I have a file that has tab separated data. I need to delete 2 columns. So, what command(s) can I use to delete everything from the current tab to the next tab?

like image 201
David Oneill Avatar asked Aug 05 '26 23:08

David Oneill


2 Answers

To delete columns 4 and 5:

:%s/^\(.\{-}\t\)\{3}\zs.\{-}\t.\{-}\t//

Explanation:

^  => start of line

.\{−} => as few characters as possible
\( .\{-}\t \)\{3} => three times as few characters as possible followed with a tab

\zs => start of match

It could be clearer with the \v switch:

:%s/\v^(.{-}\t){3}\zs.{-}\t.{-}\t//
like image 122
Benoit Avatar answered Aug 08 '26 11:08

Benoit


I think shift+ctrl+v is what you are looking for.

http://jvi.sourceforge.net/javahelpset/jvi-vis_block.html


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!