Hello vim users

>From time to time I have stumbled upon the following situation:

In  some (non-ASCII-only) text files
there are places where, e.g., I have to keep the single "1/2"
character,
(it may be best to leave it intact in a C comment), or it should be
transformed to \frac{1}{2} (for typesetting in some TeX portion of
the text). This applies to manu other non-ASCII characters as well.

Also, there is some text in greeklish that has to be converted
(in Tex, the inputenc package
using iso-8859-7 conversion rules does this; I want to change them to
greek letters in the text file),
but TeX/LaTeX constructs and normal english text
(which are properly protected using toggles
or commands with arguments such as the ones below) should not be
affected.

So, to keep things simple, let's say we have :

\xfg1   - > toggle on  /  apply transformation group 1 to what follows
\xfg2   - > toggle on  /  apply transformation group 2 to what follows
\xfa1{..text..}  - >      apply transformation group 1 to argument
\xfa2{..text..}  - >      apply transformation group 2 to argument
$..\bruxf{..text..}..$- > break mathmode, use last active
                          (just before mathmode) \xfg* or \xfa*{},
*=1,2

under \xfg1 or \xfa1{} action:
ee - > eE
'e - > E
$$ - > $

under \xfg2 or \xfa2{} action:
ee  - > EE
1/2 - > \frac{1}{2}


"\xfg1 seen, Peer"           becomes "seEn, PeEr"
"\xfa1{seen, Peer}"          becomes "seEn, PeEr"
"\xfg1 seen, \xfg2 Peer "  becomes "seEn, PEEr"
"\xfg2 seen, Peer"           becomes "sEEn, PEEr"
"\xfa2{seen, Peer}"          becomes "sEEn, PEEr"
"\xfg1 seen, xfa2{Peer}"   becomes "seEn, PEEr"
"seen, xfa2{Peer}"           becomes "seEn, PEEr" (assuming \xfg1
toggle is on)
"\xfa2{this $\alpha \bruxf{seen, Peer}$}" becomes
                        "\xfa2{this $\alpha \bruxf{sEEn, PEEr}$}"
                        since group 2 is valid just outside left $,
etc.

A wrapper for all this would be nice, e.g.,
nmap , say, <C-F5> to grasp current paragraph, yank it,
prepent each line
with the percent-character of TeX comments indicator,
(%, or // for C/C++ comments, or whatever )
fold selection, do text transformations,
and append transormed text below fold.

I keep trying to convince myself that this is yet away of the
"only TeX can parse TeX" situation, since we are dealing with only
5 user-defined TeX control commands,
\xfg1 \xfa1{} \xfg2 \xfa2{} \bruxf,
and not the whole lot,
and don't need to address problematic situations,
e.g. unbalanced "{"s or "}"s, incomplete mathmodes, etc.,
but then again, ...?


any suggestions?

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

Reply via email to