[Vim-latex-devel] Re: Alt mappings
Brought to you by:
srinathava,
tmaas
From: Luc H. <her...@fr...> - 2003-01-07 11:03:34
|
* On Mon, Jan 06, 2003 at 10:55:15PM -0500, Benji Fisher <be...@me...> wrote: > Srinath Avadhanula wrote: > >Hmm... Lets see... What about moving away from "special" keys > >altogether and using ']l' ']b' ']c' etc in insert mode (as Luc > >suggests) This is an idea I've stolen from Sven scripts. Now, I'm used to it and like it. > >and <M-[lbc]> in normal mode (or maybe even ']b' etc in normal mode > >as well)? > >This way people who want to use <M-c> etc for national characters can > >continue to do so... Ofcourse this makes the users of latex-suite > >learn yet another "leader" character... May be, may be not. What about two options: - [bg]:meta_or_mapleader - [bg]:insert_mapleader If the first is true, mappings are defined as '<M-{key}>', otherwise the mappings are defined with '{[bg]:insert_mapleader}{key}'. The configuration step is a little more complex, but still quite simple. What is really hard to propose to the end user is a simple way to change the {key}/{sequence_of_keys}. For instance, I like ']em' to insert '\emph{}', but what do you prefer ? 'FEM', ']FEM', ']EM' ? > >Maybe ']' can be reserved for beginning maps which change the text > >before them in some way... What do you mean by 'before them' ? > [...] > >" Pressing <F5> will prompt you for which environment to insert. > >" Change <F5> to change the ``hotkey''. > >nmap <silent> <F5> <Plug>Tex_FastEnvironmentInsert > > > >etc. The user needs to change the lhs in these lines to customize... > >But texrc or the user's copy of texrc is sourced only once when > >latex-suite initializes, not for every BufEnter event... So that > >might not be a good place... Why don't you put it in a {rtp}/ftplugin/tex/ directory ? Or do something like: #### {rtp}/ftplugin/tex/tex_options-commands.vim #### " excerpt from a similar file from my C++ ftplugins let s:esc_pwd = '' " Function: s:CheckOptions() {{{ " Role: Checks whether we must reload the options file to match the " current project. function! s:CheckOptions() if s:esc_pwd != escape(getcwd(), '\') let s:pwd = getcwd() let s:esc_pwd = escape(s:pwd, '\') let g:do_load_tex_options = 1 if filereadable("./tex_options.vim") so ./tex_options.vim else runtime ftplugin/tex/tex_options.vim endif endif endfunction " }}} call s:CheckOptions() " + definition of a Vim-command if needed. #### But, that supposes: - the mappings in .texrc (I really don't like this name) are buffer mappings, not global mappings And I wonder if we really need to reload the options every time we enter a new buffer. I think the end-user will likely have the same mappings for all his (La)TeX buffers. > Actually, I was suggesting something more radical. Something like > this: > > let Tex_FastEnvironmentInsert = '' " '<F5>' is popular. > " Either default to empty string as above or else comment it out: > " let Tex_FastEnvironmentInsert = '<F5>' > > Then the TexSetOptions() function (called on each FileType tex event, > I think) can test whether g:Tex_FastEnvironmentInsert exists (or is > not the empty string) and use it to define a map if so. This is the > way I did it way back in texmacros.vim (for vim 5.3+). I like this approach: let's take advantage of the ftplugin mecanism. > >Luc, Mikolaj, Fabio any suggestions? The rest of us AFAIK do not use > >the meta key anyway... I use (ie: define to mappings binded to ...) the meta keys only for NORMAL mode now. While they overlap with accentuated character (Vim does not make any difference when I hit 'é' or '<M-i>'). > >I just thought about this? Are things like ']b' etc going to cause > >the same kind of problems diacritics caused? Do strings like ']b' > >occur often in latex? > Closed intervals are pretty common: $[a,b]$. Some authors like to > reverse the brackets for open intervals: $]a,b[$ instead of $(a,b)$. That's true. I completly forgot. As finding non funky keys not used in a way or in other is nearly impossible (except if you like ^X), I think the easiest for us is to have the end-user to define his preferences on this topic -- cf. the 2 options in the beginning of this message. Then, he will use ']', '#', 'µ', ... what ever he want and can to use. > (I have to restrain myself: let's not disparage anyone's > nationality!) In France, we do use ']a,b[' for open intervals, is it used elsewhere ? > Of course, we could make ']b' do something special in text mode, but > not in math mode. > > Vim modes: [...] > TeX modes: [...] > > Why do I mention this? Mostly because it is late, but also because I > was a little worried that mentioning a TeX mode might lead to > confusion because Vim had modes, too. Don't worry. 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. -- Luc Hermitte http://hermitte.free.fr/vim/ |