Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.