Thursday, November 23, 2006

Capitalizing Sentences

Here is a quick way to search for some letters, and then capitalize them quickly. I wanted to capitalize all of the letters at that start a line. Here was my query:


I forget about Vim's submatching expression, which is extra handy for some of those tasks that just appear to be unavoidable monotony.

Saturday, November 18, 2006

Arrow keys on the macbook pro

I used to have this exact problem when I used Linux on a Thinkpad several years ago. Try to use vim from the console, and the arrow keys simply don't work. There are a couple solutions to this problem, from what I understand, but I like this one b/c its simple and easy to apply on the fly whatever kind of terminal you find yourself in front of.

  1. Lookup the key you want to override - :help terminal-options
  2. Then type "set ~option~=~Control V~~press the key that doesn't work~"
  3. The key is now overriden. To make it permanent, copy the command into your .vimrc (use : to view a buffer of all ex commands for easy copy/pasting).

This might sound a little complicated. Its not. Here is an example. Say that the 'up' arrow key doesn't do anything when you are in vim. No problem.

  1. Type :help terminal-options --- Aha, I see a table and in that table it says that 't_ku' is the 'arrow up' key.
  2. Type :set t_ku=~Ctrl-V~~up~ (where everything between ~s are the control V and then pushing the up key).
  3. Tada, the up arrow key now works correctly.

Friday, November 03, 2006

Uncombobulating text

I keep forgetting about these two tips, or rather, I get them confused. To decode some stream of data that is encoded as ASCII you can goto and read up my tip on it. Basically, install a plugin, and then run a quick search replace. I actually wrote a coder/decoder so that I could whip up custom password bookmarklets easily.

The other format is base64. I forget that ascii is base16 and base64 is, well, base64 and so has 64 different characters rather than the cleaner 16. In any event, I found this great tip for decoding base64. Don't follow the tip instructions, scroll down to the last comment on the tip, and use it instead:

:ruby require "base64"
:.rubydo $_=Base64.decode64 $_