Thursday 17 October 2013

Effective quickfix window use in Vim

I have now setup Vim to take more advantage of the quickfix window and I think it's a pretty neat way.

First I changed cscope to use it instead of the default way which is a bit bulky by adding the following to .vimrc:
set cscopequickfix=s-,c-,d-,i-,t-,e-   
This in itself is cool because now I can just jump between the hits.

Of course quickfix window is already used when I build the software. Just to make moving around this list I did the following mappings:
map <A-p> :cp<CR> 
map <A-n> :cn<CR> 
So now I can use Alt-p and Alt-n to move between items in the quickfix window. The nice thing is, that this now also applies to any cscope lists! So instead of searching, then selecting a number to see a single context of, say, a function call, I can jump in the code to see all the hits with those keys.

And just to top this off, I also added the following:
map <A-P> :colder<CR>
map <A-N> :newer<CR>
Which means that I can now build, then maybe do a cscope search to check something (say, a function prototype) and quickly move between these two quickfix windows with those keys!

As a sidenote vim-airline messes up my GVim window badly, especially when using those quickfix windows so I had to move back to Powerline. Shame, because Airline had plenty of stuff going for it.

No comments:

Post a Comment