How do you find and replace a newline?

Things I have tried

Tried to copy and paste the area between the last line and the new line. Also tried /n \n.

What I’m trying to do

How do you find and replace a newline? There is another post that suggests using VS Code, but I’d like to know about Obsidian.

Can you elaborate on what you want to do exactly?

This doesn’t exactly answer your question but you can use vim to do this. Obsidian has a vim mode but it doesn’t seem to support these commands, which is quite unfortunate.

Here’s an example:

# Important Note


Text 1



Text 2







Text 3

You can run:

:g/^$/d

to get

# Important Note
Text 1
Text 2
Text 3

Or

:%s/\n\{3,}/\r\r/e

to get

# Important Note

Text 1

Text 2

Text 3

If someone knows how to make these commands work in CodeMirror’s vim mode, please let me know.

I don’t think this is possible in Obsidian at the moment, as find and replace does not recognize regex.

Regex functionality for find and replace within obsidian

You might try copying and pasting a newline character into the find text field.

I’m going to work on learning VIM next! Thanks

I wonder how to request this for a future build

Already done in the thread linked above. Just add your +1 to it.

If you’re on Windows, the excellent freeware text editor Notepad++ does this very handily, using regex or it’s own “extended” search and replace.

Adding a regex mode to Obsidian would be excellent.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.