Skip to main content

Posts

Showing posts from March, 2008

Another VI tip - using buffers

VI lets you use buffers to quickly copy and save chunks of text. You can think of them as being sort of like the clipboard that you copy to when you highlight some text in Word or other such programs - except that you have many, many more clipboards at your disposal. Here's how it works. In VI, highlight some text that you want to copy - hit v and then move the cursor around to highlight the text. Then decide what buffer you want to copy it to. The buffers are identified by a letter - so let's say you wanted to copy some text to the "h" buffer - you would type the following (with the text highlighted) "hy which "yanks" that text into the buffer. You could then paste the contents of that buffer with "hp The contents of the buffers persist until something replaces them - which makes them a great place to store those little snippets of text you use a lot. And in reference to my earlier post about using macros , you can even use buffers within a mac...

Quick tip - imagemagick

Had to update a site today to allow its automated thumbnail creation to pad out the thumbnail with a background color, so that all the thumbs were the same size. Took a little digging to find this helpful page . The first example, using extent 100x100 worked well enough on the command line, but oddly enough wouldn't worked when called from PHP. So I used the second method that crops the image, and that worked fine. Also, I had some good feedback on the VI automation post, and actually had a pretty long post with more examples/tips - but blogger got buggered up by some of the HTML used in the example, and I abandoned the post out of annoyance. Seriously, I sort of assumed blogger stripped tags out by converting ">" to ">", etc - apparently not. Oh well, I'll do it again at some point when i get a chance.

IE6 background image/color bug and fix

Ran into this just now. I was working on alternate css for IE6, since I had a div that was using a translucent (semi-transparent) PNG, and of course IE6 doesn't support them. I tried the javascript PNG fix for IE6, but it doesn't seem to work on background images. Anyways, so I wanted to use a regular white background for IE6. I used the IE conditional statements to set that in the CSS, and sure enough IE6 would display the white background color. And then it wouldn't display most of the contents of the div! Took me a while to figure out, but apparently it decided that the div and its background color were a higher z-index than the contents. Go IE! Rendering like a champ as always. So for IE6 I had to tell it that the contents of that div (thankfully in their own divs) were z-index 100, and that fixed it.

Another VI tip - using macros, an example

God I love VI. Well, actually, vim but whatever. Here's another reason why. Suppose you need to perform some repetitive task over and over, such as updating the copyright date in the footer of a static website. (Yes, yes I know you could do a javascript thing or whatever, just bear with me.) Of course you could just search and replace in some text editor, changing "2007" to "2008" (if you're stupid) - and you'll end up with a bunch of incorrect dates being changed, most likely. What you need to do is only change that date at the bottom. And suppose that because of the formatting, you can't use the "Copy" part of the string in a search replace - perhaps some of the pages use "©", some spell out "Copyright" etc. This is where vi macros come in handy. A macro in vi is exactly what you expect, it records your actions and allows you to play them back. To start recording, press q followed by a character to use to "stor...