Code Block Macro on Insert Menu?

The Diamond Z October 19, 2011

Our Confluence Wiki (4.0) has a lot of source code examples,

Is there:

  • A shortcut to insert a Code Block Macro (in the absence of markup)?
  • A way to get the Code Block Macro on the Insert menu when editing?

So at the moment I have to choose Insert | Other Macros | Formatting | Code Block

I'm hoping for something faster/easier

2 answers

1 accepted

6 votes
Answer accepted
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
October 19, 2011
Doesn't the auto complete help you? I just type {code then hit enter. It seems to work better than using my mouse to achieve the same task.
The Diamond Z October 19, 2011

Ah, I see the problem.

As a long time confluence user I'm used to typing the {code} macro with brackets.

If I type slowly enough, the auto complete catches up and inserts the new graphical block thing.

Not a fan.

Is there any way to set the defaults for a code block (i.e. we're always using the same language, same theme).

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
October 19, 2011

I've not noticed a lag problem with the auto complete, but have heard from others on Atlassian Answers that it can be slow. I must admit that I'd like it to just insert a code block when I type {code} or {code:lang=html}, but that's not the current behaviour. I'm sure they'll catch up and improve the editor a lot in subsequent releases :P

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 20, 2011

You can configure the default language and theme in the plugin's administration page: http://confluence/admin/plugins/newcode/configure.action

Deleted user August 25, 2016

Although this is an old thread, I still did not find any solution like what David supposed... is there something?

Background: I type quickly, and inbetween I often need to insert code snippets of several code types. It is essential to have the possibility to set the code type by typing, not via mouse - with the mouse it needs actually too much time.

That is extremely annoying, and hence I hope, that maybe I just overlooked the needed feature?

Deleted user August 25, 2016

Okay, got it myself, was just too much confused by the auto complete popup - typing "{code:language=bash}" did it f.e., and "{code:lang=bash}" seemingly, too (but in the latter case it is not preset in the edit formular). Before I had always typed "{code:language=bash<Enter>". That was the error. Closing the input with '}' opens the code box like expected.

It's a bit verbose, but it works for me.

2 votes
Mahendar Muthu April 30, 2019

This {code is not working in the latest version of JIRA

Adam Buga August 7, 2019

I just noticed this... 

 

I was uploading Markdown converted to HTML content via the Confluence REST API (during a Github Wiki Migration).

When using this method, I could have "Code Blocks".

On pages where I'm creating Pages form the Confluence UI, I have no such option.

I just get the generic non-themed text.

 

VVVV Created w/ Confluence UI

Screen Shot 2019-08-07 at 3.47.28 PM.png

Screen Shot 2019-08-07 at 3.47.46 PM.png

 

 

 

VVVV Uploaded via REST API...

Screen Shot 2019-08-07 at 3.57.48 PM.pngScreen Shot 2019-08-07 at 3.58.54 PM.pngScreen Shot 2019-08-07 at 3.57.25 PM.png

 

 

These seems completely wrong.

Dima Kovalyov August 14, 2019

It works with / instead according to:
https://community.atlassian.com/t5/Confluence-discussions/Try-out-the-new-editing-experience/td-p/1000813

A single autocomplete shortcut: Type / to open a menu and add macros, tables, emojis, mentions and more to your page as you go.

Like William Walsh likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events