Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When performing git commit, VIM opens to edit the commit message. I would like VIM to already be in paste mode when this happens. What environment checks might I be able to perform in Autocommands to set the option? Of course, I don't want VIM to be in paste mode when opening any arbitrary file, otherwise I would just add set paste to .vimrc.

share|improve this question
up vote 1 down vote accepted

paste is a global option so we must be careful:

autocmd BufNewFile,BufRead COMMIT_EDITMSG set paste
autocmd BufLeave COMMIT_EDITMSG set nopaste

Should help.

share|improve this answer
Perfect, romainl, thank you once again! Tell me, how might I have found COMMIT_EDITMSG for myself? – dotancohen May 29 '13 at 18:44
It's easy: each time you use Vim to write your commit message, you actually use a temporary file located under a different randomized path and that file is always named COMMIT_EDITMSG which makes it a perfect hook for an autocmd. Note that my first reflex would be to do what Ingo suggested but paste can't be set locally, even with :setlocal, so the FileType option is not that great here. – romainl May 29 '13 at 18:53
I see. Thank you very, very much! – dotancohen May 30 '13 at 12:21

The used filetype is gitcommit, therefore you can set this via an autocmd:

:autocmd FileType gitcommit setlocal paste

or (with :filetype plugin on), you could put the :setlocal command into ~/.vim/after/ftplugin/gitcommit.vim.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.