Tip #815: Getting vim to work with cvs commit
tip karma |
Rating -13/22, Viewed by 1489
|
Read and edit this tip on the
Vim tip wiki.
The wiki may have a more recent version of this tip.
created: |
|
November 4, 2004 15:45 |
|
complexity: |
|
basic |
author: |
|
dwight |
|
as of Vim: |
|
6.0 |
One thing which I find annoying about CVS is doing a commit. You end up with a screen with a bunch of lines starting with "CVS: ", and you need to strip these strings out if you want to finish doing the `cvs commit`.
Here's some sample output from a `cvs commit`:
CVS: ----------------------------------------------------------------------
CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
CVS:
CVS: Committing in .
CVS:
CVS: Modified Files:
CVS: foo.c
CVS: Added Files:
CVS: bar.c
CVS: ----------------------------------------------------------------------
Normally, you can just type the following:
:1,$s/^CVS: //
However, even this is too annoying. I'd rather have a single button which did this.
Putting the following in your ~.vimrc file acomplishes this task:
:map <F1> :1,$s/^CVS: //p<CR><CR>
This maps the F1 key to doing the desired action. So now all you have to do is a `cvs commit`, hit <F1> and viola! You can now just start typing in what you changed for the log.
This is certainly a simple, stupid map trick. But it is a superb example IMHO of applying the map command in an everyday, useful fashion. And this trick can be applied to other Source Code Control mechanisms as well.
-dwight-
[email protected]
<< Use cygwin shell |
JAVH: Just another VIM Hacker >>
Additional Notes
Anonymous,
November 4, 2004 16:07
|
Umm... am I misreading this or what but the second line of the text given by CVS says:
"CVS: Enter Log. Lines beginning with `CVS:' are removed automatically "
You just write your log message and do :wq and you're done. No need for anything else.
|
[email protected],
November 5, 2004 0:16
|
Lines starting with 'CVS: ' are removed,
but if no additional Text is entered, another confirmation step is required.
Another note for gvim as CVSEDITOR users: use option -f to avoid background starting, thus cvs will wait for gvim to finish.
|
Anonymous,
November 5, 2004 7:06
|
Yes, you can just throw away the rest of the lines if you like. But I like preserving the messages; particulary the "Modified Files" and "Added Files" to help keep track of things.
-dwight-
|
Anonymous,
November 7, 2004 13:11
|
CVS requires a comment so there is some record of why/what was changed. Usually it is used for placing a summary of the changes being commited. The requirement for a comment is for better documentation of code. Just enter a couple words like "new function myfunc()" or even something less useful. Anyone else that looks at the CVS data or even you after many months/years will be happy for more information rather than less. :)
|
Anonymous,
November 30, 2004 17:28
|
dwight said:
...Yes, you can just throw away the rest of the lines if you like. But I like preserving the messages; particulary the "Modified Files" and "Added Files" to help keep track of things.
so I said:
But CVS already does that for you internally (that's it's job) - you don't need to keep this same info in the actual commit message.
You're supposed to write there (in English) what you did, not which files you did it to. That's the CVS's job.
... and on a side note, switch to SVN already :)
|
|