https://github.com/kana/vim-g
Vim plugin: Misc. utilities for Git
https://github.com/kana/vim-g
vim vim-plugins
Last synced: about 1 year ago
JSON representation
Vim plugin: Misc. utilities for Git
- Host: GitHub
- URL: https://github.com/kana/vim-g
- Owner: kana
- Created: 2013-06-29T05:24:56.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2025-04-10T16:15:28.000Z (about 1 year ago)
- Last Synced: 2025-04-22T19:06:51.954Z (about 1 year ago)
- Topics: vim, vim-plugins
- Language: Vim Script
- Homepage:
- Size: 112 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vim-g [](https://github.com/kana/vim-g/actions/workflows/ci.yml)
This is a Vim plugin which provides misc. utilities for Git.
# Features
## `:G args {pattern} [{pattern}...]`
Like `:args`, but {pattern}s are interpreted by Git.
Usage examples:
- `G args 'tests/*.php'` for all PHP files under `tests/`.
- `G args SomeComponent` for all files which paths includes `SomeComponent`.
Like all `*.ts` and `*.tsx` files under `components/SomeComponent/`.
## `:G blame`
Open a Git blame viewer for the current buffer.
You can dig into blame prior to the change on the cursor line by typing `o`,
and rewind the state by typing `u`.
## `g#branch#get_name({dir})`
Return the current branch name. Useful for options like `'tabline'`.
It detects detached HEAD state and returns special notation in that case. For
example,
- `REBASE-i` in the middle of `git rebase -i`
- `master~100` if you intentionally did `git checkout master~100` to
investigate a problem
## `g#vc#add()` `g#vc#commit()` `g#vc#diff()` `g#vc#restore()`
Wrappers for the corresponding Git subcommands. Useful to define key mappings
for frequent usage. For example:
```vim
" Open a new buffer to edit commit message.
" :write the buffer to commit all modified files.
nnoremap vC call g#vc#commit('-av')
```
```vim
" Open a new buffer to review all uncomitted changes.
nnoremap vD call g#vc#diff('HEAD', '--', '.')
```
```vim
" Revert unstaged changes in the current file.
nnoremap vv call g#vc#restore(expand('%'))
```
# Further reading
See [doc/g.txt](./doc/g.txt).