From: "Michael Wookey" <michaelwookey@gmail.com>
To: "Teemu Likonen" <tlikonen@iki.fi>
Cc: git@vger.kernel.org
Subject: Re: Extremely simple Vim interface for Git
Date: Sun, 7 Sep 2008 20:32:48 +1000 [thread overview]
Message-ID: <d2e97e800809070332t35e4ed46u7af4653ea768b39b@mail.gmail.com> (raw)
In-Reply-To: <20080906193744.GA3122@mithlond.arda.local>
> Here's a very simple idea for using Git from Vim editor. Add these lines
> to your ~/.vimrc file:
>
>
> command! -complete=file -nargs=* Git call s:RunShellCommand('git '.<q-args>)
> command! -complete=file -nargs=* Svn call s:RunShellCommand('svn '.<q-args>)
> command! -complete=file -nargs=+ Shell call s:RunShellCommand(<q-args>)
>
> let $EDITOR = '/usr/bin/gvim --nofork'
>
> function! s:RunShellCommand(cmdline)
> botright new
> setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
> setlocal nowrap
> call setline(1,a:cmdline)
> call setline(2,substitute(a:cmdline,'.','=','g'))
> execute 'silent 2read !'.escape(a:cmdline,'()%#')
> setlocal nomodifiable
> 1
> endfunction
If you alter the RunShellCommand() function to the following -
function! s:RunShellCommand(cmdline)
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
setlocal nowrap
if stridx(a:cmdline, "diff") > 0
set filetype=diff
endif
execute 'silent 0read !'.escape(a:cmdline,'%#')
setlocal nomodifiable
1
endfunction
Then Vim will apply diff syntax highlighting to the scratch buffer
when a "diff" command is executed.
For example:
:Git diff
:Git diff --cached
etc..
next prev parent reply other threads:[~2008-09-07 10:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-06 19:37 Extremely simple Vim interface for Git Teemu Likonen
2008-09-07 10:32 ` Michael Wookey [this message]
2008-09-07 13:13 ` Teemu Likonen
2008-09-07 17:46 ` Teemu Likonen
2008-09-07 22:47 ` Michael Wookey
2008-09-08 5:26 ` Teemu Likonen
2008-09-07 13:23 ` Thomas Adam
2008-09-07 13:59 ` Teemu Likonen
2008-09-07 14:11 ` Thomas Adam
2008-09-08 17:41 ` Bob Hiestand
2008-09-09 6:26 ` "Peter Valdemar Mørch (Lists)"
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d2e97e800809070332t35e4ed46u7af4653ea768b39b@mail.gmail.com \
--to=michaelwookey@gmail.com \
--cc=git@vger.kernel.org \
--cc=tlikonen@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).