How do I insert text into a a note at a very specific location in the note?
The method Vault.append()
inserts text to the bottom of the note. And Vault.modify()
doesn’t exactly insert text, it completely rewrites the whole note into a new string.
I’m not very experienced with TS. I managed to do app.vault.append(currentFile,"\nHello world!")
and it worked. I’d like a similar command to insert text.
As for rejecting modify()
, maybe my intuition is misguided, but I would rather actually insert text into a specific place, and avoid recreating the whole note. My unthought reasons are: 1. It seems more likely to lead to accidental corruption of the note; 2. Obsidian might not be able to properly understand that the change was small which would be relevant for Obsidian sync; 3. Incompatibility with the cursor: text insertion before the cursor should push it, should just confuse the cursor;
So append,modify,process don’t seem great. I think maybe transaction()
and EditorTransaction
might be related but I have no idea what they do.