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:
:%s/^\(\w\)/\=toupper(submatch(0))/
I forget about Vim's submatching expression, which is extra handy for some of those tasks that just appear to be unavoidable monotony.
Thursday, November 23, 2006
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.
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.
- Lookup the key you want to override - :help terminal-options
- Then type "set ~option~=
~Control V~~press the key that doesn't work~" - 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.
- Type :help terminal-options --- Aha, I see a table and in that table it says that 't_ku' is the 'arrow up' key.
- Type :set t_ku=
~Ctrl-V~~up~ (where everything between ~s are the control V and then pushing the up key). - 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 vim.org 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 $_
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 $_
Subscribe to:
Posts (Atom)