Wikia

Vim Tips Wiki

Avoid automatic jump after make

Talk0
1,613pages on
this wiki
Revision as of 04:59, October 10, 2012 by Fritzophrenic (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created November 17, 2011 · complexity basic · version 7.0

You may not like that Vim automatically jumps to the first error when you compile from within Vim using :make.

Even though the answer is right there in :help :make, for some reason people ask this question somewhat frequently, and after all you're looking on the Internet to find the answer right now, aren't you?

The correct way to avoid jumping to errors after :make is simply to add a '!', i.e. execute :make! instead of :make.

A couple commands don't let you avoid the jump. The cscope commands don't have an option to avoid the jump, and neither does :cfile. You could use a QuickFixCmdPost autocmd to delete the quickfix list after creating it, but then you will not be able to view any of the errors, in which case the command you just ran serves no purpose. Thus, a much better solution to deleting the quickfix list, would be to simply jump back to where you were. If you use one of these commands, or forget to add the '!' to commands which support it, you can just press CTRL+O in normal mode to jump back to where you were (or use :execute "normal! \<C-O>" in a script).

As a side note, the :vimgrep command also uses the quickfix list, and does not use '!' to avoid jumping, but you can add the 'j' flag to the search to accomplish the same thing.

If the quickfix list is automatically appearing whenever you save a file, that means you have a plugin which automatically runs :make followed by :copen or similar on a save. Check the plugin's documentation to see if there is a way to disable it, or edit the plugin to remove the automatic :copen, and/or add a '!' to the :make command as suggested.

CommentsEdit

Around Wikia's network

Random Wiki