分页: 1 / 1

怎样提取 感兴趣的行,并写入 另一个文件中?

发表于 : 2009-08-26 15:28
arjon
如题!
请问:
vim 打开的buffer中有很多行, 我想把 其中的 含有 pattern 字符串的行 提取到 另一个文件 file中,
我用
:g/pattern/write file
发现不行。


请指点一二!Thks1

Re: 怎样提取 感兴趣的行,并写入 另一个文件中?

发表于 : 2009-08-26 15:33
懒蜗牛Gentoo
非要用vim么?

cat filename |grep pattern >> file2

Re: 怎样提取 感兴趣的行,并写入 另一个文件中?

发表于 : 2009-08-26 15:39
eexpress
学正则吧。

Re: 怎样提取 感兴趣的行,并写入 另一个文件中?

发表于 : 2009-09-03 2:03
GiL
You can also "write" a specific portion of a file to a new filename. By prefixing the :up
command with a line range only the specified lines are written to the named file. For example,
:20,30up 20-30.txt saves lines twenty to thirty of the current buffer to a file named
20-30.txt. Alternatively, select a portion of a file visually then execute :up filename
and the text you selected will be written to a file named filename.
这个?