Monday, August 20, 2012

Re: defining imap that calls performs second call if cursor didn't move

On Mon, Aug 20, 2012 at 01:42:04PM -0700, skeept wrote:
> Hi,
>
> Suppose I have two functions Func1 and Func2. I would like to
> know if it is possible to define a imap that first calls Func1
> (imap <f1> <c-r>:call Func1()<CR>)

Shouldn't that be <c-o>?

> if the cursor moves as a result of this call then we are done,
> otherwise it would call Func2 after calling Func1.

Use a third function in the mapping which calls Func1() and
checks the current cursor position before and after and calls
Func2() if it hasn't changed.

:help getpos()
:help line()

But fixing Func1() to use proper return values makes this
simpler.

Regards,
Simon
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

No comments:

Post a Comment