Replace all asterisks in a given file

Things I have tried

I am trying to replace asterisks (Some of the stuff I copy from web/pdf is in italics/bold - Which is not needed, I just need plain text files with no formatting - be it bold,italics etc)
Example Text :

 The quic*k brown fox*jumps right~ over lazy dog^

Needed Text:

The quick brown fox jumps right over lazy dog.

I tried playing around with javascript/css but failed

var str = “Hello^# World/”;
str.replace(/[^a-zA-Z ]/g, “”); // “Hello World”

I am complete noob with CSS - But this is taking forever - I have been stumbling. Obsidian fails to load file - Not sure where could I look for errors or how to fix it.

I need to assign a hotkey and replace all asterisks with “” . Please help

Thank you!

What I’m trying to do

Search for asterisk, replace with nothing.

Or use paste and match style, which will strip out the source formatting.

Angel

I have over 5000 definitions , which I am researching on - and doing (Search/replace) that over and again is way time consuming then we may imagine.
I tried Macro plug-in - that I am not sure how to pass parameters and get results.

Given a choice I might want to automate it via a hot key.
Then there may be a 100 some files which I am formatting (Bold/Italic) and creating Table of Content(s)

That necessitates automation (or some help :slight_smile: )

Multiple files make a real difference. I’d open the vault with VSC or Atom and run a search and replace there.

Angel

That may make sense when I am already done researching on my notes and all my notes are ready to be searched and replaced.

But I have dictionary of terms that I am still researching - this requires lots of searching for financial terms/stock market analysis(Past/Current/different economies) - I don’t have it handy - I keep compiling information everyday - and often at times these notes are atomic (in case further research/re linking is needed) .
Hence comes “Formatted notes” - I just need to keep it simple - Plain Text and replace all formatting with spaces (only need to retain “.” or periods)
Bringing up replace box every time impedes the process.

If I understand correctly, notepad++ can easily do this in multiple files. To bring up the menu “ctrl+f”.
image
In the filters, you can select the file format. An example of selecting only text files.
image

1 Like

:slight_smile: This is where I was “inspired” to “format” my notes.

It can lower case+Upper case + Sentence Case + Title Case - my notes.

I create a note and use keyboard shortcuts - like alt+l for lower case and so on to “Format” my plain text files.

And I was trying to assign a macro/hotkey which would just replace asterisk from file/selected text (this functionality is available in the plugin link above)

I tried playing around with javascript and plugin folder - but so far no success :frowning:

2 Likes

With VSC or Atom, users can run a search and replace on all files in one go. No need to bring up the replace box multiple times. Just search in the entire vault, replace in the entire vault, save the files and it’s done.

I’ve done similar changes to 10,000 notes in my vault and the changes have taken about twenty seconds to complete and save. All done.

But perhaps I misunderstand your needs. Apologies if so.

Angel

1 Like

Its not the global replacement I am looking for.

Its for my atomic notes which are frequent where I need to automate this.

I value your inputs, Thank you!

1 Like

I say post a few examples of what you are talking about. I’m as confused as the people who have already replied. :slight_smile:

Trying to automate the process of replacing “*” in a note (frequent notes).
Where i copy my notes from has scattered asterisk and caret symbols which is annoying.

I’m still not a 100% sure what you are endeavouring to achieve, but perhaps look into the following plugin:

obsidian://show-plugin?id=obsidian-apply-patterns

1 Like

I will try it shortly and keep posted.

Thank you! :slight_smile:

If you’re just trying to paste text without any formatting, use CTRL+SHIFT+V to paste. Does that solve it?

To replace the asterisks in a note, one may have to:

  1. Identify the note needs such treatment
  2. Perform a action of replacement

Case1: For the 1st step, if you are able to identity all the notes need treatment, eg a list of note names, with the help of the search function within Obsidian, then you are able to perform a batch replacement in the 2nd step, using shell script;

Case2: if you can only perform step 1 manually, i.e. you can only identify the specific note when you read it, then you can only try to increase the efficiency when you are performing step 2.

Which case are you in?

It didnt help :frowning: pastes clipboard text as is (I tried it thrice - not sure if I may have missed combination)

:slight_smile: I am trying to graduate to Case 3: where I need to automate replacing asterisk with either “” or a single space(" ") .

I essence I am trying to remove all of following { } [ ] : " ’ @ # (except period) from my notes (Since there too many a notes, whenever I create a new note and paste - there are many a such characters that creep in.
Using Replace takes lots of time - per file.
I cannot use bulk replacement for I need to review notes once I remove junk characters for any grammatical/numerical errors. Removing these junk characters manually(find/replace) is time consuming as well as inefficient (even though I have assigned hotkeys for find/replace)

Still trying to figure plugin :frowning:

Your workflow means you are unable to choose batch find/replace and don’t want to do a find/replace action per file. But, those are your two choices.

I would take gregp’s advice from earlier and post actual examples of your input files and desired results.

1 Like

Example Text :

 The quic*k brown fox*jumps right~ over lazy dog^

Needed Text:

The quick brown fox jumps right over lazy dog.