Chris Sutcliffe wrote:
> >> Is it possible to pass a non-line based range to a function (i.e.
> >> using visual mode to select a piece of text in one line)?
> > Yes, you can find a nice example at :help g@
> I'm not sure how I would use the g@ command to pass the selected block
> to a command line though?
> The example provides for yanking to the '@' registry, but I actually
> want to 'w !putclip' in command mode. I should also point out that
> I'm only concern about handling Visual mode.
How about a visual mapping like this:
:vmap K "zy:let _dummy=system("putclip", @z)<CR>
I'ts a bit crude, remaps K (my temporary map combo) and uses register @z
you might use already.
A more complete version could be eg (join on one line):
:vmap <Leader>pc <C-C>:let _pc_z=getreg('z')<Bar>let
_pc_zm=getregtype('z')<CR>gv"zy:let _pcres=system("putclip",
@z)<Bar>call setreg('z', _pc_z, _pc_zm)<CR>
You might prefer making it into a function, but that requires a bit of
fiddling, too.
Preben
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---