tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
20k stars 1.01k forks source link

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

Open srcrip opened 3 hours ago

srcrip commented 3 hours ago

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?

srcrip commented 3 hours ago

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.

tpope commented 2 hours ago
au FileType gitcommit execute "normal! O" | startinsert

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