Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
srcrip opened this issue Oct 23, 2024 · 2 comments

Comments

@srcrip
Copy link

srcrip commented Oct 23, 2024

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
Copy link
Author

srcrip commented Oct 23, 2024

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
Copy link
Owner

tpope commented Oct 23, 2024

au FileType gitcommit execute "normal! O" | startinsert

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

@tpope tpope closed this as completed Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants