On Thursday, July 14, 2016 at 12:00:06 AM UTC-7, jott...@googlemail.com wrote:
> Hi,
> 
> Bee schrieb am 14.07.2016 um 08:28:
> > I tried to pass a count to <F11> but got a range error.
> > 
> > nmap <F11> :call VMA()<bar>:bn<cr>
> > 
> > Can it be done?
> > 
> > nmap <F12> :bn<cr>
> > 
> > 4<F12> works
> 
> in my experience counts and mappings don't work together very well. A
> preceding count is always used for the first command in the mapping only.
> So what happens when you enter
> 
>   4<F11>
> 
> is that Vim converts your count to an address for the command-line,
> which effectively results in
> 
>   :.,.+3call VMA()|:bn
> 
> In your mapping you first have to remove this address and "move" the
> count to the front of the command :bn. The count is stored in the global
> variable v:count. There is an example at :help v:count which can be
> adopted:
> 
>   :nmap <F11> :<C-U>call VMA()<bar>execute v:count1 . "bn"<cr>
> 
> Note that I removed the superfluous second colon and that instead of
> v:count I used v:count1 which defaults to 1 if no count was given.
> 
> Regards,
> Jürgen
> 
> -- 
> Sometimes I think the surest sign that intelligent life exists elsewhere
> in the universe is that none of it has tried to contact us.     (Calvin)
More reading... a count is not needed.
First time I have used bufdo!
function! B_() " field delimiter ';'
  g/^\d*;\+$/d                          " remove blank records
  v/^\d\+;/d                            " remove non-data records
  let @4=expand('%:t:r')                " remove path, extension
  let @4=substitute(@4,'\s\+',' ','g')  " remove extra whitespace, normalize
  let @4=substitute(@4,'^ ','','')      " remove leading whitespace
  let @4=substitute(@4,' $','','')      " remove trailing whitespace
  let @4=substitute(@4,'.*\zs ',';','') " replace ' ' ';' before date
  let @4.=";"                           " append ';' filename;date
  g/^\d\+;/:normal "4P                  " prefix lines filename;date;
endfun " example :bufdo call B_()
function! B() " everyone keep quiet
  silent bufdo call B_()
endfun " example :call B()
Bill
-- 
-- 
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thursday, July 14, 2016
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment