[Vim-latex-devel] Re: [Vim-latex-cvs] vimfiles/plugin imaps.vim,1.7,1.8
Brought to you by:
srinathava,
tmaas
From: Luc H. <her...@fr...> - 2002-12-09 00:32:45
|
* On Sun, Dec 08, 2002 at 03:12:10PM -0800, Srinath Avadhanula <sr...@fa...> wrote: > Option 1: > change things like '\onlyslides{«»}«»' to > "\\onlyslides{\xab\xbb}\xab\xbb" Hard to read IMHO. Hard to maintain. > Option 2: > Change it to something like "\\onlyslides{<++>}<++>" > Here the placeholder (or marker) characters are "<+" and "+>". Easier to read, but imaps may not work with a new language using '<+' and '+>'. I think you should choose something expressive and odd enough to not beeing used by anything else. > Now the characters (and the vim scripts) will be correctly displayed > across all platforms/locales etc. The problem with this approach, > ofcourse is that we are using 2 characters instead of 1. This will > make the expansions generally longer... It is not really problematic ! I will use '!mark!' for instance (instead of '¡mark!' currently used) to express the markers (aka placeholders) > Hmm.... As you can imagine, I am leaning towards option 2. Are there > any other suggestions? Don't worry about beeing even more expressive. The time consumption is not so hihg. > On Sun, 8 Dec 2002, Luc Hermitte wrote: > The way things work now in latex-suite is that things like > > let s:figure = "\\begin{figure}[«htpb»]\<cr>\\begin{center}..." > > are defined. When Imap_PutTextWithMovement is called it attempts to > replace «» chars with the thing defined in g:Imap_PlaceHolder*. In a > way therefore, latex-suite does actually wrap the commands into a > central function. For complex insertions like this one, I am more inclined to use template-files. In http://hermitte.free.fr/vim/ressources/after/template/tex/ you will found how I plan to support templates for TeX.[1] At this moment, I need to patch muTemplate to support different encodings. My main problem beeing to find something as short as '¡'...¡' but independant of the encoding used. > > call <SID>MapMenu4Env("50.370.200", '&LaTeX.&Environments.&itemize', > > \ ']ei', 'itemize', '\item ') > > that also defines 3 mappings and 3 menus. The insert mode mapping > > ']ei' inserts: > > \begin{itemize} > > \item µ > > \end{itemize}«» > > Wont this also create exactly the same problems we are seeing now. > For example, I am replying to this mail in vim with encoding=latin1. > When I switch to utf8, the \mu character looks like <b5> etc... [I used mu, in this email, to represent where the cursor will be, I may also have used '§'] Nope. Because MapMenu4Env() mecanics looks like: - building 3 strings (3 modes) - where the INSERT-mode string is : '\begin{'.a:tex_env.'!close!<CR>'.a:middle.' <CR>\end{'.a:tex_env.'}<esc>ks', As a result, ']ee' is i-mapped to: \begin{enumerate!close!<CR>\item <CR>\end{enumerate}<Esc>ks '{' may be already mapped to [2] to '{}«»<esc>F{a' (or may be not mappd at all) '}' if mapped is supposed to be mapped to '<esc>/}/<cr>a' '!close!' jumps to the marker (and delete it) if b:usemarks is set, or just moves one character to the right otherwise. It is completly dependant on some asumption I made, but you can do something similar with vim-latex. The map&menus functions are highly complex, but in the end, defining mappings in very easy as every LaTeX environments are based on the same principles. For more complex environments, template-files are, IMO, easier to handle and maintain. Back to your remark, the problem is to correctly define b:marker_open (b|g:placeholder_left or something like that in imaps.vim) whatever the encoding is. [1] '¿...¿' will be replaced by 'VimL: ...' [2] actually '{' is mapped to a very complex function that expand '{' into different things according to: - the context (comment, string, or other), - the value of b:usemarks, - the values of b:marker_open and b:marker_close. -- Luc Hermitte http://hermitte.free.fr/vim/ |