17 de dezembro de 2008

Autocompletar no VIM

Vi um post no blog do Renato Carvalho[1] e achei muito útil, para que programa isso é uma maravilha, então eu vou colocar este tutorial aqui, mas com algumas modificações.

O autocompletar é um método que funciona da seguinte maneira: você digita parte do nome de uma função de uma linguagem e, ao apertar uma tecla específica, o editor que você está utilizando, se ele possuir esta opção implementada, irá lhe mostrar uma lista com funções que são parecidas com o que você digitou.

No VIM esta opção não vem implementada e para implementá-la você deve fazer o seguinte, utilizando como exemplo o PHP:

Crie os diretórios para plugin e doc no ~/.vim/:

$ mkdir -p ~/.vim/doc

$ mkdir -p ~/.vim/plugin


Baixe e instale o plugin para o vim SuperTab.

Baixe a lista das funções php do site do Lerdorf e salve em ~/.vim/doc como php-funclist.txt

Insira a linha abaixo no arquivo /etc/vim/vimrc para que tenha efeito em todos os usuários:
if has("autocmd")
autocmd FileType php set complete-=k/home/$USER/.vim/doc/php-funclist.txt complete+=k/home/$USER/.vim/doc/php-funclist.txt
endif


Você pode trocar o nome do arquivo com a lista de funções para o nome que você quiser, eu aconselho que você coloque algo relacionado com o nome da linguagem a qual a lista de funções pertence, no caso deste tutorial, o PHP.

Agora você pode testar:
No terminal digite:
$ vim teste.php

No arquivo faça o teste:

< ?php
eregi_re
?>

Pressione a tecla TAB e veja o resultado:

< ?php
eregi_replace
?>


Pronto! Isso pode ser feito para outras linguagens, desde que você possua a lista com as funções e insira uma nova linha no /etc/vim/vimrc fazendo as devidas modificações.

[1] - http://www.renatocarvalho.net/autocompletando-no-vim-dicionario-php.html

Créditos a Renato Carvalho, com algumas modificações feitas por mim.

Top 20 frases de Geeks

Vi um post no blog AskStudent[1] e achei as frases muito engraçadas, então pensei: "Vou coloca no meu blog, faz tempo que não o atualizo mesmo!", e estão aí as 20 melhores frases de Geeks (em inglês):


#1. Roses are #FF0000, Violets are #0000FF. All my base Are belong to you — someone on SlashDot

#2. There is no place like 127.0.0.1

#3. Girls are like Internet Domain names, the ones I like are already taken

#4. Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning

#5. Computers are incredibly fast, accurate, and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination. — Albert Einstein

#6. There are 10 types of people in the world: Those who understand binary and those who don’t.

#7. If at first you don’t succeed, call it version 1.0

#8. 1f u c4n r34d th1s u r34lly n33d t0 g37 l41d

#9. I’m not anti-social; I’m just not user friendly

#10. I would love to change the world, but they won’t give me the source code

#11. My Software never has bugs. It just develops random features.

#12. The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts “OH MY GOD WHAT ARE YOU DOING!!!

#13. The glass is neither half-full nor half-empty: it’s twice as big as it needs to be.

#14. Passwords are like underwear. You shouldn’t leave them out where people can see them. You should change them regularly. And you shouldn’t loan them out to strangers

#15. Enter any 11-digit prime number to continue…

#16. A Life? Cool! Where can I download one of those?

#17. I spent a minute looking at my own code by accident. I was thinking “What the hell is this guy doing?”

#18. Concept: On the keyboard of life, always keep one finger on the escape button.

#19. Alert! User Error. Please replace user and press any key to continue

#20. If builders built buildings the way programmers wrote programs, then the first woodpecker that came along would destroy civilization. — Weinberg’s Second Law


[1] - http://www.askstudent.com/funny/top-20-list-of-the-best-geek-quotes-sayings-and-phrases/