Vim Tips Wiki

Show entire multiline error in quickfix

Redirected from VimTip444

1,623pages on
this wiki
Add New Page
Add New Page Talk0
Tip 444 Printable Monobook Previous Next

created 2003 · complexity basic · author eric sherman · version 5.7

Put this in your vimrc if you use the cwindow:

" \cc
map <Leader>cc :cwindow<CR>:cc<CR><c-w>bz<CR><CR>
" \cn
map <Leader>cn :cwindow<CR>:cn<CR><c-w>bz<CR><CR>
" \cp
map <Leader>cp :cwindow<CR>:cp<CR><c-w>bz<CR><CR>

and when you use \cc (or whatever your leader character is + cc), \cn or \cp, it will do what :cc, :cn and :cp usually did, with the added bonus of showing the entire contents of multiline errors. this is especially useful for javac via ant, and it's obnoxious to keep typing <c-w>b<CR> every time i do a :cn, so i mapped this.

Detailed explanation:

  • ":cwindow<CR>" ensures that the quickfix window is shown.
  • ":cc" (:cn, and :cp) actually do the operation
  • "<c-w>b" go to the bottom window (which cwindow will be if it's shown) which will magically center on the error
  • "z<CR>" will reposition the buffer in the window so that the current line becomes the top line in the window
  • "<CR>" carriage-return on the error line, taking you back to the code with the error


Another solution to this problem is to "set cmdheight=2" which will provide two lines at the bottom of the screen for quickfix error lines instead of the default one.

Also on Fandom

Random Wiki