An open API service indexing awesome lists of open source software.

https://github.com/zoubin/vim-git

Tricks for using git in vim
https://github.com/zoubin/vim-git

Last synced: 5 months ago
JSON representation

Tricks for using git in vim

Awesome Lists containing this project

README

          

vim-git
=======

Tricks for using git in vim.

## Git Blame
Mapping should be completed in vimrc, like:

```vim
noremap g :call git#BlameRange()

```

Suppose `` is `\` (the default), then,
* In normal mode: type `\g`, and you are blaming the current line
* In visual mode: type `\g`, and you are blaming the visual block

## Git Grep
Mapping should be completed in vimrc, like:

```vim
nnoremap K :call git#GrepCursorWord()
vnoremap K y:call git#GrepText(getreg('"'))
nnoremap ^F

```

Then,
* In normal mode: type `K`, and you are git greping the word under the cursor
* In visual mode: type `K`, and you are git greping the visual text

In either mode, results are shown in a split window.
Move to any line, and type `CTRL-T`, and a new split window will be opened containing the regarding file. Also, the cursor will be positioned at the regarding line.

## Usage
After installation, finish the mapping in vimrc, like:

```vim
" for git blame
noremap g :call git#BlameRange()

" In visual mode, git grep the selection text
vnoremap K y:call git#GrepText(getreg('"'))
" In normal mode, git grep the word under the cursor
nnoremap K :call git#GrepCursorWord()
" Open in a new window. :h CTRL-W_F for more information
nnoremap ^F

```