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: Mon, 8 Sep 2008 08:47:41 +1000 [thread overview]
Message-ID: <d2e97e800809071547m2b2e0f82ycc370f048d826b2d@mail.gmail.com> (raw)
In-Reply-To: <20080907131356.GC3387@mithlond.arda.local>
>> If you alter the RunShellCommand() function to the following -
>
>> if stridx(a:cmdline, "diff") > 0
>> set filetype=diff
>> endif
>
>> Then Vim will apply diff syntax highlighting to the scratch buffer
>> when a "diff" command is executed.
>
> Good idea. I implemented the same thing this way:
>
> if match(a:cmdline,'\v^(git|hg|svn|bzr) diff') >= 0
> setlocal filetype=diff
> endif
Vim 7.2 provides a better alternative. If the command is specifically
'git' then setting the filetype to 'git' also provides the correct
syntax highlighting.
For example,
if v:version >= 702
if stridx(a:cmdline, "git") == 0
setlocal filetype=git
endif
endif
Syntax highlighting is displayed correctly for several commands including:
:Git diff
:Git show
:Git log
And possibly others. If Vim (7.2) is your default editor when
performing a "git commit" then there is also a new built in Vim
command -
:DiffGitCached
This opens a preview window with the contents of "git diff --cached".
The :DiffGitCached command is only available when filetype=gitcommit.
Perhaps some of these ideas should be added to the Vim wiki...
http://vim.wikia.com/wiki/Display_shell_commands%27_output_on_Vim_window
next prev parent reply other threads:[~2008-09-07 22:50 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
2008-09-07 13:13 ` Teemu Likonen
2008-09-07 17:46 ` Teemu Likonen
2008-09-07 22:47 ` Michael Wookey [this message]
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=d2e97e800809071547m2b2e0f82ycc370f048d826b2d@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).