Re: [vox-tech] ROT13 in vi?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] ROT13 in vi?
- Subject: Re: [vox-tech] ROT13 in vi?
- From: Mark Kim <mkkim@ucdavis.MAPSedu>
- Date: Thu, 16 Nov 2000 15:07:52 -0800
- References: Pine.LNX.4.21.0011160754580.1447-100000@belial.ucdavis.edu
That's cool, but how would you do this without creating a new program --
like, how would you pipe the text to a program (tr) then grab its
output back into vi?
-Mark
On Thu, 16 Nov 2000, Peter Jay Salzman wrote:
> On Thu, 16 Nov 2000, Mark Kim wrote:
>
> > Actually, I wanted to know the way to do ROT-N, where N is any arbitrary
> > number, including 13. Mike's way of doing it was using :tr but I can't
> > figure it out. It was something like:
> >
> > :%tr/[A-Za-z]/[N-ZA-Mn-za-m]/g
> >
> > but that doesn't work so obviously that wasn't it. But it was something
> > similar.
>
> ahhh... ok, sorry about that. hopefully, this is payment on your answering
> my opengl questions! :-) rot13 is easy; it rotates by 13, so the
> following line should do it:
>
> tr 'a-zA-Z' 'n-za-mN-ZA-M'
>
> at this point, there are a few avenues of attack. if you wanted to make a
> shell script out of it, (let's call it "rot13" and put it in
> /usr/local/bin).
>
> #!/bin/sh
> tr 'a-zA-Z' 'n-za-mN-ZA-M'
>
> GNU tr is "smart" enough to know what you mean here. i'm pretty sure this
> wouldn't work on HPUX or some really braindead unix like ultrix. offhand,
> i'm not sure what would happen if the leftside didn't "fit" into the
> rightside. i'll try that after i'm done with this email.
>
> now, when you're editing something in vi (like your mail), simply
>
> 1. select some text using the shift/alt/ctl v mechanism.
> 2. press !
> 3. type rot13
>
> and bingo. there's a couple of ways to skin this particular cat.
> you could, for example, write a macro to do this. this would be the
> prefered way to do this.
>
> place the following line in your .vimrc:
>
> vmap <F1> !rot13<CR>
>
> from now on, when you select text and press F1, the selected text will be
> rot13'd. i never liked the vim help anyhow. it has 2 strikes against it:
> 1. it's hard to understand
> 2. it's confusing
> so, IMHO, F1 is an ok key to remap. :-)
>
>
> now, if we wanted to do rotN ... well, now we're talking about a little
> programming. it should be easy enough to do this in C making use of the
> nice property that ASCII alpha characters increment linearly. and then
> all the stuff i wrote above this paragraph should apply just as well to the
> rot13 case.
>
> off the top of my head, i'm having trouble figuring out how to do it in shell
> scripting without having 26 cases.
>
> let me think about it.
>
> pete
>
> > On Wed, 15 Nov 2000, Peter Jay Salzman wrote:
> >
> > > sorry, i couldn't resist.
> > >
> > > the way i do it is to use the shift/alt/control V mechanism to highlight a
> > > selection of text, then use g? (g followed by a question mark) and that
> > > converts the selected text to rot13.
> > >
> > > ubcr gung urycf! :)
> > >
> > > pete
> > >
> > > ps- :) is rot13 for :). :)
> > >
> > > ---------------------------------------------------------------- linux
> > > To err is human, to forgive is divine. p@belial.ucdavis.edu _
> > > To oink is porcine, to meow is feline. http://www.dirac.org/p ._.
> > > To neigh is equine to howl is lupine, /v\
> > > To moo is bovine to bleat is ovine. // \\
> > > ---------------------------------------------------------------- ^^ ^^
> > > The best way to accelerate a win95 system is at 9.81 m/s^2 rules
> > >
> > > On Wed, 15 Nov 2000, Mark Kim wrote:
> > >
> > > > I asked this question before and I think Mike answered it I lost the
> > > > posting. How do you do ROT13 in vi (actually, ROT anything)?
> > > >
> > > > -Mark
> > > >
> > > > PS: Yes, I know about 'g?g?' :)
>
---
Mark K. Kim
http://www.cbreak.org/mark/
PGP key available upon request.
|