Little 418

The resulting entity body MAY be short and stout

Moving around the filesystem in vim

I’m a bit of a vim junkie. Many years ago I was forced to use it in my CS101 class because it was the only text editor available. The first month was pretty rough, but that was probably because we were writing Java without an IDE. Anyway, once I got the hang of it, I was hooked.

I never studied how to be effective with vim, but instead I’ve added a trick here or there over the years. Even 16 years later, I’m still adding tricks to my vim quiver.

My latest new trick is navigating around the file system inside a vim buffer. It feels a bit awkward at the first, but once you get the hang of it, it’s a lot faster than using the OS GUI to find files.

Moving between files

I used open a new vim process from bash, make edits, :wq, find the next file, and repeat. It turns out there’s been a better way the whole time – the edit command: :e.

You give it a file name, and vim switches the buffer that file in the current directory. If the file does not exist, vim will create a new file when you write it.

:e dinosaurs-are-awesome.txt

You can also give it a path to edit a file somewhere else.

:e /secret-stuff/embarassing-fanfics/

And use escape sequences to cope with filenames that contain spaces.

:e ~/Downloads/ProposalDeck\ finalVersion\ Copy\ 2.doc

If you made some edits in your current buffer, but want to ditch those changes, add a ! just like you do in a :q!, a.k.a. the only vi command that emacs users know.


Oh, and if you’re not using tab completion here, you’re missing out. Tab completion works for filenames and directories. Consider it an added incentive to start your commonly edited files and git repos with distinct letters.

Moving between directories

If you know where you want to go, use the :cd command. If you kind of know what you want, use :cd and abuse tab completion.

:cd /tmp

If you have only a vague idea of what you want, you can navigate around directories with the :e command.

:e .

Which yields a screen like this:

Pressing enter opens whatever is under the cursor.

You can move around with arrow keys, but that’d be a sin against vim. Instead, use your vi file navigation-fu. Most of it works, including moving to line number (:42), regex searches (/[hHarry]), and even macros (qa↑↑↓↓←→←→q).

Setting a different default directory

By default vim will start it’s directory context in your home directory. This is a reasonable default, but if you want something different, just add a :cd command to your .vimrc.

:cd ~/dinosaur-fanfics/


So yeah, so that’s how you can move around in vim. It’s also a core feature that I somehow avoided for 16 years.

vim users: Are you still picking things up? If so, tell me about something you picked up recently :)

Non-vim users: 1) why are you still reading? 2) How do you tolerate other text editing interfaces?

Catching up on Data Structures

I’m pretending to be a Computer Science professor this semester at Xavier of Louisiana. My office hours are always busy, and I spend much of them teaching students the mysterious art of the tech interview: the practice of implementing clever algorithms and data structures on a single whiteboard panel.

But… my last formal training in the topic was more than a decade ago, which is a long time in CompSci land. New techniques have been invented, and others have entered common usage. Many of them are compact enough for whiteboard representations, and current info is often worth a mention in an interview, even if you solve problems with more traditional techniques.

YouTube and MIT Open Courseware to the rescue! I’ve been watching Erik Demaine’s awesome lecture, and feel almost caught up!

Change Preorder Text on Storenvy

Storenvy is a great option if you want a free online store.
We’ve been using it for our geeky fashion business, Happy Nerdcore, for the last several months. It works great, but we had to do a little hax0ring to make it fit out needs.

Storenvy has a cool ‘preorder’ flag that you can set on inventory. It communicates to the customer that it will take a little longer to ship. We wanted to use this flag to indicate which items in our store were made to order, and hence would take longer to deliver.

Luckily Storenvy lets you add your own CSS to your store, so we hacked in our own text.

  • Go to Admin Panel -> Storefront -> Theme -> CSS Mode
  • Tweak this CSS to match your color scheme and desired text
/* Update category pages */
.product .preorder.flag.status {
  background-color: #FFF; 
  color: #FFF; /* match colors to hide old text */
  width: 130px; /* adjust width to fit new text */

.product .preorder.flag.status:after {
  content: "Made to order"; /* new text */
  position: absolute;
  top: 8px;
  left: 8px;
  right: 0;
  bottom: 0;
  color: #000; /* new text color */

/* Update product detail pages */
#product .preorder.status {
  background-color: #FFF;
  color: #FFF; /* match colors to hide old text */
  position: relative;
#product .preorder.status:after {
  content: "Made to order"; /* new text */
  position: absolute;
  top: 8px;
  left: 8px;
  right: 0;
  bottom: 0;
  color: #000; /* new text color */
  • Save, reload, and profit!