vi, Drupal Search, and Playa Del Carmen Retreat

Doug Green

on

July 8, 2008

vi, Drupal Search, and Playa Del Carmen Retreat

LIVE FROM THE ENGINEERING PLAYA DEL CARMEN RETREAT... I first used vi in 1984 while writing an Operating System for one of my classes. I probably really learned vi while playing nethack during the summer of 1984. I've used vi in almost every job I've had since then. Even when I was on windows, I used mks toolkit or cygwin. That's a 24 years of vi use. I know that we all love our editor. And I have no desire to get into an editor flame war. The point is that I that I've been using vi for a long time, and it's very comfortable for me. But while I've been using vi for over 20 years, I discovered today that I might only have a 7th or 10th grade education, and that there are people with advanced degrees! First, Owen helped me setup debugging from vi. Wow! I've tried to setup Eclipse before, but never succeeded. I've been developing in Drupal using the php equivalent to printf, print_r. Learning that vi could also debug, opened up a new world. I discovered VIM for (PHP) Programming, and Wow Wow! Vi can open multiple windows, it has syntax checking, it even has a spell checker! ^W is my new favorite key. ^W s opens a split horizontal window, ^W v opens a split vertical window, ^W n opens a new split window, and then of course ^W h, ^W j, ^W k, and ^W l work as expected! Fen says that I was near tears. Here's my quick vi tutorial:
^F - forward
^B - back
h - left
j - down
k - right
l - down
^W s - split window
^W v - split horizontal window
^W h/j/k/l - move between windows
mx - mark something called "x"
dx - delete from the current line to the mark called "x"
dd - delete a line
yy - yank a line
5d - delete 5 lines
p - paste (the lines you've deleted or yanked)
% - go to the matching bracked () {}
d% - delete to the matching bracked () {}
:%s/from/to/g - change all occurrences of "from" to "to"
^ - go to the first character in the line
0 - go to the beginning of the line
$ - go to the end of the line
dw - delete word
cw - change word
C - change to the end of the line
5s - change the next 5 characters
5cw - change the next 5 words
Oh, I started down the vi debugger path because of a problem I was having with some code. A few of you might be interested to know that I've mostly completed the backport of the Drupal 6.x search patch 146466 to Drupal 5.x, because Kieran and Robert asked. BTW, the Flickr tags for the Retreat are CivicActions Offsite Playadelcarmen

Share it!

As promised above, #146466 has been submitted. After some review, maybe we can get this on drupal.org to improve performance, before the 6.x upgrade.