prion 发表于 2005-11-8 22:53:38

请教几个VI的表达式

一直没有好好学 急用 麻烦帮帮忙

第一个   删除所有包含特定搜索结果的行
比如 /\ 1.90\ \ /搜到 空格+1.90+空格+空格的结果后 删除此行

第二个移动整个竖列 比如 3,4,5列是一个东西 第6列是空格
我希望 第3列是空格 原来的东西 排到4,5,6列

第三个搜索到特定的数值 对他们进行运算比如如果 第二列和第三列组成的数>60 则减去 60

谢谢各位了!

prion 发表于 2005-11-9 10:28:00

第一个知道了是 :g/\ 1.90\ \ /d

看置顶的例子里面有列操作这里的列指什么?
我google到的 vi 列操作其实都是行操作...

sunxiaobo 发表于 2005-11-9 20:41:03

2nd question:
At first u must know the Separator( e.g. : ) of the columns.
then u can try:
##############################################
:1,$s/^\([^:]*:\)\([^:]*:\)\([^:]*:\)\([^:]*:\)\([^:]*:\)\( :\)/\1\2\6\3\4\5/
##############################################
I think man can resolve problems about column-manipulation with regex in vim just like sed.

sunxiaobo 发表于 2005-11-9 20:58:23

i think normally people write a script for the third question. But of course u can try to do it with vim.

pakix 发表于 2005-11-11 20:44:43

u shouldn't do all things in vi
u should take a look at the term "Unix and the Tools Philosophy" first
then come back
and man following commands(tools)
grep
cut
paste
and so on
页: [1]
查看完整版本: 请教几个VI的表达式