Removing a column in vim

I want to remove the first column of a text file using vim. I read these SO answers where visual mode is used, but they only remove the first character (as for answers using patterns, I don't understand them, so I have problems adapting them to my situation).

My file contains many numbers, and I want to remove the numbers in the first column, not just the first element.

eg,

12 34 43143 1
131234 1 
1 3443 132

I would like to have

34 43143 1
1 
3443 132

but currently i'm getting

2 34 43143 1
31234 1 
 3443 132

Numbers are separated by tabs, if that matters

+3
source share
5 answers

Check this: %s/\v^\d*\s//gyou can replace \swith \t, if it is divided into a tab,

\v , , , ( "(" ), ( "{" ) .. , \d , * 0 , \s , % , %s , g , carret (^) . \v g, .

Edit: : %s/^\d*\s//, Jeff

vim help -

:h \v
:h \d

e.t.c,

+3

() [0-9] , \d; , \+ . \t, \s. /:substitute (^) .

:%s/^\d\+\t//

% , . :help :range.

; (, ^\d\+\t\zs\d\+\t ) ( !) .

, , , , (CSV). (csv.vim - Filetype csv, :DeleteColumn - , ! ( ...)

+4

Another alternative is to use a macro:

qq0dawjq

Then you need to use a macro: @q or 3 @q or any number + @q

Explanation:

q: Start Recording a Macro
q: Save the macro in register q
0: Go to the beginning of the line
daw: Delete A Word
j: Move down to the next line
q: Finish the recording
+2
source

This is a quest for cut!

:%!cut -f 2-
+2
source

you need to make type

:%s/\d\+\t//
+1
source

All Articles