3

I am facing a problem for using shortcuts provided by vim-latex. Say, I want \textbf, so I was trying `bf.

But, given, `b is a shortcut for \beta, I always end up with something \betaf.

FBF works, how can I use `bf? any help?

2

The vim-latex plugin uses its own implementation of the :imap command, which here is responsible for detecting patterns that should be replaced.

According to the documentation, the timeout functionality of :imap, which would have allowed it to wait some time before checking for known patterns and allowing your usage of `bf was removed in vim-latex‘ own IMAP() function to allow for slower typing while still recognizing patterns.

IMAP() does not have the ability to wait until you probably finished typing and instead tries to match what it sees right now.

Currently, I have no idea as to how one would either add that functionality to IMAP() or use its mappings with :imap.

So, simply put, this happens because `b gets already replaced before you type f.


Or as the section 3.12 Making your own Macros via IMAP() of the vim-latex documentation puts it:

If you have two mappings which end in a common lhs, then the mapping with the longer lhs is used. For example, if you do

call IMAP('BarFoo', 'something', 'tex')

call IMAP('Foo', 'something else', 'tex')

Then typing BarFoo inserts "something", whereas Foo by itself inserts "something else".

Also, the nature of IMAP() makes creating certain combination of mappings impossible. For example if you have

call IMAP('foo', 'something', 'tex')

call IMAP('foobar', 'something else', 'tex')

Then you will never be able to trigger "foobar" because typing "foo" will immediately insert "something". This is the "cost" which you incur over the normal :imap command for the convenience of no 'timeout' problems, the ability to correct lhs etc.


Using IMAP() you could try looking into ~/.vim/ftplugin/latex-suite/main.vim and adjust the mappings to your convenience with the above explained restrictions. For example make the following changes: line 93 bbg and add a definition for bf. I am not entirely sure, that bg is unused by default. And the above would break the consistency of the greek-letter-mappings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.