Note: Insert mode for commit messages in Neovim

December 24, 2024
vim

Want to save one keystroke and a few milliseconds? I’m trying something out, when I do my git commits, to start in insert mode, so I can start typing immediately.

You can do this by adding a new autocommand for git commit messages. In Neovim and Lua you create one like this:

vim.api.nvim_create_autocmd("FileType", {
  pattern = "gitcommit",
  callback = function()
    vim.cmd("startinsert")
  end,
})

If for example you are using Lazyvim, add the above to your ~/.config/nvim/lua/config/autocmds.lua file.

Reboot with specific boot entry