typora-issues
typora-issues copied to clipboard
set default programming language for document
It would be nice if there is a global option per document to set the used programming language, so whenever i'm writing a code block, i get the default language preset for me, and i can modify if i need for certain code blocks.
I use Typora to write programming guides and notes, and i hate specifying the code block programming language every time i write "```".
This is very similar to what I suggested in #184, which was closed as "won't fix". Rather than default for the whole doc, I would even be happy if it defaulted to the previously selected one. I agree 100% that picking the same language every time is a hassle in a large doc with many code blocks.
@AlexPasternak for sure wouldnt mind the same as previous, although its a little inconvenient when you want to have one c++ block then one javascript block in alternation for example..
Sure, that makes sense, and I sometimes have alternating syntax blocks in documentation or notes as well. If a default setting would help to set the right syntax in ~ 50% of those cases, that would already be less work for me as a user.
I'm looking forward to this function, too. Recently, I'm learning Python, I have typed too many ```python.
I use Typora to write programming notes, and I cant stand specifying the code block programming language every time.
I'm very glad to hear others' supporting this basic function. When you type notes or docs that include code blocks, it becomes an obvious need. I really hope this is added soon in some form.
+++
I am considering improving this part by approaches like
a. better auto-complete function (auto suggestion the most recent one by default)
b. decide default code block language by file extension. e.g. test.js.md -> js is the default language.
c. add typora-default-lang in code fences.
Anyway, first, there should be an intuitive way for this kind of setting.
I suggest a menu option, when we click it, we can choose a language. Then Typora will fill language setting of all code fences in which language haven't been set.
Towards those code fence modified by Typora, a special background color will show for distinction. But when we save this file(Ctrl+S), it will recover to normal style.
Example:

Totally agree with this suggestion. I am an R user. Typora will be perfect if this problem could be solved.
This is definitely the functionality I'm looking for. Writing ```{lang} repeatedly is neither pleasant nor productive.
Support.
My notes always contain only one language so it's counterproductive and counterintuitive to have to keep selecting the language when making a new block.
Toaco's suggestion looks like a potentially good way of implementing this, or otherwise at least auto-detect most recent language.
Misspelling in the issue title: "lanauge".
highly recommended:c. add typora-default-lang in code @abnerlee It can save more tedious, faster writing.
Yes! If setting the default code language is possible, it would be more productive for programmers.
- #1639 related to this somehow
Totally agree with this suggestion. I am a javascript user, and really need this feature.
I too would love to see this feature implemented.
When I was about to submit this question, I found that so many friends were already troubled by it. I, too, used shortcut keys to create a code block almost all the time in my daily writing, but every time I needed to define a language to color the code, the more I used it, the more uncomfortable I felt. I hope this problem with a long history can be solved as soon as possible!
I hope this problem with a long history can be solved as soon as possible!
Indeed we're now "celebrating" the 3-year anniversary (!) of when I raised this as an issue in https://github.com/typora/typora-issues/issues/184. Still no easy workaround for this outside of something like a Keyboard Maestro macro that expands the MD code block with a language of choice (like !cj for ```java).
Haha, there is an old saying in China that "Great minds think alike". It suddenly occurred to me that we are so attached to the problem of code block coloring. In fact, it is because no color by default looks uncomfortable, because when I use other markdown tools, when I use shortcut keys to define a code block, it will be highlighted immediately. Even if it does not necessarily show the corresponding highlight according to the corresponding language, at least there is color display, which is also gratifying. I don't know if developers are willing to expend energy on this matter.
Still no easy workaround for this outside of something like a Keyboard Maestro macro that expands the MD code block with a language of choice (like !cj for ```java).
Agree. I really hope typora can add this simple function so that I don't need to specify the programming language repeatedly in the same file.. which is quite annoying.
Is there any update on this issue?
Any updates ?
any updates ?
any updates :D?
Any updates on this issue?
any updates ?
why don't do it ??
I would LOVE to see this feature. I really love Typora. Please? 🥺