分页: 1 / 1

VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 13:10
jsjcjsjc
我想做一个纯单词文本,
现在的文本时这样的

代码: 全选

a (an) - ad. one; any; each 
able - v. having the power to do something 
about - ad. almost ("about half"); of or having a relation to ("We talk about the weather.") 
above - ad. at a higher place 
abuse - n. bad treatment causing harm or injury 
accept - v. to agree to receive 
accident - n. something that happens by chance or mistake; an unplanned event 
accuse - v. to say a person is responsible for an act or crime; to make a statement against someone 
across - ad. from side to side; to the other side 
act - v. to do something 
activist - n. one who seeks change through action 
actor - n. someone acting in a play or show 
add - v. to put (something) with another to make it larger; to say more 
administration - n. the executive part of a government, usually headed by a president or prime minister 
admit - v. to accept ("admitted to the United Nations"
但我就想要这样的

代码: 全选

a (an)
able
about
above
abuse
accept
accident
该怎么做着,麻烦大家了
谢谢

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 14:17
onelynx
jsjcjsjc 写了:我想做一个纯单词文本,
现在的文本时这样的

代码: 全选

a (an) - ad. one; any; each 
able - v. having the power to do something 
about - ad. almost ("about half"); of or having a relation to ("We talk about the weather.") 
above - ad. at a higher place 
abuse - n. bad treatment causing harm or injury 
accept - v. to agree to receive 
accident - n. something that happens by chance or mistake; an unplanned event 
accuse - v. to say a person is responsible for an act or crime; to make a statement against someone 
across - ad. from side to side; to the other side 
act - v. to do something 
activist - n. one who seeks change through action 
actor - n. someone acting in a play or show 
add - v. to put (something) with another to make it larger; to say more 
administration - n. the executive part of a government, usually headed by a president or prime minister 
admit - v. to accept ("admitted to the United Nations"
但我就想要这样的

代码: 全选

a (an)
able
about
above
abuse
accept
accident
该怎么做着,麻烦大家了
谢谢
用命令行
:g/-.*$/s

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 14:48
adagio
%g/\ -\ .*/d

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 14:54
jsjcjsjc
fzq5012 写了:
jsjcjsjc 写了:我想做一个纯单词文本,
现在的文本时这样的

代码: 全选

a (an) - ad. one; any; each 
able - v. having the power to do something 
about - ad. almost ("about half"); of or having a relation to ("We talk about the weather.") 
above - ad. at a higher place 
abuse - n. bad treatment causing harm or injury 
accept - v. to agree to receive 
accident - n. something that happens by chance or mistake; an unplanned event 
accuse - v. to say a person is responsible for an act or crime; to make a statement against someone 
across - ad. from side to side; to the other side 
act - v. to do something 
activist - n. one who seeks change through action 
actor - n. someone acting in a play or show 
add - v. to put (something) with another to make it larger; to say more 
administration - n. the executive part of a government, usually headed by a president or prime minister 
admit - v. to accept ("admitted to the United Nations"
但我就想要这样的

代码: 全选

a (an)
able
about
above
abuse
accept
accident
该怎么做着,麻烦大家了
谢谢
用命令行
:g/-.*$/s

谢谢啊 不过我不知道为什么每个单词右面都有一个.mp3~

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 17:17
onelynx
jsjcjsjc 写了:
fzq5012 写了:
jsjcjsjc 写了:我想做一个纯单词文本,
现在的文本时这样的

代码: 全选

a (an) - ad. one; any; each 
able - v. having the power to do something 
about - ad. almost ("about half"); of or having a relation to ("We talk about the weather.") 
above - ad. at a higher place 
abuse - n. bad treatment causing harm or injury 
accept - v. to agree to receive 
accident - n. something that happens by chance or mistake; an unplanned event 
accuse - v. to say a person is responsible for an act or crime; to make a statement against someone 
across - ad. from side to side; to the other side 
act - v. to do something 
activist - n. one who seeks change through action 
actor - n. someone acting in a play or show 
add - v. to put (something) with another to make it larger; to say more 
administration - n. the executive part of a government, usually headed by a president or prime minister 
admit - v. to accept ("admitted to the United Nations"
但我就想要这样的

代码: 全选

a (an)
able
about
above
abuse
accept
accident
该怎么做着,麻烦大家了
谢谢
用命令行
:g/-.*$/s

谢谢啊 不过我不知道为什么每个单词右面都有一个.mp3~
那里,都没看到

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 17:28
jsjcjsjc
fzq5012 写了:
jsjcjsjc 写了:
fzq5012 写了:
jsjcjsjc 写了:我想做一个纯单词文本,
现在的文本时这样的

代码: 全选

a (an) - ad. one; any; each 
able - v. having the power to do something 
about - ad. almost ("about half"); of or having a relation to ("We talk about the weather.") 
above - ad. at a higher place 
abuse - n. bad treatment causing harm or injury 
accept - v. to agree to receive 
accident - n. something that happens by chance or mistake; an unplanned event 
accuse - v. to say a person is responsible for an act or crime; to make a statement against someone 
across - ad. from side to side; to the other side 
act - v. to do something 
activist - n. one who seeks change through action 
actor - n. someone acting in a play or show 
add - v. to put (something) with another to make it larger; to say more 
administration - n. the executive part of a government, usually headed by a president or prime minister 
admit - v. to accept ("admitted to the United Nations"
但我就想要这样的

代码: 全选

a (an)
able
about
above
abuse
accept
accident
该怎么做着,麻烦大家了
谢谢
用命令行
:g/-.*$/s

谢谢啊 不过我不知道为什么每个单词右面都有一个.mp3~
那里,都没看到
我也不了解啊,难道和缓存有关系我刚才在一个文本中再每行最后添加了一个.mp3

但问题是,我重启一下机器后,命令就不行了,显示不匹配,我把文本传上来 帮忙看一下

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 21:36
jsjcjsjc
不是很好啊 凑合一下吧
%s/^\(\w\+\).*$/\1/g

www.google.com

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-01-31 21:50
onelynx
jsjcjsjc 写了:
fzq5012 写了:
jsjcjsjc 写了:
fzq5012 写了:
jsjcjsjc 写了:我想做一个纯单词文本,
现在的文本时这样的

代码: 全选

a (an) - ad. one; any; each 
able - v. having the power to do something 
about - ad. almost ("about half"); of or having a relation to ("We talk about the weather.") 
above - ad. at a higher place 
abuse - n. bad treatment causing harm or injury 
accept - v. to agree to receive 
accident - n. something that happens by chance or mistake; an unplanned event 
accuse - v. to say a person is responsible for an act or crime; to make a statement against someone 
across - ad. from side to side; to the other side 
act - v. to do something 
activist - n. one who seeks change through action 
actor - n. someone acting in a play or show 
add - v. to put (something) with another to make it larger; to say more 
administration - n. the executive part of a government, usually headed by a president or prime minister 
admit - v. to accept ("admitted to the United Nations"
但我就想要这样的

代码: 全选

a (an)
able
about
above
abuse
accept
accident
该怎么做着,麻烦大家了
谢谢
用命令行
:g/-.*$/s

谢谢啊 不过我不知道为什么每个单词右面都有一个.mp3~
那里,都没看到
我也不了解啊,难道和缓存有关系我刚才在一个文本中再每行最后添加了一个.mp3

但问题是,我重启一下机器后,命令就不行了,显示不匹配,我把文本传上来 帮忙看一下

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-02-01 22:46
jsjcjsjc
fzq5012 写了:
jsjcjsjc 写了:
fzq5012 写了:
jsjcjsjc 写了:
fzq5012 写了:
jsjcjsjc 写了:我想做一个纯单词文本,
现在的文本时这样的

代码: 全选

a (an) - ad. one; any; each 
able - v. having the power to do something 
about - ad. almost ("about half"); of or having a relation to ("We talk about the weather.") 
above - ad. at a higher place 
abuse - n. bad treatment causing harm or injury 
accept - v. to agree to receive 
accident - n. something that happens by chance or mistake; an unplanned event 
accuse - v. to say a person is responsible for an act or crime; to make a statement against someone 
across - ad. from side to side; to the other side 
act - v. to do something 
activist - n. one who seeks change through action 
actor - n. someone acting in a play or show 
add - v. to put (something) with another to make it larger; to say more 
administration - n. the executive part of a government, usually headed by a president or prime minister 
admit - v. to accept ("admitted to the United Nations"
但我就想要这样的

代码: 全选

a (an)
able
about
above
abuse
accept
accident
该怎么做着,麻烦大家了
谢谢
用命令行
:g/-.*$/s

谢谢啊 不过我不知道为什么每个单词右面都有一个.mp3~
那里,都没看到
我也不了解啊,难道和缓存有关系我刚才在一个文本中再每行最后添加了一个.mp3

但问题是,我重启一下机器后,命令就不行了,显示不匹配,我把文本传上来 帮忙看一下
谢谢了不过貌似好有很多不理解啊 为什么会带上一个MP3 搞不懂啊

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-02-02 9:34
Strange
jsjcjsjc 写了: 谢谢了不过貌似好有很多不理解啊 为什么会带上一个MP3 搞不懂啊

代码: 全选

:g/-.*$/s
因为这里实际上是用g调用了没有参数的s命令,没参数的s默认替换的是上次替换的东西。如果上次没有替换过,那么就什么都没有。可见lz用vim替换过mp3 :em09

这个问题的话,直接用s就可以了。

代码: 全选

:s/-.*$//

Re: VIM怎么批量进行这样这样有规律的删除,进来看一下吧,一时说不清楚啊

发表于 : 2010-02-02 21:16
jsjcjsjc
Strange 写了:
jsjcjsjc 写了: 谢谢了不过貌似好有很多不理解啊 为什么会带上一个MP3 搞不懂啊

代码: 全选

:g/-.*$/s
因为这里实际上是用g调用了没有参数的s命令,没参数的s默认替换的是上次替换的东西。如果上次没有替换过,那么就什么都没有。可见lz用vim替换过mp3 :em09

这个问题的话,直接用s就可以了。

代码: 全选

:s/-.*$//

谢谢