Re: [vox-tech] ROT13 in vi?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [vox-tech] ROT13 in vi?
mark, it's exactly the same as you'd do with the progrm:
vmap <F1> !tr 'a-zA-Z' 'n-za-mN-ZA-M'<CR>
why did i mention the program in the first place? i'm not sure how to rotN
when N is an arbitrary number between 1 and 26. the easiest thing to do
would be to write a C program to do that and reference that program in your
vim macro.
pete
On Thu, 16 Nov 2000, Mark Kim wrote:
> 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
> >
> > naq ovatb. gurer'f n pbhcyr bs jnlf gb fxva guvf cnegvphyne png.
> > lbh pbhyq, sbe rknzcyr, jevgr n znpeb gb qb guvf. guvf jbhyq or gur
> > cersrerq jnl gb qb guvf.
> >
> > 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?' :)
|