Hi Bram and Vim developers,

:help g@
doc>                                                    *g@* *E774* *E775*
doc> g@{motion}         Call the function set by the 'operatorfunc' option.
(snip)
doc> 
doc> Here is an example that counts the number of spaces with <F4>: >
doc> 
doc>    nmap <silent> <F4> :set opfunc=CountSpaces<CR>g@
doc>    vmap <silent> <F4> :<C-U>call CountSpaces(visualmode(), 1)<CR>
doc> 
doc>    function! CountSpaces(type, ...)
doc>      let sel_save = &selection
doc>      let &selection = "inclusive"
doc>      let reg_save = @@
doc> 
doc>      if a:0  " Invoked from Visual mode, use '< and '> marks.
doc>        silent exe "normal! `<" . a:type . "`>y"
doc>      elseif a:type == 'line'
doc>        silent exe "normal! '[V']y"
doc>      elseif a:type == 'block'
doc>        silent exe "normal! `[\<C-V>`]y"
doc>      else
doc>        silent exe "normal! `[v`]y"
doc>      endif
doc> 
doc>      echomsg strlen(substitute(@@, '[^ ]', '', 'g'))
doc> 
doc>      let &selection = sel_save
doc>      let @@ = reg_save
doc>    endfunction

This sample script does not work properly when use visual-block-mode with '$'.

How to reproduce:
(0) Prepare test.txt containing the following.
a a
 b b b b
cc

(1) Copy to ~/.vimrc above sample script.
(2) Open test.txt
(3) Input below command.
    <C-V>G$
(4) Press <F4>

Expected behavior:
- Display '5' on command line.

Actual behavior:
- Display '3'.


I think that we should use 'gv' in this case.
Attached a patch.

PS
Is it necessary condition "elseif a:type == 'block'" ?
Help says unnecessary. (Following excerpt)
doc> Although "block" would rarely appear, since it can
doc> only result from Visual mode where "g@" is not useful.

Thanks.

--
Best regards,
Hirohito Higashi

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff -r 54d96e3b2eec runtime/doc/map.txt
--- a/runtime/doc/map.txt	Thu May 22 21:22:19 2014 +0200
+++ b/runtime/doc/map.txt	Sat May 24 12:31:15 2014 +0900
@@ -828,8 +828,8 @@
 	  let &selection = "inclusive"
 	  let reg_save = @@
 
-	  if a:0  " Invoked from Visual mode, use '< and '> marks.
-	    silent exe "normal! `<" . a:type . "`>y"
+	  if a:0  " Invoked from Visual mode, use gv command.
+	    silent exe "normal! gvy"
 	  elseif a:type == 'line'
 	    silent exe "normal! '[V']y"
 	  elseif a:type == 'block'

Raspunde prin e-mail lui