Checkout branches and tags with fzf.
Install using vim-plug.
Put this in your init.vim
.
Plug 'stsewd/fzf-checkout.vim'
Note: You need to have fzf
installed in addition to use this plugin.
See https://github.com/junegunn/fzf/blob/master/README-VIM.md#installation.
Call :GCheckout
or GCheckoutTag
to checkout to a branch or tag.
- The current branch or commit will be show at the bottom
- The first item on the list will be the previous branch
- Press
alt-enter
to track a remote branch locally (origin/foo
becomesfoo
) - Press
ctrl-n
to create a branch or tag with the current query as name - Press
ctrl-d
to delete a branch or tag
If you have fzf.vim installed,
this plugin will respect your g:fzf_command_prefix
setting.
Name of the git
binary.
let g:fzf_checkout_git_bin = 'git'
Additional options to pass to the git
command. It is not recommended to change the
--color
and --format
parameters, as they are used by the plugin and changing them
may break something.
let g:fzf_checkout_git_options = ''
Key used to track the remote branch locally (git checkout --track branch
).
let g:fzf_checkout_track_key = 'alt-enter'
Key used to create a branch (git checkout -b branch
).
let g:fzf_checkout_create_key = 'ctrl-n'
Key used to delete a branch (git branch -D branch
).
let g:fzf_checkout_delete_key = 'ctrl-d'
Display previously used branch first independent of specified sorting.
let g:fzf_checkout_previous_ref_first = v:true
Command used to execute the checkout, options are:
- system: Uses the
system()
function (default). - terminal: Uses the
terminal
command (it works on Neovim only). - bang: Makes use of
!command
.
let g:fzf_checkout_execute = 'system'
If you provide a different string as the option,
it will be executed to checkout the branch or tag.
{git}
and {branch}
are replaced with the g:fzf_checkout_git_bin
and the branch or tag to checkout.
let g:fzf_checkout_execute = 'echo system("{git} checkout {branch}")'
Same as g:fzf_checkout_execute
, but it's used when tracking a branch.
let g:fzf_checkout_track_execute = 'system'
This is the same as:
let g:fzf_checkout_track_execute = 'echo system("{git} checkout --track {branch}")'
Same as g:fzf_checkout_execute
, but used to create a branch.
let g:fzf_checkout_create_execute = 'system'
This is the same as:
let g:fzf_checkout_create_execute = 'echo system("{git} checkout -b {branch}")'
Same as g:fzf_checkout_execute
, but used to create a tag.
let g:fzf_checkout_create_tag_execute = 'system'
This is the same as:
let g:fzf_checkout_create_tag_execute = 'echo system("{git} tag {branch}")'
Same as g:fzf_checkout_execute
, but used to delete a branch.
let g:fzf_checkout_delete_execute = 'system'
This is the same as:
let g:fzf_checkout_delete_execute = 'echo system("{git} branch -D {branch}")'
Same as g:fzf_checkout_execute
, but used to delete a tag.
let g:fzf_checkout_delete_tag_execute = 'system'
This is the same as:
let g:fzf_checkout_delete_tag_execute = 'echo system("{git} tag -d {branch}")'
Prefix commands with Fzf
, i.e, FzfGCheckout
and FzfGCheckoutTag
.
let g:fzf_command_prefix = 'Fzf'
Sort branches/tags by committer date. Minus sign to show in reverse order (recent first).
let g:fzf_checkout_git_options = '--sort=-committerdate'