Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using this command below to remove the first column of a document:

%s/^[^\t]*\zs\t[^\t]*\ze//g 

but it says command not found.

Any idea?

share|improve this question
1  
I think there should be a : at the start of the command. –  Mikel Feb 4 '11 at 10:36
2  
Please clarify what you mean by "column". –  Andrea Spadaccini Feb 4 '11 at 10:45
    
Please don't cross-post. –  Dennis Williamson Feb 4 '11 at 11:02
add comment

4 Answers

You need to write it in command mode, not normal. In other words, press : first.

:%s/^[^\t]*\zs\t[^\t]*\ze//g 

Edit: To remove the first column:

:%s/^\S*\s\+//

where \s is "whitespace" and \S is its inverse.

share|improve this answer
    
thanks, but now it says the "expression was not found"...Any idea? –  user35538 Feb 4 '11 at 9:34
    
@user35538, do you mean, "pattern not found", right? Where did you found this expression? I don't have much experience with regular expression. You should check it. –  Johnny Feb 4 '11 at 9:44
    
@user35538 how are column separated? if by space this should be enough: :%s/^[^ ]* //g –  Mr Shunz Feb 4 '11 at 9:58
add comment

I don't get an error from your command, but it removes the second column. This command will remove the first column:

:%s/^[^\t]*\t\ze[^\t]*//g
share|improve this answer
add comment

You could also use Visual-Block mode.

On the first line of the file, in the first column, hit Control+v to get in Visual Block mode, followed by Shift+g (moves to the last line of the file) then use l to move over to the right as far as you want. You should see a visual selection of each column as you move to the right in the file. xwill then delete those columns.

See also: :he block

share|improve this answer
add comment

As I already answered on StackOverflow, you might use the following command:

:%s/^.//
share|improve this answer
1  
That will only remove the first character. I think the OP wants to remove everything up to the first tab. –  Mikel Feb 4 '11 at 10:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.