开发者

How to empty out a column

I'm searching to empty out multiple columns in VIM

(not to delete but to put spaces inside).

This is my search command:

/\%2c\|\%4c\|\%>5c\%<9c

(column: 2,4,6-8)

How can I empty o开发者_如何学JAVAut these columns in vim?

:%s/\%2c\|\%4c\|\%>5c\%<9c/ /g doesn't work


/\%c is a zero-width match.

You'll need to match something like:

/\v^(.).(.).(.)...

Which will keep the values of columns 1, 3, and 5 in groups.

Then you can substitute:

:%s!\v^(.).(.).(.)...!\1 \2 \3   !

...keeping columns 1, 3, and 5 but replacing the rest of the first eight columns with spaces.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜