nimgrep_cmdline.txt 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. Usage:
  2. * To search:
  3. nimgrep [options] PATTERN [(FILE/DIRECTORY)*/-]
  4. * To replace:
  5. nimgrep [options] PATTERN --replace REPLACEMENT (FILE/DIRECTORY)*/-
  6. * To list file names:
  7. nimgrep [options] --filenames [PATTERN] [(FILE/DIRECTORY)*]
  8. Positional arguments, from left to right:
  9. 1) PATTERN is either Regex (default) or Peg if `--peg` is specified.
  10. PATTERN and REPLACEMENT should be skipped when `--stdin` is specified.
  11. 2) REPLACEMENT supports `$1`, `$#` notations for captured groups in PATTERN.
  12. .. DANGER:: `--replace` mode **DOES NOT** ask confirmation
  13. unless `--confirm` is specified!
  14. 3) Final arguments are a list of paths (FILE/DIRECTORY) or a standalone
  15. minus `-` or not specified (empty):
  16. * empty, current directory `.` is assumed (not with `--replace`)
  17. .. Note:: so when no FILE/DIRECTORY/`-` is specified nimgrep
  18. does **not** read the pipe, but searches files in the current
  19. dir instead!
  20. * `-`, read buffer once from stdin: pipe or terminal input;
  21. in `--replace` mode the result is directed to stdout;
  22. it's not compatible with `--stdin`, `--filenames`, or `--confirm`
  23. For any given DIRECTORY nimgrep searches only its immediate files without
  24. traversing subdirectories unless `--recursive` is specified.
  25. In replacement mode we require all 3 positional arguments to avoid damaging.
  26. Options:
  27. * Mode of operation:
  28. --find, -f find the PATTERN (default)
  29. --replace, -! replace the PATTERN to REPLACEMENT, rewriting the files
  30. --confirm confirm each occurrence/replacement; there is a chance
  31. to abort any time without touching the file
  32. --filenames just list filenames. Provide a PATTERN to find it in
  33. the filenames (not in the contents of a file) or run
  34. with empty pattern to just list all files:
  35. nimgrep --filenames # In current dir
  36. nimgrep --filenames "" DIRECTORY
  37. # Note empty pattern "", lists all files in DIRECTORY
  38. * Interprete patterns:
  39. --peg PATTERN and PAT are Peg
  40. --re PATTERN and PAT are regular expressions (default)
  41. --rex, -x use the "extended" syntax for the regular expression
  42. so that whitespace is not significant
  43. --word, -w matches should have word boundaries (buggy for pegs!)
  44. --ignoreCase, -i be case-insensitive in PATTERN and PAT
  45. --ignoreStyle, -y be style insensitive in PATTERN and PAT
  46. .. Note:: PATTERN and patterns PAT (see below in other options) are all either
  47. Regex or Peg simultaneously and options `--rex`, `--word`, `--ignoreCase`,
  48. and `--ignoreStyle` are applied to all of them.
  49. * File system walk:
  50. --recursive, -r process directories recursively
  51. --follow follow all symlinks when processing recursively
  52. --sortTime, -s[:asc|desc]
  53. order files by the last modification time (default: off):
  54. ascending (recent files go last) or descending
  55. * Filter files (based on filesystem paths):
  56. .. Hint:: Instead of `not` you can type just `n` for negative options below.
  57. --ex[tensions]:EX1|EX2|...
  58. only search the files with the given extension(s),
  59. empty one (`--ex`) means files with missing extension
  60. --notex[tensions]:EX1|EX2|...
  61. exclude files having given extension(s), use empty one to
  62. skip files with no extension (like some binary files are)
  63. --fi[lename]:PAT search only files whose name matches pattern PAT
  64. --notfi[lename]:PAT skip files whose name matches pattern PAT
  65. --di[rname]:PAT select files that in their path have a directory name
  66. that matches pattern PAT
  67. --notdi[rname]:PAT do not descend into directories whose name (not path)
  68. matches pattern PAT
  69. --dirp[ath]:PAT select only files whose whole relative directory path
  70. matches pattern PAT
  71. --notdirp[ath]:PAT skip files whose whole relative directory path
  72. matches pattern PAT
  73. * Filter files (based on file contents):
  74. --inF[ile]:PAT select files containing a (not displayed) match of PAT
  75. --notinF[ile]:PAT skip files containing a match of PAT
  76. --bin:on|off|only process binary files? (detected by \0 in first 1K bytes)
  77. (default: on - binary and text files treated the same way)
  78. --text, -t process only text files, the same as `--bin:off`
  79. * Filter matches:
  80. --inC[ontext]:PAT select only matches containing a match of PAT in their
  81. surrounding context (multiline with `-c`, `-a`, `-b`)
  82. --notinC[ontext]:PAT
  83. skip matches not containing a match of PAT
  84. in their surrounding context
  85. * Represent results:
  86. --nocolor output will be given without any colors
  87. --color[:on] force color even if output is redirected (default: auto)
  88. --colorTheme:THEME select color THEME from `simple` (default),
  89. `bnw` (black and white), `ack`, or `gnu` (GNU grep)
  90. --count only print counts of matches for files that matched
  91. --context:N, -c:N print N lines of leading context before every match and
  92. N lines of trailing context after it (default N: 0)
  93. --afterContext:N, -a:N
  94. print N lines of trailing context after every match
  95. --beforeContext:N, -b:N
  96. print N lines of leading context before every match
  97. --group, -g group matches by file
  98. --newLine, -l display every matching line starting from a new line
  99. --cols[:N] limit max displayed columns/width of output lines from
  100. files by N characters, cropping overflows (default: off)
  101. --cols:auto, -% calculate columns from terminal width for every line
  102. --onlyAscii, -@ display only printable ASCII Latin characters 0x20-0x7E
  103. substitutions: 0 -> ^@, 1 -> ^A, ... 0x1F -> ^_,
  104. 0x7F -> '7F, ..., 0xFF -> 'FF
  105. * Miscellaneous:
  106. --threads:N, -j:N speed up search by N additional workers (default: 0, off)
  107. --stdin read PATTERN from stdin (to avoid the shell's confusing
  108. quoting rules) and, if `--replace` given, REPLACEMENT
  109. --verbose be verbose: list every processed file
  110. --help, -h shows this help
  111. --version, -v shows the version