Skip to content

Commit

Permalink
Vim: try to center on :cn, :cnf etc
Browse files Browse the repository at this point in the history
Based on the technique described in:

http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev

This seems to work pretty well, although it would be nice if we could
make the patching invisible. As it is, you can see the `:cn | normal zz`
echoed to the command line.
  • Loading branch information
wincent committed Jun 26, 2015
1 parent 19c42fb commit 7876ef1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions roles/dotfiles/files/.vim/plugin/abbrev.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
" Keep quickfix result centered, if possible, when jumping from result to result.
cabbrev <expr> cn ((getcmdtype() == ':' && getcmdpos() == 3) ? 'cn <bar> normal zz<cr>' : 'cn')
cabbrev <expr> cnf ((getcmdtype() == ':' && getcmdpos() == 4) ? 'cnf <bar> normal zz<cr>' : 'cnf')
cabbrev <expr> cp ((getcmdtype() == ':' && getcmdpos() == 3) ? 'cp <bar> normal zz<cr>' : 'cp')
cabbrev <expr> cpf ((getcmdtype() == ':' && getcmdpos() == 4) ? 'cpf <bar> normal zz<cr>' : 'cpf')

0 comments on commit 7876ef1

Please sign in to comment.