search and replace in tiddlers

141 views
Skip to first unread message

Mohammad

unread,
Feb 13, 2019, 5:16:55 PM2/13/19
to TiddlyWiki
Is there any way to search and replace in
Tiddlers
  • text
  • field value
for example search foo and replace with bar?


--Mohammad

@TiddlyTweeter

unread,
Feb 13, 2019, 5:35:02 PM2/13/19
to TiddlyWiki
Do you mean across the whole of a TiddlyWiki?

Or just within a Tiddler?

J.

TonyM

unread,
Feb 13, 2019, 8:20:23 PM2/13/19
to TiddlyWiki
Using filters you can test for particular values in fields SEARCH and use a button and action widget to setfield values REPLACE either for one tiddler or a batch of tiddlers.

If your field contains multiple values you may need to use the list operators to change one only in a list.

Global search and replace can be done opening the whole wiki in a text editor but you must be careful not to change the wrong values. Backup if doing this.

Regards
Tony

Mark S.

unread,
Feb 13, 2019, 8:35:59 PM2/13/19
to TiddlyWiki
AFAIK, unless there's some brand-new operators, you can't actually replace text *inside* of tiddler text or fields. For that you'll need some 3rd party macro or widget.

-- Mark

TonyM

unread,
Feb 13, 2019, 10:37:14 PM2/13/19
to TiddlyWiki
Mark

I belive what you say to be generaly true yet recall an auto tag or auto l8nk plugin that scans text to find and change things.

Hmmmm

Regards
Tony

Mohammad

unread,
Feb 13, 2019, 10:39:12 PM2/13/19
to TiddlyWiki
Just in tiddler.
M.

Mohammad

unread,
Feb 13, 2019, 10:39:53 PM2/13/19
to TiddlyWiki
Is these any existing macro to do that?

TonyM

unread,
Feb 13, 2019, 10:56:16 PM2/13/19
to TiddlyWiki
Mohammad,

There is an additional plugin for search and replace in code mirror. In the regular editor and text areas the browser search and replace can be used, and browser plugins found that help.

For large and complex tiddlers i prefer to use a browser plugin to open the text area in an external editor like notepad++ which has superior search and replace like including linefeed and tabs.

I believe the visual editor also has a search and replace.

Regards
Tony

Birthe C

unread,
Feb 14, 2019, 12:16:36 AM2/14/19
to TiddlyWiki
Hi Mohammad,


You are always busy, having good ideas. I enjoy it very much.

Birthe

Mohammad

unread,
Feb 14, 2019, 1:03:11 AM2/14/19
to tiddl...@googlegroups.com
Thanks Birthe.

Thanks for your kind words! I gonna to be among the Tiddlywiki Noble Prize winners :-)  (the best joke of 2019!!)

--Mohammad

Mohammad

unread,
Feb 14, 2019, 1:05:28 AM2/14/19
to TiddlyWiki
Tony,
 I am looking to find a way to replace a word/phrase using Tiddler Commander!
But seems not straightforward at all!!

So, I ignore it and will wait to see when TW  itself supports such feature.

--Mohammad

tony

unread,
Feb 14, 2019, 1:09:51 AM2/14/19
to TiddlyWiki
The command mode from the CodeMirror plugin with CodeMirror Keymap: vim 

works quite lovely with

:%s/foo/bar/gc

Even more delicious is that yanks work across the tiddlers, ie yy to yank a line in one tiddler, open a different tiddler and p to paste

Heck, even :sort to sort all lines in the tiddlers work

Good stuff!

Best,
tony


On Wednesday, February 13, 2019 at 2:16:55 PM UTC-8, Mohammad wrote:

Mohammad

unread,
Feb 14, 2019, 1:34:08 AM2/14/19
to TiddlyWiki
Yep,
 That is really handy! Specially when you write codes

Thanks Tnoy for the hint!

Cheers
Mohammad

Mark S.

unread,
Feb 14, 2019, 11:40:59 AM2/14/19
to TiddlyWiki
Here's a javascript macro you can play with in a safe place. It's just a think javascript macro wrapped around the underlying javascript system, so I'm sure it could be improved.

Invoke like:

<<regexpsub "(\w+)\s(\w+)" '$2, $1' "John Doe">>

Parameters regtext (which can be a regular expression, but also plain text if it's been escaped), subtext (the text to replace found text with. Note $1,$2... for replacing groups in regtext), and the text itself.

-- Mark
$__MAS_macros_regexpsub.json

Mohammad

unread,
Feb 14, 2019, 12:14:47 PM2/14/19
to TiddlyWiki
Many thanks Mark,
 I will return to you with my evaluation result.

Cheers
Mohammad

Mohammad

unread,
Feb 14, 2019, 2:11:20 PM2/14/19
to TiddlyWiki
Hi Mark,
 It works great! Some question:

The macro has three parameters
  • text
  • subtext
  • regtext
Is it possible to send a whole tiddler to macro, e.g text=<<currentTiddler>> ?

does regtext accept the same JS regexp expression?

--Mohammad

Mohammad

unread,
Feb 14, 2019, 2:29:08 PM2/14/19
to TiddlyWiki
If I can send rexexp pattern, then can I extract few character of some words or phrases?


On Thursday, February 14, 2019 at 8:10:59 PM UTC+3:30, Mark S. wrote:

Mark S.

unread,
Feb 14, 2019, 2:47:24 PM2/14/19
to TiddlyWiki
Do it as a macrocall:

<$macrocall $name="regexpsub" regtext="Hello" subtext="Goodbye" text={{HelloThere}}/>

-- Mark

Mohammad

unread,
Feb 14, 2019, 2:54:02 PM2/14/19
to TiddlyWiki
Got it!

@TiddlyTweeter

unread,
Feb 14, 2019, 3:16:29 PM2/14/19
to TiddlyWiki
Though I don't grasp the mechanics I can see this is exciting !

Mohammad

unread,
Feb 14, 2019, 3:48:52 PM2/14/19
to tiddl...@googlegroups.com
Hi Josiah,
 I am experimenting to see how Commander can search in tiddlers meet some criteria and makes search/replace subtexts!
Also for tiddler partial renaming, for example change  the word `exmp` with a word `sample`in title of a set of tiddlers all have in their title the word exmp.


--Mohammad

Mohammad

unread,
Feb 20, 2019, 4:36:00 PM2/20/19
to TiddlyWiki
This is now partially works in TW-Commander,

see


Best
Mohammad
Reply all
Reply to author
Forward
0 new messages