nimgrep_cmdline.txt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 sub-directories 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:: PATERN 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. --ext:EX1|EX2|... only search the files with the given extension(s),
  53. empty one ("--ext") means files with missing extension
  54. --noExt:EX1|... exclude files having given extension(s), use empty one to
  55. skip files with no extension (like some binary files are)
  56. --includeFile:PAT search only files whose names contain pattern PAT
  57. --excludeFile:PAT skip files whose names contain pattern PAT
  58. --includeDir:PAT search only files with their whole directory path
  59. containing PAT
  60. --excludeDir:PAT skip directories whose name (not path)
  61. contain pattern PAT
  62. --if,--ef,--id,--ed abbreviations of the 4 options above
  63. --sortTime, -s[:asc|desc]
  64. order files by the last modification time (default: off):
  65. ascending (recent files go last) or descending
  66. * Filter file content:
  67. --match:PAT select files containing a (not displayed) match of PAT
  68. --noMatch:PAT select files not containing any match of PAT
  69. --bin:on|off|only process binary files? (detected by \0 in first 1K bytes)
  70. (default: on - binary and text files treated the same way)
  71. --text, -t process only text files, the same as `--bin:off`
  72. * Represent results:
  73. --nocolor output will be given without any colors
  74. --color[:on] force color even if output is redirected (default: auto)
  75. --colorTheme:THEME select color THEME from `simple` (default),
  76. `bnw` (black and white), `ack`, or `gnu` (GNU grep)
  77. --count only print counts of matches for files that matched
  78. --context:N, -c:N print N lines of leading context before every match and
  79. N lines of trailing context after it (default N: 0)
  80. --afterContext:N, -a:N
  81. print N lines of trailing context after every match
  82. --beforeContext:N, -b:N
  83. print N lines of leading context before every match
  84. --group, -g group matches by file
  85. --newLine, -l display every matching line starting from a new line
  86. --cols[:N] limit max displayed columns/width of output lines from
  87. files by N characters, cropping overflows (default: off)
  88. --cols:auto, -% calculate columns from terminal width for every line
  89. --onlyAscii, -@ display only printable ASCII Latin characters 0x20-0x7E
  90. substitutions: 0 -> ^@, 1 -> ^A, ... 0x1F -> ^_,
  91. 0x7F -> '7F, ..., 0xFF -> 'FF
  92. * Miscellaneous:
  93. --threads:N, -j:N speed up search by N additional workers (default: 0, off)
  94. --stdin read PATTERN from stdin (to avoid the shell's confusing
  95. quoting rules) and, if `--replace` given, REPLACEMENT
  96. --verbose be verbose: list every processed file
  97. --help, -h shows this help
  98. --version, -v shows the version