Search code examples
vimvim-fugitive

Modify vim-fugitive Gstatus mapping


The :Gstatus window has specific mappings for that particular buffer. In my case, I would like to change the cc mapping to not only execute :Gcommit but also go into insert mode afterwards.

It seems like the user robodendron figured out how to do this as shown in https://github.com/tpope/vim-fugitive/issues/647, but I'm don't know what he means when he says "changing the order should be enough." Also, I would ask this on the Git issues page, but it seems like the user NicolasWebDev already tried that and no one got back to him.

I can add mappings by creating a after/ftplugin/gitcommit.vim file, but modifying an existing mapping seems to be more difficult since the mapping is defined after the filetype is set.

Also, I could modify the source code mappings, but we all know that's more of a temporary fix.


Solution

  • I am not sure about trying to alter :Gstatus mappings, but you can start insert mode when entering the commit buffer.

    Add the following to your vimrc file:

    augroup turbo_commit
      autocmd!
      autocmd BufEnter COMMIT_EDITMSG startinsert
    augroup END
    

    For more help see:

    :h :autocmd
    :h :augroup
    :h BufEnter
    :h startinsert