On Thursday, January 23, 2014 11:51:16 PM UTC+9, Chan Kim wrote: > I’m a long-time vi(m) user and I have question.Can I remove lines that > contain a pattern but not another pattern?For example, Line 1 : rabbitLine 2 > : arch sparcLine 3 : arch armLine 4 : tigerI want to remove lines containing > arch but not containing sparc.So Here I want to remove only line 3 leaving > lines 1, 3 and 4 intact. I can remove lines containg ‘arch’ by:g/arch/dI can > remove lines not containing ‘sparc’ by:g!/sparc/dHow do I combine those two?I > tried:g/arch/&!/sparc/d or :g/arch&!sparc/dBut of course it doesn’t work. > (with escape before ! also)Is there a way to remove only line 3? I looked it > up in the manual but in vain..Thank you! ------------- Thank you Tim and Ben (I'll read Ben's post later..) But I found maybe the nicest one. The following line does it. :v /sparc/s/.*arch.*\n// I guessed the meaning of :v command concluding that it says 'for every line not containing 'sparc', replace '.*arch.*\n'(line containing arch together with return) with null. in case of no search pattern(..arch..), ignore it. ref : http://stackoverflow.com/questions/11807713/multiple-g-and-v-commands-in-one-statement (Zecc's reponse)
Chan -- -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
