"Find and Replace" in Matlab Editor

44 ビュー (過去 30 日間)
Andre Zeug
Andre Zeug 2019 年 8 月 14 日
回答済み: Andre Zeug 2019 年 8 月 20 日
Hi there,
is there a way to specifically search (and replace) only in code lines or only in commented text?
Thanks

採用された回答

Neuropragmatist
Neuropragmatist 2019 年 8 月 14 日
I don't think this is a feature in Matlab's find & replace utility.
You could write your own code to do this though - just open a function as a text file and search for the word you want to replace. If it occurs after a % symbol it is probably a comment if not it is probably code.
The problem would be that many functions working with strings (such as sprintf) also utilise % symbols, so that would require some thought. The Matlab editor can differentiate comments from code though, so there may be some Matlab internal function you could utilise for that.
M.
  2 件のコメント
Andre Zeug
Andre Zeug 2019 年 8 月 14 日
thanks for fast reply.
"I don't think this is a feature in Matlab's find & replace utility."
I don't think so as well, but would be nice to be implemented.
"The Matlab editor can differentiate comments from code though, so there may be some Matlab internal function you could utilise for that."
Does anybody know such internal Matlab function?
A.
Rik
Rik 2019 年 8 月 14 日
To hook into the parser you will probably have to use some Java hacks. That often breaks between releases, so if you're looking for a stable solution you'll have to write something yourself.
You might have a look at how notepad++ and/or GNU Octave handle the parsing, because they seem to have it figured out.
For my spellchecker FEX submission I didn't bother and only used the percent and ellipsis as comment markers, which is close enough for that application.

サインインしてコメントする。

その他の回答 (2 件)

Steven Lord
Steven Lord 2019 年 8 月 14 日
I don't believe there is such functionaltiy in the Editor, but this seems like a reasonable enhancement request to file with Technical Support. Use the telephone icon in the upper-right corner of this page to send it to Support.
  1 件のコメント
Andre Zeug
Andre Zeug 2019 年 8 月 14 日
Thanks Steven, I requested to Tech Support.
We will see what happens :-)
A.

サインインしてコメントする。


Andre Zeug
Andre Zeug 2019 年 8 月 20 日
Here is the anwer from Mathworks Technical Support:
"...I am writing in reference to your Technical Support Case #03742137 regarding 'AddOn to "Find and Replace" in Matlab Editor'.
... I have reported this enhancement feature to my colleagues in development team,
and they would consider integrating this useful feature. Thank you for bringing it to our notice."
A.

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by