Default language for code blocks

Hey,

Since logseq supports the possibility to add a language to the codeblock for syntax highlighting, I would suggest that somehow it would be possible to set a kind of default language for every new codeblock.

In my case I always have to add “kotlin” for my codeblocks, because in 99.999% of all cases I only write kotlin code into logseq for the moment.

Possible workaround is maybe to create a template, but I’m not sure if this would be faster…
(is there a possibility to add a template via shortcut?)

Thanks!

I like the idea of having the ability to set a default language for code block.

In the interim, you can add this command to your config.edn and them use that every time you need to add a code block for kotlin

 :commands [
     ["kotlin" [[:editor/input "```kotling\n\n```" {:backward-pos 4}]]]

How do I use it?

  • use the slash command: /kotlin

I hope this helps a bit :slight_smile:

2 Likes

perfect, I will try this immediately. thank you

edit: unfortunately every time the config file gets reset (i also added the missing “]”) :slightly_frowning_face:

Will that work if we use template also?

Yes, you can use a template too. But you will have to do it in two steps (type /template, then type the template name). Using is command is one step, therefore quicker.

1 Like