Wednesday, March 28, 2007

Editor Brain Modes

I wound up tying in a long comment to "Coding Horror's" blog... so I thought I would post it here too since this is my official place for programmer musings and fun discussions.


I am a big fan of using the keyboard as much as possible. I have found that over the years I have formed "modes" in my brain for the different types of editors I use:

  • Mode # 1 - "Everyman" Editing:

    This is my brain mode for when I am in a standard windows text box, a notepad window, or editing something on someone else's editor and I want to have the best chance of things just "working". No fancy, feelin' cool editing tricks here. Just get the job done and use the experience to remind you of how much nicer the other mode's are.. (This message typed in Mode # 1).

  • Mode # 2 - "Faux Emacs":

    Ah, old school emacs. This is my favorite, because if you are trained right you can keep both hands on the keyboard for just about everything. No lifting your hand up to search for arrow keys or the home/end. Just keep those palms flat on the keyboard ergo-bench and type away. Emacs uses the CTRL and ALT keys as modifiers for all the basic editing commands, and has no qualms about, say, using Control-F to mean "move cursor forward" and Control-d to mean "delete character". There are some interesting conflicts that arise when you bring the default emacs commands to windows. The one that really freaks people out is when I have Page-Down mapped to Control-V. Heaven help the poor soul who tries to use my Visual Studio while its emacs profile is still engaged. They go to paste a bit of text and the *entire screen changes!* Heh heh... if I had a dime for every time a coworker yelped in dismay...

    I do have a somewhat hybrid set up for those apps that I can configure to use emacs key bindings - things like Shift + Control + F = Extend selection forward one char, Shift + Control + A = Extend selection to start of line, and Control + U = Page Up (took that from vi). I am actually more in tune with this "bastardized" hybrid than true emacs, but drop me in real emacs editor and I only start to choke when I have to remember those funky double-sequence commands like Control-X Control-S to save and the like. Or heaven help me if I need to remember how to manipulate kill regions or run a Meta-X search-for-string...
  • Mode # 3: "To The Pain" (g)VI(m) -

    Long ago I lived in worlds where sometimes emacs was not available. I bit the bullet and learned VI. It is just as powerful as emacs in its ability to let you keep those palms flat on the keyboard, but it does it in a different way. VI is a "mode-based" editor - meaning that you press a key ('i') and then everything you type until you hit the ESCAPE key is treated as text input. If you are not in 'insert' mode, then you're in 'command' mode, which is where you can move around ('ijkl') and enter "colon" commands like ':w ~/myfile.txt', ':wq' (write file then quit), or ':q!' (quit without saving, dammit).

    After literally years, I eventually reached the point where I could effortlessly switch into "vi" mode and do quie well. These days, I am even able to do basic search and replace without having to look it up. Don't believe me? Check this out:


    Looks like Sendmail control codes, or Perl gone right, eh? No sir, it is my version of "Replace every occurence of the word 'foobar' with 'Snickers' in the file. My mind tells me that this command is essentially broken down like this:

    ':1,$s/foobar' // search for the string foobar anywhere from
    // the 1st line to the end of file '$'.

    // If you find a foobar, replace it with Snickers please...

    'g' // Oh, and do it globally for all matches you find.
    // (Snickers really satisfies...).

    It turns out that depending on which vi you are using you may not need the 'g' part at all.. and frankly if you use me as your canonical reference for how to break down the vi command above you should have your brain checked for lesions.

    Well, anyway, that's my brain on editors after well over ten years of programming in Unix, Windows, and other seedy locales. Thank you for listening :-)

Tuesday, March 27, 2007

Mouse scroll wheel too sensitive? This might work...

The Mouse with A.D.D.

Recently, for no reason that I can figure out, my mouse scroll wheel suddenly became hypersensitive. I would scroll just a tiny fraction and the window in focus would scroll down as if I had spun the wheel harder than the burliest contestant on The Price Is Right. Reams and reams of virtual pages would careen before my eyes. I would try to barely move it - but it was like playing that Operator game -- and I kept touching the sides! BZZZZZZT!!! It was so sensitive that just the barest touch of my finger would send it down several pages. On several occasions, and I am not making this up, the damn thing would literally scroll UPWARDS after it hit the bottom of the page, as if it were bouncing back due to some kind of virtual scroll-wheel backlash.

It nearly drove me insane. I had to put a stop to it.

The problem was systemic to all applications, so it seemed likely a driver issue. After fiddling with the control panel, which didn't help because the slowest scroll speed was still 100 KPH or better, I went to phase two and upgraded the mouse driver. I installed the latest Microsoft Intellipoint mouse driver, and that fixed the issue without even requiring a reboot. Yay!

So the next time your mouse is giving you problems, try upgrading the mouse driver software. Or even just reinstalling the drivers you already have. Chances are good that this may fix your problem. If not, there's always tech support .


Monday, March 19, 2007

Twitter Mania

I have recently been checking out the new web-craze called Twitter. I heard mention of it many times on TWiT ( before I finally decided I would check it out. At first I was confused as to what the heck was the big deal - but I suddenly "got" it when I added Leo Laporte, the host of TWiT, to my friends list. Suddenly I felt I was connected with his life in a way that I've never experienced before. It seems silly, but knowing what he was up to during the day kept me somehow feeling closer to him. I didn't really feel like a stalker, though in truth there is definitely a stalker element to this, but rather as some kind of privileged friend that had Leo on my MSN account or something and I kept getting IM messages from him.

It is strange to know more about what Leo is doing during the day than my own wife, or anyone else in my life, other than my coworkers. Very interesting.

I think the other thing that I have come to associate with twitter is a sense of being in the midst of a maelstrom of web links and blogging and cool links. As soon as I added a few of the "popular" or "A-list" tweeters, such as Scoble & Calcannis (sp?) I found myself quickly overwhelmed with the amount of links they were posting and the sheer volume of information those personalities could shovel at the populace in a day. They seemed to have a capacity for reading and trolling and posting links that far exceeded my meager ability to read them.

In the end I can simply de-friend the ones that are to annoying/noisy. I liked Jason Calcannis' style, but the guy is hyperactive at a level I can't match - so I removed him from my friends list and suddenly the world seems a bit more peaceful now.

Now if I can just get the gumption up to drop Scoble from my list. ..