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$

Replace inline Vim

Replace pattern with or classifications in string

 [{
    sidebar_id            : null,     // id of the node, must be unique for the whole sidebar
    text          : '',       // string or function, text for the node
    order         : null,     // if defined, will be used for sorting, otherwiser text  will be used
    nodes         : [],       // array of sub node objects
    icon          : null,     // string or function, font icon name
    img           : null,     // css class of the image that will appear on the left
    style         : '',       // additional style for the node
    class         : '',       // additional clas name for the node
    count         : '',       // text of the badge that will appear on the right
    route         : null,     // route for the node
    selected      : false,    // indicates if node is selected
    expanded      : false,    // indicates if node is expanded
    hidden        : false,    // indicates if node is hidden
    disabled      : false,    // indicates is node is disabled
    group         : false,    // indicates if node is a group
    groupShowHide : true,     // indicates if to display show/hide link for groups
    collapsible   : true,     // indicates if node can be collapsible
    plus          : false,    // if true, then + will be shown even if there is no sub nodes
    childOffset   : 0,        // additional offset for all child nodes
    // events
    onClick       : null,     // mouse click event handler
    onDblClick    : null,     // mouse double click event handler
    onContextMenu : null,     // mouse right click event handler
    onExpand      : null,     // node expand event handler
    onCollapse    : null,     // node collapsed event handler
    // internal
    parent        : null,     // reference to a parent node object
    sidebar       : null      // reference to the sidebar the node belongs to
}]

Replace for Python class , sqlachemist model

s/\( \+\)\(\w\+\|\w\+_\w\+\)\( \+\|\)\(: \+\)\(false\|true\|null\|\[\]\|{}\|\d\{1,\}\|''\|'\w\+'\)\(, \+\|\)\(\/\/\)\(.*$\)/\2 = Column(String,server_default=text("\5"),comment="\8")/g

Result

class Model(BaseModel):
    __tablename__='MyTable'

    sidebar_id = Column(String,server_default=text("null"),comment=" id of the node, must be unique for the whole sidebar")
    text = Column(String,server_default=text("''"),comment=" string or function, text for the node")
    order = Column(String,server_default=text("null"),comment=" if defined, will be used for sorting, otherwiser text  will be used")
    nodes = Column(String,server_default=text("[]"),comment=" array of sub node objects")
    icon = Column(String,server_default=text("null"),comment=" string or function, font icon name")
    img = Column(String,server_default=text("null"),comment=" css class of the image that will appear on the left")
    style = Column(String,server_default=text("''"),comment=" additional style for the node")
    class = Column(String,server_default=text("''"),comment=" additional clas name for the node")
    count = Column(String,server_default=text("''"),comment=" text of the badge that will appear on the right")
    route = Column(String,server_default=text("null"),comment=" route for the node")
    selected = Column(String,server_default=text("false"),comment=" indicates if node is selected")
    expanded = Column(String,server_default=text("false"),comment=" indicates if node is expanded")
    hidden = Column(String,server_default=text("false"),comment=" indicates if node is hidden")
    disabled = Column(String,server_default=text("false"),comment=" indicates is node is disabled")
    group = Column(String,server_default=text("false"),comment=" indicates if node is a group")
    groupShowHide = Column(String,server_default=text("true"),comment=" indicates if to display show/hide link for groups")
    collapsible = Column(String,server_default=text("true"),comment=" indicates if node can be collapsible")
    plus = Column(String,server_default=text("false"),comment=" if true, then + will be shown even if there is no sub nodes")
    childOffset = Column(String,server_default=text("0"),comment=" additional offset for all child nodes")
    # events
    onClick = Column(String,server_default=text("null"),comment=" mouse click event handler")
    onDblClick = Column(String,server_default=text("null"),comment=" mouse double click event handler")
    onContextMenu = Column(String,server_default=text("null"),comment=" mouse right click event handler")
    onExpand = Column(String,server_default=text("null"),comment=" node expand event handler")
    onCollapse = Column(String,server_default=text("null"),comment=" node collapsed event handler")
    # internal
    parent = Column(String,server_default=text("null"),comment=" reference to a parent node object")
    sidebar       : null      // reference to the sidebar the node belongs to

Last update: Sep 10, 2026