tpope/vim-fugitive

Fugitive inserts a blank/newline before commit messages, when launched like `git commit -m "whatever" -e`

Closed this issue · 2 comments

Hello all,

If you use Vim in such a way that you end up opening a commit buffer, and you have fugitive loaded, you'll get a new/blank line before the current commit message, which is super annoying. Is there any way to avoid this?

nvm, this seems to be a me problem. I was doing this:

  {
    "tpope/vim-fugitive",
    config = function()
      map("n", "<space>gg", ":Git<cr>", { silent = true })
      vim.cmd([[
        au FileType gitcommit execute "normal! O" | startinsert
        nnoremap <silent> <space>gd :Gdiff<CR>
        nnoremap <silent> <space>gb :Git blame<CR>
        nnoremap <silent> <space>gL :Git log --author=sevensidedmarble <CR>
        nnoremap <silent> <space>gl :Git log<CR>
        nnoremap <silent> <space>gb :GBranches! checkout<CR>
        nnoremap <silent> <space>gc :GBranches! create<CR>
        nnoremap <silent> <space>G :Tig<CR>

        augroup FugitiveMappings
          autocmd!
          " autocmd FileType fugitive setlocal winheight=40 | nmap <buffer> <Tab> =
          autocmd FileType fugitive nmap <buffer> <Tab> =
        augroup END
      ]])
    end,
  },

Not really sure why, but that was inserting a new line.

au FileType gitcommit execute "normal! O" | startinsert

O inserts a newline. It's doing what you told it to do.