2

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?

Nemoden
  • 2,547

2 Answers2

2

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()
garyjohn
  • 36,494
0

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
------------------------------------------------------------------------
% 
mkomitee
  • 596