Vim Tips Wiki
(Created page with "One of my largest annoyances with Vim is the great Quickfix, in particular the auto-jump. The reasons for this do not matter, but I wanted to disable it really bad. It took me se...")
 
(Remove mindless solution.)
Tag: Visual edit
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  +
{{TipProposed
One of my largest annoyances with Vim is the great Quickfix, in particular the auto-jump. The reasons for this do not matter, but I wanted to disable it really bad. It took me several months to figure out how to do it, and the end-result still feels like a hack.
 
  +
|id=0
  +
|previous=0
  +
|next=0
  +
|created=November 17, 2011
  +
|complexity=basic
  +
|author=
  +
|version=7.0
  +
|subpage=/201111
  +
|category1=
  +
|category2=
  +
}}
  +
You may not like that Vim automatically jumps to the first error when you compile from within Vim using <code>:make</code>.
   
  +
Even though the answer is <em>right there in {{help|:make}}</em>, 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 code for this==
 
   
  +
The correct way to avoid jumping to errors after <code>:make</code> is simply to add a '!', i.e. execute <code>:make!</code> instead of <code>:make</code>.
Put the following in your .vimrc
 
   
  +
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 <code>:cfile</code>. One possible solution is 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 <code>:execute "normal! \<C-O>"</code> in a script).
<pre>
 
autocmd QuickFixCmpPost * call setqflist([])
 
</pre>
 
   
What this does is quite inhumane: it deletes the quickfix-list. I am still looking for a way to disable the `jump' without deleting the list.
+
As a side note, the {{help|prefix=no|id=: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 <code>:make</code> followed by <code>:copen</code> 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 <code>:copen</code>, and/or add a '!' to the <code>:make</code> command as suggested.
==Use case==
 
   
  +
==Comments==
Obviously, quickfix is a sacred thing, and should never be disabled. To figure out why I would still want to, read the following.
 
 
I use Vim to edit TeX-files, and want to know about boxing errors (underfull, overfull) so that I can fix those. In very few cases, however, I can not fix it, because I am quoting an exercise from a book for my homework. But, everytime I type ':make', it jumps to the boxing error, and I lost where I am.
 

Latest revision as of 22:06, 11 May 2018

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. One possible solution is 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.

Comments[]