I switched to Vim
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 it comes with Stata syntax highlighting out of the box. Integrating it with Stata is not hard at all, either. There are some general directions by Nick Cox here, but on my Windows XP machine I just had to do two things.
First, I had to edit the PERSONAL/e/editors.ado file to make Vim replace Notepad++ entry in the Editors... sub-menu of the User menu:
program define editors
version 10
window menu append submenu "stUser" "Editors"
window menu append item "Editors" "Vim" "winexec gvim.exe"
end
Next, I wrote a PERSONAL/v/vim.ado file like so:
program vim
version 10
syntax anything
winexec gvim.exe `anything'
end
This is based on Nick Cox's recipe, slightly altered so you can launch Vim from the Stata command line to edit an existing do-file that say has spaces in it, as in vim "my dofile.do". There's a little more on this "syntax anything" solution in my previous Stata post.
One thing I did give up -- for now -- is the ability to launch a Stata instance from within Vim after I'm done editing a do-file, either for running the entire do-file or some select lines, the way I used to be able to do in Notepad++. There's got to be a way for that, though. If you know it, please drop me a line.
That said, I'd never knock Notepad++. It is still a fine text editor that has served me well. The people at Mather Economics, who adopted it a while back at my instigation, are sticking with it -- and I recommend it to anybody who does not insist on a modal editor.
No. 1 — June 19th, 2010 at 5:48 pm
i've had similar problems with the syntax highlighting not parsing the escape quotes. i've found that Smultron (Mac only) does it right and in some other editors i can usually trick it into working by using a comment to close what the parser perceives as a hanging quote
No. 2 — July 2nd, 2012 at 12:21 am
I finally found a solution for the stata-withinvim issue.
It's Vim plugin called Conque that let's you open a shell in a vim buffer.
The additional advantage you can also send selected lines of code from the adjacent vim buffer directly to the Conque buffer running stata. (However doesn't work under windows as there is no console version of Stata here.)
But I got vim working with rundolines.exe. If you need the vimrc part for that just send me an email.
No. 3 — July 2nd, 2012 at 10:29 am
Hi Felix,
Thank you for this. I'm on a Mac now, so I had to brew my own equivalents to rundo.exe and rundolines.exe. I managed it with help from the Statalist. See here.