0

I'm looking for a method to map :q to :bwipeout only for SVN blame buffers, as generated by vcscommand.vim and :VCSBlame so that my motor memory of :q takes hold when I want to eliminate those short-lived read-only buffers.

The buffer names begin with SVN\ annotate <filename>, and so I hoped this would match:

autocmd BufNew SVN\ annotate* cmap q bwipeout

However, the buffer name doesn't match this pattern. How can I make this mapping happen locally for buffers like SVN\ annotate*?

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390

2 Answers2

2

VCSCommand (which I recommend) gives its buffers special filetypes. For :VCSBlame it's svnannotate if you use Subversion or gitannotate if you use Git.

From my limited trial, this line does exactly what you want:

autocmd FileType svnannotate cmap <buffer> q bwipeout

I've added <buffer> just in case but I think you can remove it safely.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • @romani Yes, perfect. That's exactly what I wanted, also extensible, it appears, to `ft=svninfo` Thanks. – Michael Berkowski Feb 27 '12 at 23:11
  • Be very careful with `cmap`. It can fire on any command line type actions. e.g. `/quick`, `?quick`, and middle of a command like `w ~/quick.txt`. see the following for a solution: http://stackoverflow.com/questions/7513380/vim-change-x-function-to-delete-buffer-instead-of-save-quit/7515418#7515418 – Peter Rincker Feb 28 '12 at 14:23
2

Apparently the VCSCommand plugin has a setting called VCSCommandDeleteOnHide which when set to non zero will :bdelete the buffer on a hide which this includes :q. Note: this will apply to all VCSCommand buffers.

let g:VCSCommandDeleteOnHide = 1

If you really want to wipe just the annotate the buffer you can do the following instead.

autocmd FileType svnannotate set bufhidden=wipe

See

:h VCSCommandDeleteOnHide
:h 'bufhidden'
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101