Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have the following as part of my Vimperator configuration to use MacVim (gvim) to edit text fields:

editor=/bin/bash -lc "mvim -f \$*" mvim

This works well, but the temporary file it creates has a .tmp extension and I would like to give it a different extension so that I can have Vim associate that with a filetype and thus set up a bunch of options made for editing.

Is there a configuration in Vimperator or Vim that can do this?

share|improve this question
up vote 1 down vote accepted

Well, the question is what extension would you associate it with?

Since it's just a text field, there isn't really any way for any part of the system to know what you intend it to be (that is, what you're editing); is it C code? Is it mediawiki? Is it a facebook comment?, etc.

Given that, I can think of two solutions:

  1. If there's only one filetype you care about for this sort of thing, just tell vim about it: autocmd BufReadPost,FileReadPost *.tmp setl filetype=wibble
  2. If there are lots, make key bindings so you can change easily once you've opened the file; map F1 :setl filetype=wibble

Those would both go in your vimrc.

-Robin

share|improve this answer
    
Thanks...I didn't think of it this way. I was thinking in the manner of quickcursor in which you define the extension of the temp file passed to the editor based on the application it is coming from, so I could just define those with a .md extension and the correct filetype would be set. This is more versatile! – Chris Nov 16 '12 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .