rcs diff/ au BufRead

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

rcs diff/ au BufRead

William Pursell
 
2 totally unrelated questions:

1) I've recently started putting lines in my files which look like:
/* vim-keyword cType foo baz */
I've set up an autocommand that searches for those lines on BufRead, and
then makes the trailing words part of the syntax group (so in this case
"foo" and "baz" become cTypes.)  It works just fine, and I haven't
noticed that it is too slow, but I'm wondering if there is a cleaner way
to get this functionality.  However, I haven't thought of a good way to
tie buffers together in the sense that I would really like to be able to
put the "vim-keyword" line in the header file only and then have the
syntax groups persist into the c files.  (ie foo.h contains the line,
foo.c does not but does contain "#include <foo.h>", and editing foo.c
will make the syntax mapping.)  I'm definitely worried about the speed
of startup if I search through every included file, and I'd be happy
with only getting the highlighting in foo.c if I have foo.h open in the
same session.  Any thoughts?

2) There's been a lot of traffic on vimdiff lately, and I'm starting to
use it but am fairly new to it.  Is there any way to make it look into
your RCS files for you?   For example, can I execute "vimdiff foo.c
-r1.3" (or something similar) and get a buffer with the current copy of
foo.c and revision 1.3 from the local foo.c,v file?
Reply | Threaded
Open this post in threaded view
|

Re: rcs diff/ au BufRead

Gary Johnson
On 2005-10-17, bill <[hidden email]> wrote:

> 2) There's been a lot of traffic on vimdiff lately, and I'm starting to
> use it but am fairly new to it.  Is there any way to make it look into
> your RCS files for you?   For example, can I execute "vimdiff foo.c
> -r1.3" (or something similar) and get a buffer with the current copy of
> foo.c and revision 1.3 from the local foo.c,v file?

Put this in your ~/.vimrc:

    command -nargs=? RcsDiff vnew | set bt=nofile | exe 'r !co <args> -p #' | 0d_3 | diffthis | wincmd p | diffthis

To diff the current buffer against the latest version of the file,
execute

    :RcsDiff

Or to perform your example command:

    vim -c 'RcsDiff -r1.3' foo.c

HTH,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA
Reply | Threaded
Open this post in threaded view
|

Re: rcs diff/ au BufRead

William Pursell
Gary Johnson wrote:

>On 2005-10-17, bill <[hidden email]> wrote:
>
>  
>
>>2) There's been a lot of traffic on vimdiff lately, and I'm starting to
>>use it but am fairly new to it.  Is there any way to make it look into
>>your RCS files for you?   For example, can I execute "vimdiff foo.c
>>-r1.3" (or something similar) and get a buffer with the current copy of
>>foo.c and revision 1.3 from the local foo.c,v file?
>>    
>>
>
>Put this in your ~/.vimrc:
>
>    command -nargs=? RcsDiff vnew | set bt=nofile | exe 'r !co <args> -p #' | 0d_3 | diffthis | wincmd p | diffthis
>
>To diff the current buffer against the latest version of the file,
>execute
>
>    :RcsDiff
>
>Or to perform your example command:
>
>    vim -c 'RcsDiff -r1.3' foo.c
>
>HTH,
>Gary
>
>  
>
That is brilliant!  Any thoughts about how to reference a ,v file that
may be remote, for example off in a $CVSROOT somewhere?
Reply | Threaded
Open this post in threaded view
|

Re: rcs diff/ au BufRead

Gary Johnson
On 2005-10-18, bill <[hidden email]> wrote:

> Any thoughts about how to reference a ,v file that may be remote,
> for example off in a $CVSROOT somewhere?

I've never used CVS very much, so I don't know how you would do
that.  However, there are a number of scripts at vim.sf.net that do
CVS stuff.  This one,

    cvscommand.vim
    http://vim.sourceforge.net/scripts/script.php?script_id=90

has by far the highest rating and the most downloads, so I'd give it
a try first.

Regards,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA
Reply | Threaded
Open this post in threaded view
|

Re: rcs diff/ au BufRead

adah
In reply to this post by William Pursell
> 2) There's been a lot of traffic on vimdiff lately, and I'm starting
> to use it but am fairly new to it.  Is there any way to make it look
> into your RCS files for you?   For example, can I execute "vimdiff
> foo.c -r1.3" (or something similar) and get a buffer with the current
> copy of foo.c and revision 1.3 from the local foo.c,v file?

I am maintaining cvsmenu.vim, and will definitely recommend you to give
it a try, if you are using CVS or CVSNT:

http://www.vim.org/scripts/script.php?script_id=1245

Generally you open the file first and then do CVS operations.  To do
"cvs diff", you need to use the menu items "CVS - Diff", or shortcut
",cd".  To do "cvs diff -r 1.3", you need "CVS - Extra - Diff to
revision", or ",cxd", and enter "1.3".

Best regards,

Yongwei