Is your feature request about something that is currently impossible or hard to do? Please describe the problem.
I needed to know which of the files from an argument list contained a pattern. The pattern was a common word which many of the files contained much more than once, so :lvimgrep /pattern/ ## generated a very long location list that was somewhat difficult to analyze.
Describe the solution you'd like
A flag for :lvimgrep that would limit the maximum number of matches to find in each file. (I know there's :{count}lvim[grep], but that limits the total number of matches in all files).
Describe alternatives you've considered
I came up with this function and corresponding user command:
function! LoclistUniqueFilenames()
if !empty(getloclist(0))
let loclist = getloclist(0)
let items = ""
for i in loclist
let items ..= bufname(i['bufnr']) .. "\n"
endfor
new
silent 0put =items
silent uniq
return 0
else
echo 'Location list for the current window is empty!'
return 1
endif
endfunction
command -nargs=0 LocListUnique call LoclistUniqueFilenames()
That solves my particular problem, but perhaps a general solution, e.g. a flag for setting n (where n is maximum number of matches to find in each file) would be better.
Vim v9.2.738.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()