Regex-based matching and sustitution with nano?

后端 未结 3 1642
时光取名叫无心
时光取名叫无心 2020-12-17 09:33

I am aware of nano\'s search and replace functionality, but is it capable of using regular expressions for matching and substitution (particularly substitutions

3条回答
  •  萌比男神i
    2020-12-17 10:27

    You need to add, or un-comment, the following entry in your global nanorc file (on my machine, it was /etc/nanorc):

    set regexp
    

    Then fire up a new terminal and press CTRL + / and do your replacements which should now be regex-aware.

    EDIT


    Search for conf->(\S+):

    enter image description here


    Replace with \1_conf

    enter image description here


    Press a to replace all occurrences:

    enter image description here


    End result:

    enter image description here

提交回复
热议问题