[Vim-latex-devel] Re: Alt mappings
Brought to you by:
srinathava,
tmaas
From: Luc H. <her...@fr...> - 2003-01-08 01:21:48
|
* On Tue, Jan 07, 2003 at 11:36:20PM +0100, Mikolaj Machowski <mi...@wp...> wrote: > On Tue, Jan 07, 2003 at 12:02:31PM +0100, Luc Hermitte wrote: > > the {key}/{sequence_of_keys}. For instance, I like ']em' to insert > > '\emph{}', but what do you prefer ? 'FEM', ']FEM', ']EM' ? > > I like FEM because: > ]FEM it too long > ]EM can lead to inconsistence. I didn't wanted to propose new mappings. My point is that we all have different preferences. Having an option to define the leading key is really easy, contrary to the following keys. For instance, we could write a function like: function s:DefMappings() call IMAP( b:TeXleader.'EM', '\emph{', '}') call IMAP( b:TeXleader.'BF', '\textbf{', '}') ... endfunction Everyone have good reason to prefer one keybinding to another. For instance, - i'd rather the mapleader does not belong to '\c[a-z]'. I may have to use an accronym like FEM someday. - FEM implies I hold the <shift> key - I quite never use ']' ; because I use a bracketing system and because I rarely write intervals. However ']' requires me to press <AltGr>. - the backquote (`) is a dead key on my keyboard - I often write tables (&) - '#', 'µ', '£', or '€' may be nice for me, but most of them are funky characters you may not have on your keyboard. Anyway, the leading character is not a problem at all with a function like s:DefMappings() -- BTW, I recall my advice to use commands that defines mappings and menus in one call: that eases the maintenance of the list of mappings supported. > [...] > what about EIT (\begin{itemize})? ']ul' in my environment ;-) I have exactly the same mappings for common LaTeX and HTML constructs. Benji added: > This is what <Plug> is for. We already use this in imaps.vim. > Just search for "<Plug>" to see the examples. Indeed. But I don't find the '<Plug>' thing as handy with ftplugins having hundred of mappings as it is with plugins. Moreover: - it does not solve the problem that the menus can't be synchronized with mappings that the end-user tuned with the '<Plug>mappings'. - many mappings are based on IMAP() that calls :imap itself instead of returning a string. So, I agree with Srinath's opinion: S> Well, latex-suite provides <plug>s for things like IMAP_Jumpfunc(), S> not for things like EFI in insert mode which generates the figure S> micro template... Doing it the <plug> way for those will be, I think S> needlessly complex. ---- context dependant mappings ---- > > BTW, it would be nice if we could define mappings aware of the TeX > > mode. For instace, an same mapping would insert '\textbf{}' or > > '\mathbf{}' according to the current TeX mode. > > This is possible with checking of current syntax. Benji did it for > inserting cdots, and I used it in 'polski' file. > > if synIDattr(synID(line('.'),col('.')-1,0),"name") =~ '^texMath\|^texZone' As I remember, the test is more tricky than that. But yes it is the idea. Except that ... IMAP() is not handy to define such things. The easiest approach should be: imap what-ever-bf <c-r>=BF()<cr> With BF() returning '\textbf{<+cursor-pos+>}<++>' or '\mathbf{<+cursor-pos+>}<++>'. Today, the trick imposing the less changes will be a BF() function returning the correct (according to user's preferences) FBF or MBF string. -- Luc Hermitte http://hermitte.free.fr/vim/ |