Tuesday, June 29, 2010

Re: Conditional imap

I did what you told me to (i dont want to use "(<Tab>" but just "(" to remap
to "\left("). When I enter the command while i opended the Document
everything works fine. But when I put the command in my .vimrc (or the
tex.vim respectively) it stops working.

The map is present, it just won't replace the "(".

Any Idea?


Christian Brabandt-3 wrote:
>
> On Mon, June 28, 2010 11:46 am, gitterrost4 wrote:
>> I am using vim mostly for LaTeX-editing. now I would like to imap the
>> sequence "(<Tab>" to "\left(".
>>
>> The Problem being that "\left(" is only valid in Math-Mode.
>>
>> So I would like to first check (by regex) if I am in a Math-environment
>> (e.g count the number of "$"-signs) and if so, imap the above mentioned.
>>
>> Is there any way of doing that?
>
> You can use map-expressions, as explained in :h map-expression
>
> Excuse my LaTeX skills, I haven't used math-mode in a while, but something
> like this should work:
>
> imap <expr> <Tab> synIDattr(synID(line('.'), col('.'), 1), "name")=~
> "texMath" ? "\left(" : "\t"
>
> (one line)
>
> This obviously requires a working Syntax highlighting (e.g. :syntax on)
> and I am not sure, if the name "texMath" matches all different TeX Math
> environments.
>
> regards,
> Christian
>
> --
> 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
>
>

--
View this message in context: http://old.nabble.com/Conditional-imap-tp29008528p29020858.html
Sent from the Vim - General mailing list archive at Nabble.com.

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

No comments:

Post a Comment