Tom Morris



2009.06.02

  No. 952 

I'm quite amused by this story of how Osel Hita Torres, who the Dalai Lama picked as a great spiritual leader, has basically told them to fuck off. Totally strange story. A good outcome for Torres, but epic fail for the Tibetan Buddhist monks. It's quite something when a child that's supposedly reincarnated from one of the great teachers decides he wants nothing to do with the religion and becomes an agnostic. Like something out of a Discworld novel. 2009-06-02T14:31:33ZUntitled entry permalink

Going (almost) mousefree on OS X 2009-06-02T11:21:38ZPermalink

Ever since I started using Vim, I've really gotten into Vim-style keybindings. I was touch-typing back when the normal kids were out kicking spherical objects around grassy planes, both on an Olympia SM8 (with a longer carriage suitable for legal documents) and on an Amstrad CPC 6128 running AMSBASIC and CP/M.

If you can't type, fucking well fuck off and learn how to do it. Go read Steve Yegge or Jeff Atwood. Then go install the GNU typing tutor thingy or find some flashy Ajax shit that'll teach you how not to suck.

Anyway, being able to type and using software which lets me use the 79 keys on my laptop (or the hundred odd on the keyboard I occasionally pull out when I'm getting my write on) is far preferable to mousing. Trackpads on the Mac have gotten so much better with the switch to the glass multi-touch trackpads, but nothing beats the keyboard. You may think mouse gestures are clever. Keyboard gestures are much nicer. I've got this rather strange affliction. I mean, I've got this fancy Mac laptop with light-up keys and everything. But I know where the keys are - the lights seem ever so slightly pointless if you know how to type. It's also got this beautiful whizzy operating system with superb typography and bouncy, floaty animated doodads. Which is nice. They tick away in the background while I spend hours staring at white, monospaced text on a black background.

Once Vim gets it's hooks in, you then start wanting everything else to be less like a Fisher-Price toy and more like Vim. Obviously, the Terminal is pretty close already. But there's still this operating system here that's a bit of a pest.

Quicksilver gets you most of the way there. Hide that Dock away. Cmd-Tab, Cmd-backtick. Quicksilver lets you launch, switch and do a whole bunch of common actions (trash, move, and lots of app-specific stuff). Seriously. Some people stick with Spotlight, pre-built into the OS. It has some nice stuff, but the problem I find is that I type in something very simple like "Safari" into Spotlight and it sits and churns to try and find me absolutely every bit of developer documentation or thesaurus entry or whatever. Quicksilver is just snappier. Even if Quicksilver's index can get bloated. It was getting to the point where it was using up something like 1.5Gb of physical RAM just sitting passively in a backgrounded account on another box, so when anyone else tried to use that box, they'd sit there for hours while everything just swapped around it. (Know thy top, ps or Activity Monitor.app and delete Quicksilver indexes from user folders if they get too resource-hungry).

Much more awesome than even Quicksilver is Vimperator. Vimperator is a plugin for Firefox that hides all that location bar, toolbar and bookmark bar clutter and lets you control it like you control Vim. But, better than even that is the fact that it’s scriptable. In JavaScript. Oh yes. You can do something like liberator.modules.commands.addUserCommand(["cheese"], "Takes you to a website about cheese", function(...)); and you get yourself a :cheese comand. You also get a .vimperatorrc file which you can fill with map commands like your .vimrc. Oh, and, yes, XHR works in vimperator JavaScript. Of course. Firefox can become Vim. Only, Vim’s extension language makes JavaScript seem pretty pleasant. And having a whole bunch of Vim colon-commands is a lot nicer than having a whole load of bookmarklets. Have a look here. There’s plugins for all sorts of things: URL shorteners (like is.gd, bit.ly, tinyurl etc.), delicious integration and so on. Now, if you are using Mac, the standard OS X Firefox theme looks very strange when you first start using Vimperator. Obviously, the tab bar remains. Once you’ve got Vimperator in place, I strongly suggest you switch the theme in Firefox to GrApple Delicious. I’ve tried a few other possible themes (including the other GrApple themes) and GrApple Delicious seems to work best and look the least fugly.

Is it only the Firefox people who get to play? Hell no. VimOpera does the same thing for Opera. And if you are more of an Emacs-head and have a whole bunch of double-jointedness, Conkeror is for you. It’s XULRunner-based and uses Emacs key-bindings.

Now, much as they are hacky and possibly the cause of instability, InputManagers on OS X are a necessary evil. They are often the cause of fair amounts of pain and frustration and must be selected with care and love. There’s two which are particulary useful you should start with. MegaZoomer lets you make software run completely full-screen. That all started with Hog Bay Software’s WriteRoom, which gives one a full-screen text editor (with the simplicity of a typewriter!). MegaZoomer does that for a whole ton of other apps including the Terminal. It doesn’t do it in MacVim, but MacVim already has something similar (Shift+Apple+F). Also, the latest version of Pages has this feature for you strange people who want to write something outside the text/plain, HTML, XML or LaTeX mindset of, well, me. The other input manager worth having is Afloat, which has a whole stack of features - I use it only for making windows float on the frontmost layer.

On Linux, I use GNOME. I have thought about switching to other window managers like AwesomeWM, or even something like StumpWM. One feature that the less “user-friendly” window managers have that I like is the ability to tile, move, resize and organise windows using the keyboard. Window management via mouse/trackpad is fiddly and quite annoying. I wanted something like that for OS X. Google brought up this blog post by Jon Smajda. He’d done something with an app called Spark and a whole ton of AppleScripts being bound to different window management commands. The word AppleScript shone out like a warning. He also pointed to a commercial app called MercuryMover. I tried it and fell in love. I can shunt my windows around and resize them, undo resizes, store particular window locations that I like. I downloaded, tried it for about half an hour and bought it.

Another thing I find with OS X is that I just don’t use the Finder much. I find I navigate using the Terminal much easier. It’s got Quick Look for the files I care about most: less and vim. If I do want to Quick Look something, I can open . on it and look at it there. But bash feels a lot less clunky and slow than the OS X finder. And the keybindings are better. Bash’s tab-completion beats the hell out of fiddly tree-level fold-downs (the triangle to the left of folders in List View on OS X, the little square with a plus symbol on Windows). I find that when I do use the Finder, I want the List View, but that SFTP volumes I mount using ExpanDrive take a long time to Calculate All Sizes (surely, pass an ls or du command to the remote box. I guess, if the files I spent most of my time curating weren’t plain text or some variant thereof (code, markup etc.), the Finder would be a lot more useful. But the command line kicks it’s ass.

I haven’t yet tried out Vi Input Manager, which gives one a bunch of vi commands in any standard Cocoa text field. I would do it if I used more Cocoa text fields. If I used Xcode, this would be a good thing to have.

Now, as for web forms, It’s All Text is a highly useful plugin for Firefox that lets you basically pass text from any textarea in Firefox over to your editor of choice. After you install MacVim, you need to find the mvim script. If you can’t find it, I’ve put a copy up on Gist. I keep a copy in ~/bin/mvim and then point to it from there in It’s All Text. Works great. Takes a few minutes to setup. You also then need to set a hot-key in It’s All Text. That way you navigate to a field on a webpage, hit your hot-key (I set Shift+Cmd+Ctrl+E (I’ll explain why shortly), have MacVim pop up, edit away to your hearts content, and then :wq. Boom. It’s then back in the text field. It’s good to be aware of how It’s All Text operates. When you click an edit button, it takes the contents of the field and puts them in a temporary file in your ~/Library/Application Support/Firefox/Profiles/.*/itsalltext/ folder. It clears them at the end of the session. The file name is based on the domain of the site. So, if you edit en.wikipedia.org, It’s All Text creates a filename of en.wikipedia.org.[10-character alphanumeric ID].txt. Now, if Firefox crashes, be sure to remember that the text you edited may still be in the itsalltext/ folder in your Firefox profile directory. But there’s more. Vim has syntax highlighting modes. If you edit wikis or post on forums or blogs or anything where there is some kind of custom syntax, you can use the fact that the domain is in the filename to set the filetype.

This isn’t just for Firefox. MacVim allows you to install a plugin for Safari that lets you edit any textarea with a similar keystroke in Safari. There’s always been a promise floating about that such a thing would work for TextMate too. If you open up MacVim and go into the Preferences, there’s an Integration button which lets you install an “Edit in External Editor” command. It works for more than just MacVim. You can choose which editor you want to use. But, of course, you’d want to use MacVim. ;) The two main apps it adds the features to are Safari and Mail.app. I don’t use Mail.app so I can’t tell you whether it works. But Safari sure does work. Here, you can either go to the Edit menu when in a textarea or you can hit Shift+Control+Cmd+E. Yes, the command is a bit fiddly and Emacsy. I’d prefer something like :edit myself, but oh well. I’d rather it worked consistently in Firefox and Safari. That’s why I’ve set Firefox’s It’s All Text to use the same control as the External Editor plugin for Safari does. Safari (and, I guess, Mail.app and other places where one can do external editing from) use the window title. The file gets stored in /var/folders/.*/.*/-Tmp-/[page title].safari. Yes, it’s the page title with .safari as the extension. Investigate for yourself what it is for Mail.app if you want.

Now, with these two rules in place: domain.id.txt and title.safari, we can edit our filetype.vim settings to match specific sites that one might edit. I’ve put up an example rule on Gist showing how one might create a filetypedetect augroup rule of autocmd’s in filetype.vim to detect Wikipedia edits. The rule on line 2 is detecting filenames that match *.wikipedia.org.* filenames and then setting the filetypes to Wikipedia, which is the name of the MediaWiki filetype in Vim (and which you can get Wikipedia.vim and load it into your ~/.vim/syntax directory). Line 2 is picking up from It’s All Text, Line 3 is picking up from Safari Edit in External Editor command. You should, of course, keep your filetype.vim (all of your ~/.vim in fact) backed up, version controlled and synched up between any machines you use. You may want to write a script that tarballs it too and pokes it into your inbox or onto a USB device you carry around with you (hint: phones, cameras, iPods etc.) so you can always get into the Vim thing wherever you are.

If you have to use any other of the never-ending shitty wiki syntaxes (see my impassioned plea to stop creating so many new bloody syntaxes that abstract HTML), Google for them followed by vim. I’m sure there’s someone out there who has felt your pain and created a syntax mode. Markdown has one, as does Textile, SocialText, Haml, MoinMoin, FitNesse, FlexWiki, Kwiki, Confluence, DokuWiki, Creole and Trac.Whoever thought that all these different syntaxes were a good idea? If that’s you, or you have created your own wiki syntax, do click here.

This little bevy of links and tips, bound together with a few choice obscenities, should help you ensure that you can get by on a Mac for everyday work in either English or your language of choice without having to drag lumps of plastic around your desk. Of course, you’ll still have to use the cursed thing occasionally. But my Amstrad CPC 6128 had it about right: you kept the mouse in the drawer until you needed to use the graphics application. Then you pull it out, plug it in the joystick port and do so. Mousing or trackpadding is still important: there’s no way you can do graphical work without it. But for those of us who don’t do visual stuff, there’s good reason to beef up the keyboard side.

Green Party want bullshit, magic and farce to be available free on the NHS 2009-06-02T14:47:34ZPermalink

Dave Cross provides a very good reason not to vote for the Green Party, namely their support for so-called alternative medicine (SCAM) - they don’t want regulation of SCAM providers, and they want the NHS to pay for SCAM treatments. I completely agree. I’m definitely not voting Green. Which narrows my choice down to (in the South-East region) the Big Three or a nutcase right-wing wackaloon party like BNP or UKIP (or whatever the Vertiarse people are reincarnated as this week). I guess I’ll be voting Lib Dem then.

Links from del.icio.us

Comments
blog comments powered by Disqus


Tom Morris 9f4907d871750fd4c9b9bad7086701b51d6abd10 bd9f81a05283ed85e699175ed057b4a497f20b77 802c68123e12bf69d99a25a87cef360f18813fe4
Currently in: East Sussex, England
Usually in: East Sussex, United Kingdom
AIM: tommorris
YIM: tom.morris

I am a , an , like to code in and (and Java, but let’s not talk about that), and noodle about with and the .

I have an MA in philosophy from Heythrop College, University of London. My philosophical interests are in analytic metaphysics, ontology, modality, the work of , , , and . I have a strange, unfulfilled interest in . I’ve been influenced by Gadamer, by , , and .

Musically, I like jazz fusion, soul and P-Funk. My musical nirvana would be a mixture of Beethoven, Miles Davis and George Clinton topped with a side-serving of Erykah, Jill and Angie.

I also write for the Citizendium, an online encyclopedia project. If you know about stuff, you should join in. I occasionally produce audio recordings for The Pod Delusion.

Elsewhere:

  • GPG Key
  • del.icio.us
  • Flickr
  • Twitter
  • Jaiku
  • LinkedIn
  • ma.gnolia
  • blip.tv
  • upcoming.org
  • MetaFilter
  • LiveJournal
  • CiteULike
  • Technorati Profile

RSS Feed Subscribe:

RDF

« June 2009 »
SuMoTuWeThFrSa
 123456
78910111213
14151617181920
21222324252627
282930 

View in month context

On this day in: 2006 2007