Hy ZyX!
On Sunday, February 6, 2011 2:00:54 AM UTC+1, ZyX wrote:
It should be
> :%s/.*{pattern}.*\n//
> or, in this particular case:
> :%s/.*abc\ndef.*\n//
> because we are going to delete the whole lines that contain match, but
> nobody
> said that they contain only match. Both solutions does not work for
> patterns
> with \zs and \ze, maybe it is better to do the following:
>
> function! s:MarkToDel(todelete, sline, submatch)
> let lnum=len(substitute(a:submatch, '\n\@!.', '', 'g'))
> call add(a:todelete, [a:sline, lnum])
> return a:submatch
> endfunction
> function! DeleteMatchingLines(pattern)
> let todelete=[]
> let savedgdefault=&gdefault
> set nogdefault
> try
> execute '%s/'.escape(a:pattern, '/').
> \'/\=s:MarkToDel(todelete, line("."), submatch(0))'
> finally
> let &gdefault=savedgdefault
> endtry
> let deleted=0
> for [sline, lnum] in todelete
> let sline-=deleted
> let deleted+=lnum+1
> let range=sline.','.(sline+lnum)
> execute range.'delete _'
> endfor
> endfunction
>
How should I use your function? I've copied it to my .vimrc but don't know
what to do next :-)
Thank you again for your time (and Tim's too!)
--
Eduard.
http://www.google.com/profiles/edfabra
>
--
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