BSD

Vim a la TextMate

Alex Young posted “Vim for TextMate fans” a couple of years back, in which he ponders how to get the best of both worlds:

I’ve used vim a lot over the years, mainly because I spent a long time using Linux and it was there so I used it. The choice was obvious: vim or vi were on almost every machine I had access to, and worked excellently both locally and remotely. Once I’d learnt the basics I was set, I knew enough to get my work done.

Then I found TextMate for Mac OS. The immediacy of TextMate made it easy to get started with, and it has many excellent features. The problem is, I’m not always using a Mac. But you know who’ll follow me around to every platform I use? Good old vim! So I started thinking, how could I make vim feel more like TextMate?

Check out his screencast for more.

A command line ebook reader

I was casting around for a replacement for the excellent Tofu screen text reader for Mac, due to some encoding issues. Always wont to explore the command-line options, I turned first to the ubiquitous less pager, available on pretty much every unix-alike system out there.

The only real drawback to less is its apparent inability to wrap long lines at spaces rather than chopping words in the middle and sans hyphenation. This isn’t a problem on hard-return files like a Project Gutenberg ebook, but makes for difficult reading otherwise. (The opposite is the case for Tofu, which requires a bit of manual column widening to compensate for the hard returns.)

Doing a bit of poking around, I re-discovered the also-ubiquitous fmt command, which does word wrapping to a fare-thee-well, though doesn’t do paging.

Combining the two commands gives the best of both in classic Unix fashion:

fmt 1911EthanFrome.txt | less

You can also use options to enhance the experience. less -m will give you a prompt showing how far along you are in the file; see man less for others.

The pager recognizes vim movement keys, which I love. Plus you can hit the v key at any time to drop into vim, edit the file, and then return to less. Spiffy.

Of course, you could just use vim (or your favorite text editor), but I like the simplicity without the overhead. Unlike other options, less doesn’t read the entire file into memory before displaying it, a definite advantage on big documents.

Another Tip: If you’re in a Mac Terminal window, right click on a word or phrase to search for it in Google or Dictionary.

Bonus tangential tip: if you don’t care about downloading the text files but want to stick to reading Project Gutenberg files in the terminal, why not use lynx or ELinks?

screenshot of terminal window showing lynx web browser viewing the Edith Wharton novel Ethan Frome on Project Gutenberg

Useful Unix, Vim, and Emacs tricks on Slashdot

cartoon of vi man beating up feeble emacs user

A couple of days ago, Slashdot posted a story asking about “(Useful) Stupid Unix Tricks?”:

So the other day I messaged another admin from the console using the regular old ‘write’ command (as I’ve been doing for over 10 years). To my surprise he didn’t know how to respond back to me (he had to call me on the phone) and had never even known you could do that. That got me thinking that there’s probably lots of things like that, and likely things I’ve never heard of. What sorts of things do you take for granted as a natural part of Unix that other people are surprised at?

It’s perhaps unsurprising that there have been over 2200 comments exploring the arcana of the Unix and Unixy command line. A lot of awesome lore to check out.

Yesterday came the next story, “(Useful) Stupid Vim Tricks?”:

I thoroughly enjoyed the recent post about Unix tricks, so I ask Slashdot vim users, what’s out there? :Sex, :b#, marks, ctags. Any tricks worth sharing?

570+ comments later, there’s a lot to check out there as well.

Today’s post was inevitable, “(Stupid) Useful Emacs Tricks?”:

Since the Vi version of this question was both interesting and popular, let’s hear from the other end of the spectrum. What are your favorite tricks, macros, extensions, and techniques for any of the various Emacs? Myself, I like ‘M-x dunnet’ ;-)

200 comments and counting.

One of the most enjoyable parts of the Vim story, apart from the various spiffy command tips and tricks, were links to other sites. Here are a couple, along with a few related others I’ve linked to before.

Raggle and Elinks

Arky over at Playing With Sid posted a few months ago on “Reading RSS/XML feeds in Elinks Line Browser”, which he does by running raggle in server mode, inside a screen session. Then he directs Elinks at that via http://localhost:2222 (the default Raggle web UI port). Clever idea — I expect you could do that over SSH and have Raggle running centrally on a server you could access from wherever.

Advanced Bash Scripting Guide

From Mendel Cooper comes the Advanced Bash Scripting Guide: An in-depth exploration of the art of shell scripting.

This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction … all the while sneaking in little snippets of UNIX® wisdom and lore. It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell scripting techniques. The exercises and heavily-commented examples invite active reader participation, under the premise that the only way to really learn scripting is to write scripts.

This book is suitable for classroom use as a general introduction to programming concepts.

Syndicate content