Missing copy button for codeblock in edit mode, when the page only has 1 code block

For every page with a single codeblock (I have many of these), I have to switch to Reading View every time I want to copy the block. This is very frustrating

Pages with multiple elements or codeblocks show a copy button on the codeblocks. This is great, I don’t need to switch to Reading View just to copy the block.

Steps to reproduce:

  • Create new note
  • Type “```” (triple backtick) to create a new codeblock
  • Type anything inside the codeblock
  • There is no Copy button showing on the codeblock
  • Try clicking the page title or anywhere else to “exit” the codeblock, you cannot. I think perhaps the reason the copy button does not show is because the codeblock is in edit state? Actually I always want the copy button even while editing

I have these settings:

  • Reading view: unticked
  • Source mode: unticked

Please include your environment / debug info in bug reports. Thanks.


By chance, are you not closing the code block with another set of backticks? The behavior you describe sounds like there are only an opening set of backticks. i.e. the entire note is a code block.

This is what I see on my end with only one code block in a note:

```css <-open
body {
  --tab-font-size: 22px;
}
``` <-close

Obsidian_Z2kQysNVFP

When I type triple backtick it automatically ads the closing backticks, so it’s not because I haven’t closed the block.

Windows 11, Obsidian 1.7.4
Plugins disabled

I looked in the troubleshoting guide that’s linked when you create a new bug, and I see no mention of how to include debug info

I notice on other pages with multiple elements, the little “language/copy” button shows, but if I click inside the codeblock to edit, the button vanishes.

Can I force the button to always show?

Run the Show debug info command and paste it into the report. It helps the team get an idea of your setup without a lot of back-and-forth. (I don’t think you need to at this point, but it couldn’t hurt).

Okay, good. So it’s not that.


When you are in the fenced code block, even on the lines with the backticks, the copy button isn’t shown. That’s not new behavior that I can recall.

Try creating a few new lines (blank lines) under your code block and move your cursor in there if there’s aren’t any already. Also, if you click outside of Obsidian, the copy button will appear even if there are only three lines in the note.

explorer_pN61T9AsCI

If I do a newline after the codeblock, the copy button appears.

However, if its a long codeblock, then I have to move the cursor down to the newline, then scroll back up the page to find the copy button.

It would be nice if the copy button could just show. Or if by clicking on the pagetitle it would cause the copy button to show

SYSTEM INFO:
	Obsidian version: v1.7.4
	Installer version: v1.7.4
	Operating system: Windows 11 Pro 10.0.22631
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 1
	Restricted mode: on

The behavior may not be what you like or expect, but I don’t think this is a bug. Let’s see what the team thinks.


You can leave a blank line or two at the top of those notes so you can easily move your cursor / click in there for the copy button to show.

It’s really not consistant.

Sometimes I just can’t get the copy button to show, no matter where I click, or where my cursor is.

Do you have any suggestions on how to force the button always to show?