Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grep with indentation-based context

Is there a grep tool that shows context based on indentation? For each match, I would like to see all the most recent lines with a lower indent level, but skip all the lines at the same indent level in between. Example:

$ contextgrep rstrip pep8.py
class Checker(object):
    def check_logical(self):
        if self.verbose >= 2:
            print(self.logical_line[:80].rstrip())
like image 396
Johann Avatar asked Apr 22 '26 02:04

Johann


1 Answers

Here's a blog post about a literal Haskell implementation of "outline grep".

like image 145
Johann Avatar answered Apr 25 '26 14:04

Johann