0

Possible Duplicate:
Can I make vim do syntax highlighting on C++ headers that don't have extensions?

I'm using the R.vim script to source my .R files from vim to R-GUI using Applescript. However, this will only work if the file I open in vim has the .R extension.

When I open MacVim, the buffer has no extension, so I have to save the file as temp.R before I can use the shortcuts provided by R-vim for sourcing to R-GUI. I am predominantly an R-user, so I would like to make it so that, by default, when MacVim opens, it assumes the filetype is R and I can begin sourcing the buffer immediately.

Is there a way to automatically tell the buffer the filetype is R so that I don't need to write my buffer before sourcing to R?

Community
  • 1
  • 1
Christopher Aden
  • 757
  • 6
  • 21
  • I was hoping for a solution that didn't involve typing something into and saving the file before it would allow highlighting and sourcing. Otherwise, I might as well just save the file as foo.R and avoid this problem entirely. – Christopher Aden May 15 '12 at 01:04
  • Try the Vim-R-Plugin http://www.vim.org/scripts/script.php?script_id=2628 – Idr May 15 '12 at 01:35

1 Answers1

2

You can set the filetype of a buffer using :set filetype=R or short :set ft=R

dwalter
  • 7,258
  • 1
  • 32
  • 34
  • Is there a way to add that to my vimrc to make all new buffers open as filetype=R? – Christopher Aden May 15 '12 at 17:46
  • 1
    you can add `autocmd BufEnter * if &filetype == "" | setlocal ft=R | endif` to your vimrc. This will set the filetype for all unknown files to `R`. – dwalter May 15 '12 at 21:46