Thursday, December 18, 2014

Re: Can the "<" char be escaped with a backslash in Vim keymaps?

BPJ wrote:
> Erik wrote:
>> Is your task amenable to using simple methods? E.g.:
>> $ echo Ewokhbhs laoohmf rsqhmfr akrn vnqj | tr "[a-y]" "[b-z]"
> Alas it is not. By transliteration I mean things like changing the
> two-character sequence "ch" into the single Cyrillic letter "ч"
> (U+0447), so the tr utility won't be up to the task. Moreover I'm
> doing this outside of Vim, transcribing text files batchwise
> programmatically, it's just that I have the needed replacements
> already written up as Vim keymaps, so I'm writing a script to
> convert Vim keymaps into the correspondence tables needed by the
> script doing the file transliteration. (The latter basically
> imports the correspondence table as an associative array and
> constructs a huge regular expression from the keys, then does a
> single longest-leftmost substitution pass. See here for the
> theoretical background:
> <http://interglacial.com/~sburke/braille/tpj_article.txt>.

That article gives a very good background on how you can use perl,
instead of tr, as the external filter to accomplish your task. It also
sounds like you have the start of a vimrc parser to use as a
configuration file for your script.

For readability reasons, I would not write it as a single giant RE,
however, but a series of very small REs applying the rules in order.

> (BTW Sean M. Burke's self-description "likes making linguists
> think he's a programmer, and programmers think he's a linguist"
> would fit me very well too! ;-)

Perl is a language written by an amateur linguist, so it seems to
attract people with that mindset.

Elijah

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: