QuickFixCurrentNumber : Locate the quickfix item at the cursor position.
| script karma
Downloaded by 237
Comments, bugs, improvements
script versions (upload new version)
You can navigate through the errors in the quickfix list with the built-in
:cfirst, :cnext, etc. commands. The quickfix and location lists have a
notion of "current item" (the highlighted one), and you can easily jump back
to it or others. But there's no built-in way to find out which error is at or
after the current cursor position, and you cannot limit the navigation to
errors in the current buffer.
This plugin provides additional quickfix commands like :Cnr and :Cgo to
print / go to the item at or after the cursor position, and motions like ]q
to go to previous / next errors in the current buffer, based on the cursor
Inspired by the following Stack Overflow question:
:Cnr, :Lnr Print the number of the item in the quickfix /
location list for the current cursor position (or the
next item after the cursor).
:Cgo[!], :Lgo[!] Go to the item in the quickfix / location list for the
g<C-Q> current cursor position (or the next item after the
cursor). g<C-Q> (and the commands when [!] is given)
also jump to the last item if the cursor is after all
errors; without [!], the commands then abort with an
[q / ]q Go to [count] previous / next start of an error in the
g[q / g]q Go to [count] first / last error in the current
[l / ]l Go to [count] previous / next start of a location list
item in the current buffer.
g[l / g]l Go to [count] first / last location list item in the
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
To uninstall, use the :RmVimball command.
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.023 or
For a permanent configuration, put the following commands into your vimrc:
If you want to use different mappings, map your keys to the
<Plug>(QuickFixCurrentNumber...) mapping targets _before_ sourcing the script
(e.g. in your vimrc):
nmap g<C-q> <Plug>(QuickFixCurrentNumberGo)
nmap ]q <Plug>(QuickFixCurrentNumberQNext)
nmap [q <Plug>(QuickFixCurrentNumberQPrev)
nmap ]l <Plug>(QuickFixCurrentNumberLNext)
nmap [l <Plug>(QuickFixCurrentNumberLPrev)
nmap g[q <Plug>(QuickFixCurrentNumberQFirst)
nmap g]q <Plug>(QuickFixCurrentNumberQLast)
nmap g[l <Plug>(QuickFixCurrentNumberLFirst)
nmap g]l <Plug>(QuickFixCurrentNumberLLast)
If you want no or only a few of the available mappings, you can completely
turn off the creation of the default mappings via:
:let g:no_QuickFixCurrentNumber_maps = 1
This saves you from mapping dummy keys to all unwanted mapping targets.
Click on the package to download.
ip used for rating: 188.8.131.52
||- :Cgo and :Lgo take [!] to behave like g<C-Q>, i.e. jump back to the last error instead of aborting. This is helpful because g<C-Q> only crudely distinguishes between location and quickfix list, and both may be in use. Thanks to Enno Nagel for the suggestion.
- Allow to disable all default mappings via g:no_QuickFixCurrentNumber_maps. Some users may prefer straightforward navigation through quickfix errors with ]q (e.g. as provided by the unimpaired.vim plugin).
- BUG: Script errors when jump mappings like ]q are executed in a quickfix / location list. Need to populate the bufferQflist property in the returned result and tweak the check in QuickFixCurrentNumber#Next(). Thanks to Enno Nagel for reporting this.
- Use ingo/err.vim for error reporting.
||- g<C-Q> now also jumps to the last item if the cursor is after all errors; the commands continue to abort with a "No more items" error. This allows to jump to the next / closest error position, regardless of the cursor position. Thanks to Enno Nagel for the suggestion.
- Factor out ingo#window#quickfix#TranslateVirtualColToByteCount() into ingo-library. *** You need to update to ingo-library (vimscript #4433) version 1.023! ***