Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using vim as a git commit message writer, is it possible to autocomplete modified function names?

I find myself often repeating the names of the functions I've edited, in the commit message, and it'd be nice to have autocompletion for the functions I've just changed when writing the commit messasges.

Is it possible to get vim to somehow search through the current commited files and grab the function names, or better yet, only the modified ones?

I'm using gVim7.3 and C#, if that's at all relevant.

like image 979
TankorSmash Avatar asked Dec 06 '22 09:12

TankorSmash


1 Answers

If you use the -v option to git commit that will cause git to place the diff of what you're committing in the file used to create the commit message. With most languages the headers of hunks within that diff will indicate the name of the function being modified. This will make the names of modified functions available for completing with Ctrl+N or Ctrl+P

To simplify this I long ago did

git config --global alias.ci 'commit -v'

And always use git ci rather than git commit.

Newer versions of git support configuration to turn this on for all commits.

git config --global commit.verbose true
like image 185
qqx Avatar answered Jan 14 '23 13:01

qqx