Thursday, January 28, 2010

Re: How to go to command line mode from script

On Jan 28, 11:47 am, Aarto Matti <aarto.ma...@gmail.com> wrote:
> Hello,
>
> How can I open a command line prompt from script, print a command there and
> leave it open so I can continue typing it and then press Enter myself.
> Sounds simple, but I've been searching for a solution for long, yet haven't
> lost my hope. That's a ruff example of what it would look like:
>
> function! foo()
>     " start command line mode, print there ':echo "hello"' and that's it
> endfunction
> map <F12> :call foo()<CR>
>
> So when I press F12 it opens a command line with:
> :echo "hello"<cursor here>
> and I still can continue typing, I don't want it to be executed immediately.
>
> :) I could use this:
> map <F12> :echo "hello"
> but my real function has to do some stuff before it gets a ready command to
> print out, that makes it very hard or even impossible to retype the whole
> thing to single mapping.
>

Try using an expression mapping to call your function, which should
just return the incomplete command line with the leading : but without
the trailing <CR>.

:help map-<expr>

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: