http://blog.tplus1.com/index.php/2007/08/29/how-to-use-vimdiff-as-the-subversion-diff-tool/ gives a simple way to use vim for svn diff. Unfortunately, vim doesn't understand the left-hand-side filetype so, there's no syntax highlighting. What's the simplest/best way of solving this?
a quick search for "vim set filetype" gave me this link, which shows you how to make this work "forever" by changing .vimrc a bit. If you're just stuck with a file for once, and you know its "correct" filetype, you can try (from the left hand side file):
:set filetype=XXX
where XXX is the appropriate format (e.g. python, c, etc)
a look at
:help filteype
might also help a bit
it's as if vimdiff was invoked with the following command
vimdiff .svn/text-base/foo.php.svn-base foo.php
so you see, vim fails to recognize the filetype of the lhs file as php because of the different extension.
No proper solution is known to me. I use something like this in different scenario, but that only fixes the syntax highlighting:
au BufReadPost *.php.svn-base set syntax=php
You can also try that:
au FileType *.php.svn-base set filetype=php
but I can't test that as I have :filetype
disabled. That should overwrite file type detection for the .php.svn-base
files and map it to the desired php
. I have checked that it overrides the 'filetype'
and 'syntax'
: :set filetype?
and :set syntax?
produce expected output.
When I use restructured text within a file with the .txt suffix, by default, vim won't highlight the text. So I put this at the top of my file:
.. vim: set filetype=rst :
And then vim does all the cute syntax highlighting.
Try adding a modeline to the first line of your files and then see if vim does what you want when you do a diff.
Incidentally, that's my blog you linked to! Can I get a prize?
Add the following code to ~/.vim/filetype.vim
:
" only load filetypes once if exists("did_load_filetypes") finish endif augroup filetypedetect " when BufRead or BufNewFile event is triggered, pop off the .svn-base extension and " manually restart filetype autocommands autocmd! BufRead *.svn-base execute 'doautocmd filetypedetect BufRead ' . expand('%:r') autocmd! BufNewFile *.svn-base execute 'doautocmd filetypedetect BufNewFile ' . expand('%:r') augroup END
As the comments state, this code will pick up .svn-base
files and try to figure out what the filetype would be without that extension on the end.
:help new-filetype :help :doautocmd :help expand()