Comments (7)
Oh, and in case you're wondering why not just add what user searched for to the /
register - because this wouldn't work with regex searches.
from vim-grepper.
Do you know that there's simple highlighting support already? It's enabled by :Grepper
s -highlight
flag. (See :h :Grepper
.)
Simple because it indeed uses the /
register, although it should handle simple cases of .*
and a few other patterns just fine. It's a "good enough" approach that doesn't rely on external tools.
Put this in your vimrc to turn on highlighting for :Ag
:
command! -nargs=* -complete=file Ag Grepper -noprompt -highlight -tool ag -query <args>
As for the other suggestions:
- Way 1: But how do you "search" the output line to even get the starting column when using regexp? To get an exact answer, you'd have to use the same tool again. And then you have the same problem again: no ending column. (Some tools don't even report the starting column.)
- Way 2: No, just no. :-) Parsing ANSI escape sequences only leads into a deep, deep rabbit hole. Some tools might not even provide coloured output.
from vim-grepper.
@mhinz First of all I've tried enable highlight via g:grepper
, but it didn't work out for some reason.
About the first way. Ag can report starting column. You don't need to search for it youself. Then, as I've said - you can make Ag output match only and from that you can get the length of match. Start column + length = end column. And there it is - you arguments for the matchpos ready.
Unfortunately I know only basics of vimscript, so most of you code is mumbo jumbo to me, so I can't add this myself in any reasonable time, but this shouldn't be hard to do, right?
What's harder to do is display the whole line in quick fix with this approach. I don't really need that myself, but other people probably would prefer this. This is also achievable. We can just take line numbers from ag output and get this lines manually from all files with matches.
I sense that you will say something like "this is too much work", "no one really needs this", so would you at least accept pull request with this feature sometime?
And I don't like things that's "good enough" when there's clearly a way to make them better. Never settle on the mediocracy.
from vim-grepper.
First of all I've tried enable highlight via g:grepper, but it didn't work out for some reason.
What was the exact line? A quick test with let g:grepper = { 'highlight': 1 }
and searching for "foo" afterwards worked just fine.
And I don't like things that's "good enough" when there's clearly a way to make them better. Never settle on the mediocracy.
Well, this misses the point. The approach wasn't chosen because it's easier to implement, but because it works the same for all supported tools and tools added by the user. It's the best approach given a certain design and has nothing to do with mediocracy.
Ag can report starting column. You don't need to search for it youself. Then, as I've said - you can make Ag output match only and from that you can get the length of match.
And as I've said, that might not work for other tools, which is my main grief, since I don't like adding too much tool-specific code.
Nevertheless I'm open to adding "exact highlighting". Let me play around with this idea for a bit and see if I encounter any technical problems.
from vim-grepper.
@mhinz Thanks, will be glad if this would be added.
from vim-grepper.
I played around with the idea for a bit, but all solutions seem quite flakey to me.
Nevertheless I let the issue open in case someone wants to have a try on it.
from vim-grepper.
I'm closing this since I'm going into maintenance mode for this plugin. I'll still fix bugs but I won't add new features on my own.
from vim-grepper.
Related Issues (20)
- Autocomplete path in the Grepper prompt?
- doc/grepper.txt: suggestion about setting global grepper options is misleading
- 'o' does not open the current context
- why not support realtime display while typing some search words? HOT 1
- Integration with fugitive for git-grep
- Search in project root
- `executable` seems to be really slow on arm64 macOS causing grepper
- Always No results with ripgrep 13.0 HOT 24
- grepper prompt can't display <c-d> / <c-s> indicators at the same time
- qf window height HOT 1
- Failed to catch the filename when grepping a file(NOT folder) with gnu-grep
- Can I have multiple configs for a same tool?
- Can I pass multiple arguments to grepprg?
- no results for term surrounded by single quotes under Microsoft Windows 10 HOT 3
- Apply search only to files that are in quickfix list
- -cword stopped working HOT 11
- The -buffer flag has no effect HOT 7
- Grepper in Vimscript function does not execute subsequent cdo command
- add example of how to grep in the directory of current file. HOT 1
- complete_files error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-grepper.