Monday, March 29, 2010

"Archive and Next" in Gmail

True timesavers among Gmail's keyboard shortcuts:
'[': Archive and move to the next newest message
']': Archive and move to the next newer message

Open MacVim tabs from command-line

Change the mvim script as follows to open files in new tabs instead of new windows when starting MacVim from the command line:

  1. Add the following line to the top of the file, below the commented section:
    tabs=true

  2. Replace the if structure at the bottom of the file with the following:
    # Last step:  fire up vim.
    if [ "$gui" ]; then
    if $tabs && [[ `$binary --serverlist` = "VIM" ]]; then
    exec "$binary" -g $opts --remote-tab-silent ${1:+"$@"}
    else
    exec "$binary" -g $opts ${1:+"$@"}
    fi
    else
    exec "$binary" $opts ${1:+"$@"}
    fi

Tip'o'the hat to Web Expose for this information.

Friday, March 26, 2010

Moving the shell cursor around

  • ctrl-a: move to front of line
  • ctrl-e: move to end of line
  • ctrl-w: delete word before cursor
  • ctrl-r: search past command history
  • up/down arrow: page through previous commands
  • alt-b / alt-f: move backward/forward one word (without deleting)
More details can be found in the bash reference.

Tuesday, March 16, 2010

Using xmllint in (Mac)Vim

To reformat XML documents in Vim:

:%!xmllint --format --encode UTF-8 -

More details here.

Thursday, March 11, 2010

Shell script for replacing multiple partial strings in multiple files

I wrote a very simple script to handle a complex replacing in a lot of files. Use with care!


#!/bin/bash

# This script replaces multiple partial strings in multiple files

for n in strpart1 strpart2 strpart3
do
exec perl -pi -e 's/firstpart${n}secondpart/newfirstpart${n}newsecondpart/g' *.htm
done