axil's blog
  • Home
  • Categories
  • Tags
  • Archives

Jump to next error in vim

vim can check syntax as you type using quickfix feature. To jump to next/previous error you need to write :cnext or :cprev in the command line.

unimpaired plugin has shortcuts [q and ]q for that.

The problem with this is that if there's only one error, :cn and :cp don't work, you need to use :cc. Which is an amazingly bad design decision in my opinion.

The following shortcuts solve this issue:

nnoremap } :<C-R>=len(getqflist())==1?"cc":"cn"<CR><CR>
nnoremap { :<C-R>=len(getqflist())==1?"cc":"cp"<CR><CR>

They map the '}' and '{' keys to jump to next/previous error even if there's only one error in a file.

  • « Improving the MS Office ribbon
  • How to open .ipynb file with one doubleclick on Windows »
Comments
comments powered by Disqus

Published

Dec 7, 2016

Last Updated

2019-12-16 00:41:49.248573+07:00

Category

software

Tags

  • cnext 1
  • quickfix 1
  • vim 1
  • .vimrc 1
  • Powered by Pelican. Theme: Elegant by Talha Mansoor