Re: Extremely simple Vim interface for Git

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux