Sunday, January 29, 2017

Re: Why the substitute in the selection only substitute the first letter in the selection in my vimscript?

On Friday, January 27, 2017 at 9:17:06 PM UTC+8, Christian Brabandt wrote:
> Hi Zhe!
>
> On Fr, 27 Jan 2017, Zhe Lee wrote:
>
> > Why the substitute in the selection only substitute the first letter in the selection?
> >
> > The \%V option works fine when I just use the command line to exec it.
> >
> > But it seems not work very well when I use it in the vimscript.
> >
> > vnoremap <leader>dfc :call DragonflyCmdProcess(1)<CR>
> >
> > function! DragonflyCmdProcess(visual)
> > if a:visual
> > normal! gv
> > " execute "s/\\%V./&,/g"
> > execute "'<,'>s/\\%Ve/x/g"
> > else
> > endfunction
>
> I am not sure, I understand. Please try with the following changes:
>
> vnoremap <leader>dfc :<c-u>call DragonflyCmdProcess(1)<CR>
> function! DragonflyCmdProcess(visual)
> if a:visual
> '<,'>s/\%Ve/x/g
> endif
> endfunction
>
>
> Best,
> Christian
> --
> Amerikaner werden mißtrauisch, wenn man nicht einer von ihnen werden
> will - im Gegensatz zu Franzosen, Engländern, Schweden und den meisten
> anderen Völkern, die es gerade mißtrauisch macht, wenn man zu ihnen
> gehören möchte.
> -- Billy Wilder

add a more backslash will work thnx`
function! DragonflyCmdProcess(visual)
if a:visual
'<,'>s/\\%Ve/x/g
endif
endfunction

--
--
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.

No comments: