Wednesday, August 22, 2012

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

On Mon, Aug 20, 2012 at 08:58:24PM -0700, skeept wrote:
> 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.

The following mapping works:

imap <C-L> <C-O>:call SelectImapOrUlti()<CR>

I'm not 100% sure why <C-R>=SelectImapOrUlti()<CR> doesn't work,
but I guess because it's only meant to insert text.

Btw. the LaTeX-Suite might not be the best solution. Here's what
the bot vimgor (from Freenode/#vim) has to say about it:

<vimgor> A slightly-maintained, buggy, over-complicated plugin
intended to make it easier to author (La)Tex files.
Often, this is better served by using a standalone
snippets plugin (like snipMate) to define the
snippets you actually find useful as well as using
the command ':compiler tex' to allow using Vim's
quickfix feature when compiling TeX to an output
format.

Personally I use XPTemplate instead of snipMate and it works very
well for me.

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

No comments: