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
Now, command :Git works just like "git" from shell except that the
output is displayed in a Vim scratch buffer/window. The buffer will be
wiped out from memory when the window is closed. Filename completion and
piping works. Examples:
:Git diff --cached
:Git help merge
:Git branch | column
(I am aware that there are VCS plugins for Vim. I happen like this
approach better because it works just like the command line Git which
I'm familiar with.)
As a "side effect" this also adds similar :Svn command as well as :Shell
command which can be used to run any shell command and have its output
displayed in a Vim window. Using the first two letters of :Shell is
enough in my system because I don't have other custom commands which
start with letters "Sh".
:Sh ls -l
--
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
[Newbies FAQ] [Kernel List] [Site Home] [Free Online Dating] [Gcc Help] [IETF Annouce] [DCCP] [Netdev] [Networking] [Security] [V4L] [Bugtraq] [Free Online Dating] [Rubini] [Photo] [Yosemite] [MIPS Linux] [ARM Linux] [Linux Security] [Linux RAID] [Linux SCSI] [DDR & Rambus] [Linux Resources]