summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
* utf: fixed console.delete()hut2010-05-171-7/+9
|
* fixed utf stuffhut2010-05-173-17/+58
|
* utf stuffhut2010-05-102-6/+16
|
* attempt to fix utf issues (wrong calculation of width)hut2010-05-104-3/+112
|
* TODO: updatedhut2010-05-101-3/+13
|
* main: added commenthut2010-05-101-2/+3
|
* HACKING: updatehut2010-05-101-8/+3
|
* all_benchmarks: improvedhut2010-05-102-10/+20
|
* Makefile: updatedhut2010-05-101-9/+12
|
* Run python with flag "-O" by defaulthut2010-05-101-1/+1
| | | | | This will discard assert statements which are unnecessary for end users.
* fixed "zc" keyhut2010-05-101-10/+10
|
* defaults.commands: edit current file with ":edit"hut2010-05-101-1/+4
|
* api.commands: fixed :ehut2010-05-101-3/+4
|
* close console with <C-D>hut2010-05-101-1/+1
|
* added <C-P> and <C-N> keys to consolehut2010-05-101-2/+2
|
* defaults.keys: added hint for "cw"hut2010-05-091-1/+1
|
* defaults.keys: fixed delete keyhut2010-05-091-1/+1
|
* fsobject.directory: bugfixhut2010-05-061-1/+1
|
* ext.human_readable: round(number, 2)hut2010-05-061-1/+1
|
* fsobject: bugfixhut2010-05-061-3/+3
|
* fsobject: don't unnecessarily use abspath() in __init__hut2010-05-063-9/+12
|
* fsobject.fsobject: lazily load mimetypehut2010-05-061-11/+26
|
* shared.mimetype: optimizationhut2010-05-061-5/+3
|
* fsobject.fsobject: optimizationshut2010-05-061-30/+44
|
* fsobject: a couple of optimizationshut2010-05-062-29/+44
|
* cleanupshut2010-05-059-30/+21
|
* Added license header to a few fileshut2010-05-044-0/+60
|
* bm_loader: stuffhut2010-05-031-1/+35
|
* fsobject: removed obsolete fsobject.type attribute + constantshut2010-05-032-13/+1
|
* Makefile: added `make bm` to run all benchmarks BMCOUNT timeshut2010-05-031-2/+5
|
* test: added TODO, skip broken testshut2010-05-034-5/+25
|
* Makefile: cleaned up, added automatic uninstallhut2010-05-031-58/+57
|
* ext.accumulator: added commenthut2010-05-021-0/+1
|
* defaults.commands: fixed :quit, added :quitallhut2010-05-021-5/+14
|
* help.movement: updated 1.6: there is no "tab 0" anymorehut2010-05-021-1/+1
|
* ranger.help: fixed topicshut2010-05-023-3/+5
|
* widgets.browsercolumn: call move_parent when scrolling in second columnhut2010-05-023-8/+19
|
* bugfix: scroll faster with ctrlhut2010-05-021-1/+1
|
* added help chapter 5, ranger/help/invocation.pyhut2010-04-303-1/+109
|
* extended and documented u* key combinationshut2010-04-302-2/+6
|
* defaults.keys: implement I keyhut2010-04-302-1/+5
|
* defaults.keys: new tabs start in the home directoryhut2010-04-301-1/+4
|
* api.commands: bugfix (renamed Command.quick_open to Command.quick)hut2010-04-302-3/+3
|
* some more doc updatesSitaram Chamarty2010-04-302-10/+15
|
* Added documentation for remaining key combinations (excluding z*, g*,...)hut2010-04-293-4/+29
|
* changed testdir to /usr/includehut2010-04-291-1/+1
|
* Separated benchmark from testcasehut2010-04-294-125/+165
|
* help.console: updatedhut2010-04-281-4/+10
|
* widgets.console: added macro %dhut2010-04-281-0/+5
|
* widgets.console: give a local variable a more meaningful namehut2010-04-281-7/+7
|
> 100 101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128


                         

                      
               
 
                        
             
 
                                                                              
                                                                    

                                                                 
                                               

                                                        




            
                                 
 
        
                                    
     
 
                                                    

 


                     

                                










































                                                                                
                                                                        















                                                                          




                                                   
                                                                         
 
          
                                                      
                                   
       




                                                                            
                  
          

                                                                               
       

                                                                       
          




                                                   
       

                                                                                
=========================
  nimgrep User's manual
=========================

:Author: Andreas Rumpf
:Version: 1.6.0

.. default-role:: option
.. contents::

Nimgrep is a command line tool for search and replace tasks. It can search for
regex or peg patterns and can search whole directories at once. User
confirmation for every single replace operation can be requested.

Nimgrep has particularly good support for Nim's
eccentric *style insensitivity* (see option `-y` below).
Apart from that it is a generic text manipulation tool.


Installation
============

Compile nimgrep with the command:

  ```cmd
  nim c -d:release tools/nimgrep.nim
  ```

And copy the executable somewhere in your ``$PATH``.


Command line switches
=====================

.. include:: nimgrep_cmdline.txt

Path filter options
-------------------

Let us assume we have file `dirA/dirB/dirC/file.nim`.
Filesystem path options will match for these parts of the path:

| option              | matches for                        |
| :------------------ | :--------------------------------  |
| `--[not]extensions` | ``nim``                            |
| `--[not]filename`   | ``file.nim``                       |
| `--[not]dirname`    | ``dirA`` and ``dirB`` and ``dirC`` |
| `--[not]dirpath`    | ``dirA/dirB/dirC``                 |

Combining multiple filter options together and negating them
------------------------------------------------------------

Options for filtering can be provided multiple times so they form a list,
which works as:
* positive filters
  `--filename`, `--dirname`, `--dirpath`, `--inContext`,
  `--inFile` accept files/matches if *any* pattern from the list is hit
* negative filters
  `--notfilename`, `--notdirname`, `--notdirpath`, `--notinContext`,
  `--notinFile` accept files/matches if *no* pattern from the list is hit.

In other words the same filtering option repeated many times means logical OR.

.. Important::
  Different filtering options are related by logical AND: they all must
  be true for a match to be accepted.
  E.g. `--filename:F --dirname:D1 --notdirname:D2` means
  `filename(F) AND dirname(D1) AND (NOT dirname(D2))`.

So negative filtering patterns are effectively related by logical OR also:
`(NOT PAT1) AND (NOT PAT2) == NOT (PAT1 OR PAT2)`:literal: in pseudo-code.

That means you can always use only 1 such an option with logical OR, e.g.
`--notdirname:PAT1 --notdirname:PAT2` is fully equivalent to
`--notdirname:'PAT1|PAT2'`.

.. Note::
   If you want logical AND on patterns you should compose 1 appropriate pattern,
   possibly combined with multi-line mode `(?s)`:literal:.
   E.g. to require that multi-line context of matches has occurrences of
   **both** PAT1 and PAT2 use positive lookaheads (`(?=PAT)`:literal:):
     ```cmd
     nimgrep --inContext:'(?s)(?=.*PAT1)(?=.*PAT2)'
     ```

Meaning of `^`:literal: and `$`:literal:
========================================

`nimgrep`:cmd: PCRE engine is run in a single-line mode so
`^`:literal: matches the beginning of whole input *file* and
`$`:literal: matches the end of *file* (or whole input *string* for
options like `--filename`).

Add the `(?m)`:literal: modifier to the beginning of your pattern for
`^`:literal: and `$`:literal: to match the beginnings and ends of *lines*.

Examples
========

All examples below use default PCRE Regex patterns:

+ To search recursively in Nim files using style-insensitive identifiers:

    ```cmd
    nimgrep --recursive --ext:'nim|nims' --ignoreStyle
    # short: -r --ext:'nim|nims' -y
    ```

  .. Note:: we used `'` quotes to avoid special treatment of `|` symbol
    for shells like Bash

+ To exclude version control directories (Git, Mercurial=hg, Subversion=svn)
  from the search:
    ```cmd
    nimgrep --notdirname:'^\.git$' --notdirname:'^\.hg$' --notdirname:'^\.svn$'
    # short: --ndi:'^\.git$' --ndi:'^\.hg$' --ndi:'^\.svn$'
    ```
+ To search only in paths containing the `tests`:literal: sub-directory
  recursively:
    ```cmd
    nimgrep --recursive --dirname:'^tests$'
    # short: -r --di:'^tests$'
    # or using --dirpath:
    nimgrep --recursive --dirpath:'(^|/)tests($|/)'
    # short: -r --pa:'(^|/)tests($|/)'
    ```
+ Nimgrep can search multi-line, e.g. to find files containing `import`:literal:
  and then `strutils`:literal: use pattern `'import(.|\n)*?strutils'`:literal:.