diff options
| author | Franck Cuny <franckcuny@gmail.com> | 2016-07-02 20:06:31 -0700 |
|---|---|---|
| committer | Franck Cuny <franckcuny@gmail.com> | 2016-07-02 20:06:31 -0700 |
| commit | 4b8e43f75b394a4e6169884fbfb4c606865c6a22 (patch) | |
| tree | 48cae6b8e8f9b68cae29676d8a15cb3ddbfcccda /content/post/2008-12-05-vim-and-git.md | |
| parent | Stop using Jekyll. (diff) | |
| download | lumberjaph-4b8e43f75b394a4e6169884fbfb4c606865c6a22.tar.gz | |
Import migration from Jekyll to Hugo.
All the posts were converted, and the layout is created. This looks like
it works just fine.
Diffstat (limited to '')
| -rw-r--r-- | content/post/2008-12-05-vim-and-git.md | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/content/post/2008-12-05-vim-and-git.md b/content/post/2008-12-05-vim-and-git.md new file mode 100644 index 0000000..ac09231 --- /dev/null +++ b/content/post/2008-12-05-vim-and-git.md @@ -0,0 +1,43 @@ +--- +date: 2008-12-05T00:00:00Z +summary: In which I share another snippet of code for vim. +title: vim and git +--- + +idea from [Ovid's journal](http://use.perl.org/use.perl.org/_Ovid/journal/37966.html) (ovid is full of really good ideas for vim): + +to get a quick git diff in my vim session, put this in your .vimrc + +```vim +map ,gh :call SourceDiff() " gh for git history + +function! SourceDiff() + let filename = bufname("%") + let command = 'git log -5 --pretty=format:"%h - (%ar) %an - %s" "'.filename.'"' + let result = split( system(command), "\n" ) + + if empty(result) + echomsg("No past revisions for " . filename) + return + endif + + " get the list of files + let revision = PickFromList('revision', result) + + if strlen(revision) + let items = split(revision, " ") + execute '!git diff ' . items[0] . ' -- "' . filename .'" | less' + endif +endfunction +``` + +the output looks like this: + + Choose a revision: + 1: ea0bb4d - (3 days ago) franck cuny - fix new_freq + 2: a896ac7 - (5 weeks ago) franck cuny - fix typo + 3: c9bc5fd - (5 weeks ago) franck cuny - update test + 4: e9de4be - (5 weeks ago) franck cuny - change the way we rewrite and check an existing url + 5: 3df1fd6 - (7 weeks ago) franck cuny - put id category + +You choose the revision you want to check the diff against, and you got a (colorless) diff in your vim buffer. |
