De acordo com as Leis 12.965/2014 e 13.709/2018, que regulam o uso da Internet e o tratamento de dados pessoais no Brasil, ao me inscrever na newsletter do portal DICAS-L, autorizo o envio de notificações por e-mail ou outros meios e declaro estar ciente e concordar com seus Termos de Uso e Política de Privacidade.


Criação de tags HTML dentro do vi

Colaboração: Rubens Queiroz de Almeida

Data de Publicação: 29 de Junho de 1997

O editor de textos vi possui uma característica bastante interessante que permite que se criem abreviações para comandos ou caracteres a serem automaticamente digitados.

Estas definições são criadas dentro do arquivo $HOME/.exrc.

Uma definição do tipo

  ab pl #!/usr/local/bin/perl 

fará com que sempre que se digite a string "pl" esta seja expandida para "#!/usr/local/bin/perl". A string "ab" significa "abbreviation".

Importante, quando criar as suas abreviações, não escolha uma sequência de caracteres que seja comum na língua portuguesa. Se você criar uma abreviação como:

  ab	sa	#!/bin/sh

você se verá na incômoda situação de ver todos os "sa" que digitar transformados em "#!/bin/sh". Para desabreviar, existe o comando "unab", que deve ser executado em modo de comando:

  unab sa

Uma aplicação interessante deste conceito é a criação de macros que permitam a criação automática de diretivas html, ou seja, tornar o vi html-enabled (boa essa, não?).

Abaixo incluo um exemplo de um arquivo .exrc com diretivas para criação das macros html com algumas explicações.

Dá para ver que com esta facilidade o vi pode desempenhar tarefas extremamente complexas, reduzindo o stress causando pela digitação constante. Basta deixar a imaginação fluir :-)


Exemplo de arquivo .exrc

  "
  "                          Editor HTML
  "
  "   ab .... abreviações (utilizar em modo de inserção)
  "
  "        xy  gera <XY>,
  "       nxy  gera </XY>
  "
  ab pg <HTML><HEAD><TITLE>#</TITLE>
</HEAD><BODY>
</BODY></HTML>
  ab hr <HR>
  ab pp <P>
  ab ht <HTML>
  ab nht </HTML>
  ab hd <HEAD>
  ab nhd </HEAD>
  ab ti <TITLE>
  ab nti </TITLE>
  ab bd <BODY>
  ab nbd </BODY>
  ab str <STRONG>
  ab nstr </STRONG>
  ab bo <B>
  ab nbo </B>
  ab it <I>
  ab nit </I>
  ab pre <PRE>
  ab npre </PRE>
  ab ul <UL>
  ab nul </UL>
  ab ol <OL>
  ab nol </OL>
  ab li <LI>
  ab dl <DL>
  ab ndl </DL>
  ab dt <DT>
  ab dd <DD>
  ab adr <ADDRESS>
  ab nadr </ADDRESS>
  ab h1 <H1>
  ab nh1 </H1>
  ab h2 <H2>
  ab nh2 </H2>
  ab h3 <H3>
  ab nh3 </H3>
  ab h4 <H4>
  ab nh4 </H4>
  ab h5 <H5>
  ab nh5 </H5>
  ab h6 <H6>
  ab nh6 </H6>
  ab ig <IMG SRC="#">
  ab fr <FORM ACTION="#" METHOD="#">
  ab nfr </FORM>
  "
  "   map .... Macros.   (usadas em modo de comando)
  "
  "  ctrl-x ctrl-l : a linha sob o cursor se torna o texto para um link
  "                  o cursor fica localizado após o HREF para que possa ser
  "                  feita a inserção da URL
  "
  map  o</A>kO">I<A HREF="
  "
  "  ctrl-x ctrl-w : a palavra sob o cursor se torna o texto para um hiperlink,
  "                  o cursor fica posicionado no HREF para que se possa inserir
  "                  a URL. (isto somente funciona se o cursor estiver 
  "                  posicionado no fim da palavra)
  "
  map  a</A>bbbi<A HREF="#">F#s
  "
  "  ctrl-x number : a linha sob o cursor se torna um cabecalho
  "                  ctrl-x 1  --->   H1  
  "                  ctrl-x 2  --->   H2  
  "
  map 1 I<H1>A</H1>j
  map 2 I<H2>A</H2>j
  map 3 I<H3>A</H3>j
  map 4 I<H4>A</H4>j
  map 5 I<H5>A</H5>j
  map 6 I<H6>A</H6>j

Dica Humorística :-)

Fit the Second: (Birth) Striped Irregular Bucket #5

Bastard Operator From Updated: Tuesday 14 November 1995 BOFH © 1990-1995 by Simon Travaglia and Datamation. All rights reserved.

I'm still bored.

But at least now the radio's off, it was on it's 12 repeat of "Wildfire" THIS WEEK, and it's only Tuesday; shit I hate that.

So anyway, I quicklime the engineer to remove any fingerprints and then FedEx him back to headquarters and set about waiting for the new engineer.

Now the second engineer only has to come out after another 4 hours, there's no death of engineer penalty clause, (but I'm thinking about asking for one) so I've got to fill in some time. This guy's going to be a technical engineer, the sort that comes in with a raggedy tie where he got it caught in the drum printer at 3000 rpm a couple of years ago, and he'll have the grazes on the face that indicate that he didn't get the gate open in time...

I know those sorts...

So I fill in a couple of hours by killing users off and deleting their files, then waiting for them to call...

"Um, I can't find my files" the wimpering simp on the phone says

"Files? What files?"

"The files in my account. My thesis, my research - all gone!"

"Gone ay? What's your username?"

"TURGEN"

"TROJAN?! LIKE THE CONDOM?"

"No TURGEN. T-U-R"

"OH Turgen, like TURD, but with a GEN instead of a D... Ok lets see" I make vague clicking noises my dragging the quicklimed man's fingers back and forth across the keypad. "Uh-huh" >drag dragdragedy poke "I KNOW!"

"Well, what are you calling ME for? We don't make the files you know, we just look after them. And chopitty-chop too, your thesis looks like it's due in a couple of days.."

I hang up - he'll call back. Meantime I open up a copy of "VMS BASTARD OPERATORS MANUAL FROM HELL" I'm reading the article I sent in about getting rid of those trouble users...

"... Modify the user's password minimum from 6 to 32 letters, give the password a 1 day lifetime, set it so that they HAVE to use the password generate utility when they change their password (so their password will always be something that looks like vaguely pronouncable line-noise), add a secondary password with the same as the above, then redefine their CLI tables so that the only command that works is DELETE, and all other commands point to it."

Beautiful.... Shit I'm good!

He calls back.

"MY FILES ARE GONE!" he screams, panicking.

"Did you have a backup?" I ask, as sweet as pie

"But that's what you people are supposed to do!" he sobs

"Yeah, well we did - but then we switched to those 8mm tapes, and they're the same size as the ones in my video camera, so I've been using them to tape the neighbour's sex romps..."

I hear the revolver go off, but what the hell, it's 5pm, and not my problem...

Adicionar comentário

* Campos obrigatórios
5000
Powered by Commentics

Comentários

Nenhum comentário ainda. Seja o primeiro!


Veja a relação completa dos artigos de Rubens Queiroz de Almeida