VIM Tricks
(Krish Roskin – June 2003)
A lot of you use R and some of you write R code with vim. Currently, if you edit a .r file in vim, it thinks you're editing a REXX program. Here's how to change that
1. create a ~/.vim directory, if you don't already have one.
2. add the three lines:
"Detect R (the statistical package) files with .r extension
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.r setfiletype r
augroup END
to the top of ~/.vim/filetype.vim, create the file if necessary.
**You can also copy ~krish/.vim/filetype.vim to ~/.vim/.
Next time you open a .r file in vim, it will know that it's an R file.
There is a vim package for switching from a .c file to its corresponding .h file and in reverse, it also works for C++. I've modified it to work with Jim's source tree (i.e. where the .h files are in ../inc/ and .c files are in ../lib/).
Copy ~krish/.vim/plugin/a.vim to ~/.vim/plugin/a.vim. Now :A will switch to the .h or .c file corresponding to the current file. :AS will open the .h or .c file corresponding to the current file in a new window.