On Monday, August 20, 2012 6:23:53 PM UTC-4, Simon Ruderich wrote:
> 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

Thanks for the help, I still have some issues. 
I cannot make the first mapping work properly when called from the function, so 
I cannot make the hole thing work.

Right now just for the first mapping the function looks like:

function! SelectImapOrUlti()
  let save_cursor = getpos(".")
  execute "normal \<Plug>IMAP_JumpForward"
  return ''
endfunction

imap <c-l> <c-r>=SelectImapOrUlti()<cr>
imap <silent> <NL> <Plug>IMAP_JumpForward

So when writing latex if I have a word in the text like this <+text+> and I hit 
<c-j> the text shows up as selected and I can backspace and delete it; however 
if I use the the mapping with the function the cursor is placed on the last +> 
marker, but the word is not selected.

Any idea how to make this?

Thanks!


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

Reply via email to