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
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
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.
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.
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