Tuesday, 2 March 2010
Last week I mentioned that in the course of switching from Notepad++ to Vim I lost the ability to run Stata do-files or selected lines from within the text editor, and I asked my readers for help if they had a solution. What do you know, one of them did, and wrote to me all the way from China with a Vim script that solves both problems. I won't repeat it here because it is almost identical to this one. Clearly, I need to remember to always look into the Statalist archive first.
There was one line that I had to change, where Vim is ordered to clean up after itself. Every time you runDoLines() you produce a bunch of .tmp.do files in your %temp% directory, which Vim knows as $TEMP. Though this
au VimLeave * exe "!del -y " temp
should have deleted them, on my computer it did not. This one did:
au VimLeave * silent exe '!del /Q "'.$TEMP.'\*.tmp.do"'
Another thing I tinkered with was the way Vim handles these backup files that end in a tilde. You can disable them entirely, by adding
set nobackup nowritebackup
to _vimrc as explained here. You can also have Vim keep them somewhere you can delete them explicitly, in bulk, as explained here. Finally, you can use a combination of both: you save backup files while Vim is working, but then you make it delete them all when it starts next time. That is explained here. I went with it, so after I created a temp folder in $VIMRUNTIME, I added this to my _vimrc file:
" Keeps backups in $VIMRUNTIME\temp folder, cleans them up
silent execute '!mkdir "'.$VIMRUNTIME.'\temp"'
silent execute '!del /Q "'.$VIMRUNTIME.'\temp\*~"'
set backupdir=$VIMRUNTIME\\temp\\
set directory=$VIMRUNTIME\\temp\\
In the process of figuring this out, I also discovered that there's a quick way to clean up %temp% thoroughly, as shown here. Good to know. One of these days I might add that to _vimrc too. Now I'm on a roll.

Tags: text editors, Vim
Posted in Stata | No Comments »
Sunday, 28 February 2010
When it comes to defining local macros in a different place from where you use them, you have two options: a do-file you include as needed or an r-class program that you call as needed. I talked about it here and said that a program is a better choice, without any evidence to back up [...]
Posted in Stata | 2 Comments »
Friday, 26 February 2010
I was looking for an excuse to try something new and I decided to pick on one Notepad++ shortcoming that was handy: the Stata syntax highlighting gets utterly mangled after compound quotes -- `"`like so'"' -- which do sometimes arise, usually in the process of file open/file write.
Vim does not get confused by compound quotes and [...]
Tags: syntax, text editors, Vim
Posted in Stata | No Comments »
Tuesday, 23 February 2010
The other day I wrote a program that needed to call a file as an argument -- with the full file path. My first pass at it was to capture the argument as usual, with say args input_file. But that would not have worked with file paths that have spaces in them. What might have [...]
Tags: syntax
Posted in Stata | 1 Comment »
Thursday, 18 February 2010
In The Stata Journal Vol. 9, No. 3, 2009 there's a Stata tip (# 77) on re-using macros in multiple do-files, by Jeph Herrin. His solution is to define any local macros in a separate do-file, say locals.do. You can call that do-file with the include command at the top of any do-file that might [...]
Tags: include, local macros, program
Posted in Stata | 3 Comments »
Friday, 15 January 2010
This is a revision of my earlier assessment that tsclient is so slow it's useless. The thing came back to life somehow and it looks like it's thanks to either Dell or Microsoft. I upgraded to Karmic over Christmas with some hope that it might fix tsclient, but nothing changed. Then the server in Atlanta [...]
Posted in Ubuntu | No Comments »
Thursday, 7 January 2010
On December 11, 2009 portaudit turned up a problem in a package called libtool-2.2.6a_1. So, as usual, I figured I'd go to whatever port that is, and do a portupgrade. Unfortunately, whereis libtool turned up no such port. What's the rookie accidental admin to do?
Take good notes, for one. While dabbling in an unrelated topic -- [...]
Posted in FreeBSD | No Comments »
Wednesday, 2 December 2009
My migration to Ubuntu has just hit a major snag.
I spend most of my work day connected to a Windows Server 2003 machine sitting in a colocation facility in Atlanta. I write and run Stata code on it, use the MS Office products, a bit of Gmail -- the usual stuff. As it turns out, [...]
Posted in Ubuntu | No Comments »
Thursday, 12 November 2009
One drawback of a system that's giving you very little trouble is that between bouts of fixing whatever does occasionally go wrong you forget what you're supposed to do. We should all be this lucky, but it's still an annoyance.
FreeBSD, for example, will sometimes turn up a damaged package or two in response to #portaudit. [...]
Tags: portaudit, portupgrade
Posted in FreeBSD | No Comments »
Friday, 30 October 2009
The books I'm reading these days come with examples of code, saved on associated web sites. Sometimes that code is neatly packaged into a zip archive or tarball, with every piece of code sitting in a directory named after the chapter it was referenced in. But other times these web sites have the code sitting [...]
Posted in Cygwin, FreeBSD, Ubuntu | No Comments »