开发者

Trying to remove the first column of a document.

开发者 https://www.devze.com 2023-02-08 06:56 出处:网络
I\'m using this command below to remove the first column of a document: %s/^[^\\t]*\\zs\\t[^\\t]*\\ze//g

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

%s/^[^\t]*\zs\t[^\t]*\ze//g 
开发者_StackOverflow

but it says command not found. Any idea?


Here's the quickest way to remove the first column:

  1. Press gg to go to the first character in the document.
  2. Hit Ctrl+V to enter visual block mode.
  3. Hit G (that is, shift-g) to go to the end of the document
  4. Hit x to delete the first column.


I like the block selection solution of @Peter, but if you want to use substitution you need this command:

:%s/^.//

Let's analyze why this works:

  • :%s exec a substitution on all the document
  • /^./ select the first character after the start of the line
  • / and replace it with... nothing.


If I understand you correctly, this should do the job:

:%s/^[^\t]//

The command removes all leading characters that are not a tabulator.

Alternatively, if you're editing a tabulator separated values document and want to remove all "columns" before the first tabulator, then this should do it for you:

%s/^[^\t]*\t//


The below command worked for me:

:%s/^\w*// 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号