Launch Vim from any text widget

Jan 22, '02 12:37:37AM

Contributed by: logan

Stuff you'll need for this hint:

Now, put them together. TextExtras allows you to run the text in an entry box through a pipe and replace the text with the pipe's output. We're going to set up a pipe for Vim. The tricky part is that Vim, being an editor, can't just read text from stdin, edit it, and write it back to stdout; it uses stdout for the editing interface. So we have to help it out a bit, and this is where vimwrapper.pl comes in.

Read the rest of the article for the details on this trick...

You'll need to edit vimwrapper.pl a little bit, to tell it where your copy of Vim is installed. You might also want to add options to its list. At any rate, modify it as needed and drop it somewhere useful; I put mine in ~/bin/.

Okay, now test it... the way it should work is when you pipe text into vimwrapper.pl on stdin, it should launch Vim with that text in the buffer. You edit the buffer, and when you quit Vim your modified text is dumped back to stdout. So you can test it with "echo 'some junk' | ~/bin/vimwrapper.pl".

If all goes according to plan, you'll want to define a 'User Pipe' for vimwrapper.pl in TextExtras. That TEUserPipes.plist file does this: it both defines the pipe to ~/bin/vimwrapper.pl and binds it to the "CMD-\" keystroke. Move that file to ~/.TEUserpipes.plist. You should be good to go at this point. Fire up TextEdit and give it a go.

This trick-- with a little modification of the supplied script -- should actually work for any editor you might wish to use (even emacs, I suppose).

NB: TextExtras does not get loaded in Mozilla. I don't know why, exactly.

[Editor's note: I'll display my complete lack of knowledge here by stating that I have close to no idea what this hint does, but boy, it sounds cool! Obviously, I have not tried this hint on my system ;-)!]

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020122003737260