Re: Extremely simple Vim interface for Git

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

 



> 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..
--
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