Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a plugin for VIM which is basically provides an interface for my SVN (vcscommand.vim). And I've mapped :VCSUpdate and :VCSCommit commands of vcscommand plugin in my .vimrc. Everything is perfect, except one thing:

After you call :VCSCommit you usually write comment like so:

:VCSCommit I've made some minor changes to this file

In our company's deployment system it is not highlighted which file was commited, so we usually write our comments like so:

:VCSCommit I've made some minor changes to file .vimrc

In the deployment system we see all this commits, so we can tell which file is to be uploaded to production server after "Sync" button pressed.

So, I wonder how do I map for :VCSCommit so it would add name of the file as a comment. My mapping so far is:

map <C-q> :VCSCommit

So after Ctrl+Q press, it shows :VCSCommit in the bottom bar, but I'd want to see :VCSCOmmit my_file_name_that_i_m_editing_now.

How do I do that?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

This should do it.

map <C-q> :VCSCommit <C-R>%

For more, see

:help c_CTRL-R

EDIT

To insert just the file name when % contains a path, use this:

map <C-q> :VCSCommit <C-R>=expand("%:p:t")<CR>

The :p expands the preceding file name to include the full path and the :t takes the tail of that path. See

:help expand()
share|improve this answer
    
Helps, but it's a little not what I expected. It inserts the relevant path to file I'm editing from pwd, so it inserts include/somefile.php. How do I get just a somefile.php. I've read the help and tried the alternate filename (#)... still not what I want :( If there is no way to insert filename, I'll go with <C-R>% –  Nemoden May 26 '11 at 2:47
    
@Nemoden: No problem. I've updated the answer. –  garyjohn May 26 '11 at 2:55
    
I wouldn't ever figure it out. Thanks! –  Nemoden May 26 '11 at 3:06
add comment

Just as an fyi, svn log -v will show you what files were modified by a commit, so adding the filename in the commit message shouldn't really be necessary..

First without -v:

% svn log -r2                                      
------------------------------------------------------------------------
r2 | mkomitee | 2011-05-27 08:56:02 -0400 (Fri, 27 May 2011) | 1 line

change
------------------------------------------------------------------------

Now the same revision with -v:

% svn log -vr2                                      
------------------------------------------------------------------------
r2 | mkomitee | 2011-05-27 08:56:02 -0400 (Fri, 27 May 2011) | 1 line
Changed paths:
   M /baz

change
------------------------------------------------------------------------
% 
share|improve this answer
    
It's not about svn (in which I'm experienced and know how to list changes, so your fyi does not advance my knowledge), but about vim (in which I'm not that experienced and need help), so this asnwer does not correspond to what I'm asking for. @garyjohn already provided a decent answer. I would not want to downvote though. –  Nemoden May 27 '11 at 13:30
    
Probably it's my bad - I did not tell that in our deployment system we don't see to which files changed were made, but all we see are just comments to those commits. I will probably make some changes to our system in nearest future like a pop-windows displaying all information about a particular commit, but now I don't have enough time for tweaking internal software... so we still need to include filenate into comments. I know - that sucks... –  Nemoden May 27 '11 at 13:41
    
That's fine. I just question the need to add information to a commit message that's readily available already. My answer would have been better suited as a comment on the question, because it wasn't really an attempt to answer the question asked. –  mkomitee May 29 '11 at 18:00
    
Yep :) That's why I responded a little harshly. I'm sorry if it sounded so (I realized that after rereading my comments now). I really appreciate the community's help though. –  Nemoden May 30 '11 at 5:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.