Wiki: Tutorial Extentions


Note: You are viewing an old revision of this page. View the current version.


<Lars_G> stupid question, I am trying to eliminate blank lines on a file.... tried :%s/^$// and it marks all blank lines but they are not eliminated
<Lars_G> any ideas please?
<p0g> :g/^$/d
<Lars_G> thanks... what is g? never used it before.
<p0g> global
--> zeedo (~zeedo@www.bsrf.org.uk) has joined #vim
<-- strull_at_w has quit ("leaving")
<Lars_G> I see, it matches lines based on the regexp and applies command d to them
<Lars_G> interesting...
<MetaCosm> uws: also, changing the tw doesn't excuse the depth :)
<MetaCosm> it just makes it seem less fugly
<Lars_G> thanks, pretty powerfull, a new day, a new command in vim learnt
<p0g> yes, it's where g/re/p comes from :)
<Lars_G> p0g, can regexps be conbined with ranges that way too?
<pre>
 lampus Lars_G

<Lars_G> something like :5,12/^$/d for example? <p0g> that would be :5,12g/^$/d <Lars_G> thanks <Lars_G> vim rules <Lars_G> it's so powerfull it's scary <MetaCosm> Lars_G: yep <Lars_G> so lets say, ident all non-empty lines from 5 to 12 would be :5,12g/^.+$/< <Lars_G> ident left <Lars_G> de-ident actually <MetaCosm> Lars_G: one thing to be aware of <Lars_G> yes? <MetaCosm> after the final / <MetaCosm> that is Ex commands <MetaCosm> not "normal" commands <MetaCosm> but you can fix that by doing <Lars_G> Not Vi, only Ex? thanks <MetaCosm> :g/this/normal < <MetaCosm> that will be normal commands for sure <MetaCosm> just as you are used to them <Lars_G> normal changes to Vi(m) mode then.... <Lars_G> thanks <-- Esaj has quit ("Client exiting") <p0g> < is an ex command too <Lars_G> Yes I know what Ex is ;) <MetaCosm> p0g: well, my example was more for general <MetaCosm> not the specific command he was using <Lars_G> yes I understood, thanks for the remark. <p0g> Lars_G: and :v means "does not match", so you could use :5,12v/^$/< <p0g> but shifting empty lines doesn't work anyway <Lars_G> p0g: they're the left sided version of RegExps normal flags then, g, v, does caseless matching apply too? (s i think it was? no... U???) <Lars_G> p0g, Yes it was a bad example :) <p0g> huh, left sided version of regexps normal flags? <p0g> what's that supposed to mean <Lars_G> g is regexp's flag for global <Lars_G> :s/soemthing/else/g <---- <tazz> p0g, hmm.. is that about grep true? :) <p0g> oh, no it's not like that <Lars_G> ok <Lars_G> thanks <p0g> tazz: yes, but it's from ed, not vim <tazz> Cool.. but why 're'? <tazz> Could be anything <p0g> regular expression <tazz> I see <Lars_G> Yes I try not to say "grep" not to mention an implementation of regular expressions but the concept of regular expressions themselves... <Lars_G> :) that's why I walways say RegExps instead of Grep or regs and eregs <Lars_G> :) <Lars_G> Or Perl, the world famous bloated RegExp? engine ;) (Joke, I respect perl a lot.) </pre>

http://www.okuno.com.cn/ http://www.carcenter.com.cn/ http://www.xiangde.com.cn/ http://www.j-net.com.cn/ http://www.chinabm.net.cn/ http://www.lead-int.com/ http://www.paiwei.cn/ http://www.sunflow.com.cn/ http://www.txhf8.com/ http://www.lyzhuguang.com/ http://www.emicn.com/

http://www.carcenter.com.cn/add/ http://www.chinabm.net.cn/add/ http://www.lead-int.com/add/ http://www.amwaypower.com/amwaypower/ http://www.amwaypower.com/amway_china/ http://www.amwaypower.com/amway_gongsi/ http://www.amwaypower.com/amway_chanpin/ http://www.amwaypower.com/amway_niucuilai/ http://www.amwaypower.com/amway_usa/ http://www.amwaypower.com/amway_zhixiao/ http://www.paiwei.cn/add/ http://www.playseo.com/bjlvyou/ http://www.playseo.com/zuche021/ http://www.playseo.com/zuche8/ http://www.playseo.com/zuche/ http://www.saishuo.com/tiezhixiangji/ http://www.sunflow.com.cn/sunflow/ http://www.txhf8.com/add/

http://qichezulin.51.net/ http://guanlipeixun.51.net/ http://diandu123.51.net/ http://usauniversity.51.net/ http://pagerank.51.net/ http://amwaypower.51.net/ http://amwaypower.51.net/amway_china/ http://amwaypower.51.net/amway_gongsi/ http://amwaypower.51.net/amway_chanpin/ http://amwaypower.51.net/ay_niucuilai/ http://amwaypower.51.net/amway_usa/ http://amwaypower.51.net/amway_zhixiao/ http://fadianjizu.51.net/ http://bjlvyou.51.net/ http://zuche021.51.net/ http://zuche8.51.net/ http://tiezhixiangji.51.net/ http://sunflow.51.net/ http://zhibanji.51.net/ http://siweiyuan15.51.net/ http://siweiyuan14.51.net/ http://siweiyuan13.51.net/ http://siweiyuan12.51.net/ http://siweiyuan11.51.net/ http://siweiyuan10.51.net/ http://siweiyuan09.51.net/ http://siweiyuan08.51.net/ http://siweiyuan07.51.net/ http://siweiyuan06.51.net/ http://siweiyuan05.51.net/ http://siweiyuan04.51.net/ http://siweiyuan03.51.net/ http://siweiyuan02.51.net/ http://siweiyuan01.51.net/ http://siweiyuan.51.net/

http://www.playseo.com/somewebpage.htm http://www.souwho.com/somewebpage.htm http://pagerank.51.net/somewebpage.htm http://www.amwaypower.com/keywords/free1.htm http://www.boshilw.com/keywords/free1.htm http://www.dfhb.com/keywords/free1.htm http://www.dxslw.com/keywords/free1.htm http://www.emicn.com/keywords/free1.htm http://www.gfqy.com/keywords/free1.htm http://www.google123.net/keywords/free1.htm http://www.google123.org/keywords/free1.htm http://www.lnhbsb.com/keywords/free1.htm http://www.ly-yufeng.com/keywords/free1.htm http://www.lyzhuguang.com/keywords/free1.htm http://www.lxep.com/keywords/free1.htm http://www.newstyle-w.com/keywords/free1.htm http://www.paiwei.cn/keywords/free1.htm http://www.playseo.com/keywords/free1.htm http://www.saishuo.com/keywords/free1.htm http://www.sh-xinping.com/keywords/free1.htm http://www.shhcy.com/keywords/free1.htm http://www.songshangroup.com/free1.htm http://www.souwho.com/keywords/free1.htm http://www.sunflow.com.cn/keywords/free1.htm http://www.suntront.com.cn/keywords/free1.htm http://www.think-t.com/keywords/free1.htm http://www.txhf8.com/keywords/free1.htm http://www.vita-biotech.com/keywords/free1.htm http://www.writerlw.com/keywords/free1.htm http://www.xinpushihua.com/keywords/free1.htm http://www.xtzn.com/keywords/free1.htm http://www.ycc-zipper.com.cn/keywords/free1.htm http://pagerank.51.net/free1.htm


Sponsored by: Labrat Technology -- Need Consulting Services? Programming, Maintenance, Security, Database Analysis & Design, Hosting -- we do it all!
Copyright 2005 Robert Melton
Send questions and comments to
Last updated March 10th, 2005