Le vendredi 7 avril 2017 20:31:20 UTC+2, Christian Brabandt a écrit :
> Hi Ni!
> 
> On Fr, 07 Apr 2017, Ni Va wrote:
> 
> > Is it possible to use this kind of command to count items without moving 
> > cursor ?
> > 
> > 'a,'bs/pattern//gn
> 
> like the other question you asked about the :s command, this is not 
> possible without wrapping into a function and saving/restoring the 
> cursor position there.
> 
> 
> Best,
> Christian
> -- 
> Gute Manieren bestehen aus lauter kleinen Opfern.
>               -- Ralph Waldo Emerson

Then I wrote this little code :

function! s:getPatternCount(begL,endL,pattern)
        let netrkC = 0
        if copy(a:begL) < copy(a:endL)
                for lnum in range(copy(a:begL), copy(a:endL))
                        if stridx(copy(getline(lnum)), copy(a:pattern)) == 0
                                let netrkC += 1
                        endif
                endfo
        endif
        return netrkC
endfu
        let networkCount = s:getPatternCount(copy(s:getPreviousLineBlock()), 
v:beval_lnum, 'NETWORK')

-- 
-- 
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/d/optout.

Reply via email to