More readable code with less typing

Tagged:  •    •    •  

How do you get back into your code after a week of doing something else?

  • Start reading and put comments to what you don't understand.
  • Add the categories you left out last week.

Both tasks involve a lot of typing, but that can be alleviated by using
features of your favorite text editor, vim in my case.

autocmd BufEnter *.st imap <localleader>c <category: ''><ESC>hi
autocmd BufEnter *.st imap <localleader>o <comment: ''><ESC>hi
autocmd BufEnter *.st imap <localleader>i <import: ><ESC>i

These three lines provide some basic templates for adding the usual
pragmas to your Smalltalk code. The are defined as "imap", i.e.
they work in insert mode while entering text. Localleader tends to
be backslash, but can be redefined somehow. Also note, how we're
backing up to continue typing at the correct position.

Working on Iliad code, you're typically going to need a few categories
quite often, say "accessing" and "views". So let's add the following
two autocmds to speed things up even further.

autocmd BufEnter *.st imap <localleader>ca <category: 'accessing'><CR>
autocmd BufEnter *.st imap <localleader>cv <category: 'views'><CR>

Now back to (less) hacking.

User login