Search and Replace

Example for search in unix help format and reorder some fragments

Title

  -h, --help            show this help message and exit

  --version             show program's version number and exit

  -cc, --createConfig   Create configuration files

  -c CONFIG, --config CONFIG

  -sp SCRAPE_POOL, --scrape-pool SCRAPE_POOL

  -x {1,2,3}, --engine {1,2,3}

  -addr ADDRESS, --address ADDRESS

  -pd PLOT_DATA [PLOT_DATA ...], --plot-data PLOT_DATA [PLOT_DATA ...]

  -csv SOURCE_CSV_FILE, --source-csv-file SOURCE_CSV_FILE

  -tbl, --show-table    Print data in table format save,edit,complete and can
g/\(^ \+\)\(-\+\)\(\w\{1,\}\)\(,\| \w\{1,\}.\+,\| {.\+},\|\)\( --\w\{1,\}[-[a-z]\+]*\|\)\( {.\+}\|-\w\{1,\} \w\{1,\}\| \w\{1,\}\|\)\(.*]\|\)\(\n\?\)
Grouping patterns
1
2
3
4
5
6
7
8
\(^ \+\)
\(-\+\)
\(\w\{1,\}\)
\(,\| \w\{1,\}.\+,\| {.\+},\|\)
\( --\w\{1,\}[-[a-z]\+]*\|\)
\( {.\+}\|-\w\{1,\} \w\{1,\}\| \w\{1,\}\|\)
\(.*]\|\)
\(\n\?\)

replace with

\1\2\3\4\5\6\7 [#\3]_ \r..[#\3]
  -pl SOURCE_CSV_POOL_FILE, --source-csv-pool-file SOURCE_CSV_POOL_FILE [#pl]_
.. [#pl]                        Dir with csv files
  -addr ADDRESS, --address ADDRESS [#addr]_
.. [#addr]                        DB source address <hostname>, url , dsn , ip
  -drv DRIVER, --driver DRIVER [#drv]_
.. [#drv]                        ODBC Driver Definition ex: Microsoft : `ODBC Driver 17
                        for SQL Server` unix-odbc: `sql2019`
  -db DATABASE, --database DATABASE [#db]_
.. [#db]                        The database name
  -dusr DATABASE_USER, --database-user DATABASE_USER [#dusr]_
.. [#dusr]                        just that
  -dpw DATABASE_PASSWORD, --database-password DATABASE_PASSWORD [#dpw]_
.. [#dpw]                        Self explanatory

Shell Client datavisualization:
  Clientoptions section

  -ce, --client [#ce]_
.. [#ce]         Set Client mode enable
  -pd PLOT_DATA [PLOT_DATA ...], --plot-data PLOT_DATA [PLOT_DATA ...] [#pd]_
.. [#pd]                        Set the data to plot by column 1 2 3 ... etc
  -tbl, --show-table [#tbl]_
.. [#tbl]    Print data in table format save,edit,complete and can
                        export to csv format
g/^.. \[#.*$\|^   \+\w\{1,\}.*$/m$

Last update: Sep 04, 2025