Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .