mileszs / ack.vim

Vim plugin for the Perl module / CLI script 'ack'
Other
3.08k stars 396 forks source link

ack count function #161

Closed jungle-boogie closed 8 years ago

jungle-boogie commented 9 years ago

Hello,

How do you count occurrences within a file with ack.vim? With standard ack, its ack -c pattern.

With :Ack -c, you get: || Options '--column' and '-c' are mutually exclusive

Thanks, jungle

ches commented 8 years ago

Apologies that this issue went without a response for so long. Trying to clean house a little bit now.

Can you explain the use case you had in mind? Since the primary mode of operation for ack.vim is populating the quickfix list with lines matching a search query, a count of matches falls a bit outside the norm. I'm just wondering if there's something more advanced you were wanting to script using the plugin.

ack.vim calls ack with the --column option by default in order to be able to take you exactly to a match, and multiple matches on the same line. For scripting something, you could save the value of g:ack_default_options in a variable, change it, and then restore it after you've done what you need to. For one-off usage it'd probably just be easiest to avoid the plugin altogether, e.g. :!ack -c query %.

ches commented 8 years ago

Going to close this, if I haven't answered your question feel free to comment and re-open.

jungle-boogie commented 8 years ago

Thanks for the follow up.

I'm willing to accept that my request is a bit of feature creep and I'll use ack to do counting outside of vim.