typora/typora-issues

set default programming language for document

Closed this issue Β· 53 comments

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.

toaco commented

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.

toaco commented

+++

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.

toaco commented

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:
jeb yymlbga11 o nbe6 xs

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.

mlntr commented

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.

yoo0 commented

Yes! If setting the default code language is possible, it would be more productive for programmers.

obar1 commented
  • #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 #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 ?

pycgo commented

why don't do it ??

4N7 commented

I would LOVE to see this feature. I really love Typora. Please? πŸ₯Ί

Why is it still not there yet :/

Also interested! In my class, we're only using Java, so having to write ```java for every code block (I use around 5-10 per note; 1 note per lecture), is definitely a hassle.

Bumping this. This is such a frustrating omission in an otherwise fantastic app. It's the only reason I keep an eye out for an alternative md editor.

hope to add this function

Happy belated 5th anniversary to this request. May it one day see the light of day.

one day..

wow, it has been 5 years? I'm new in programming but also wish to add this function

Now that Typora isn't free any more I guess the need for this feature is gone for many people.
I also switched to an alternative although I liked Typora's copy, paste and save image functionality. But sorry, not paying for this particular feature in closed source software. 😁

This is my first time hearing that Typora has exited beta and is now a paid product. I always said I would buy it, and registered for a license immediately. As a paid user, I still need and would like this feature, even if it's years later. This would be a huge "Finally" to take care of.

This is my first time hearing that Typora has exited beta and is now a paid product. I always said I would buy it, and registered for a license immediately. As a paid user, I still need and would like this feature, even if it's years later. This would be a huge "Finally" to take care of.

Found a way to get around with the shortcut app named "BetterTouchTool". My set up is that once typing shift+`, it automatically replaces with ```python + enter. This video might be helpful. https://www.youtube.com/watch?v=8C5C9yZlkWY
image

When this is implemented I'll buy a license.

Bump this up. Would LOVE this feature...

i am using an espanso shortcut

i am using an espanso shortcut

Like to share? ;)

can be converted topython (or any other shortcut as per your convenience )
please install espanso -
https://espanso.org/

same problem ,looking forward to implemente this function

Despite buying a licence for Typora, the lack of support for some features led me to switch to Obsidian. Not only is it free, it supports plugins, and the community is excellent. I have one that provides Git integration, and another plugin provides selection of default language when selecting and creating a code block (I have a couple of shortcuts assigned for csharp and js). Very customisable.

Recommended.

Any updates on this? Would be so happy to be able to set the code language just once...

6Fv commented

This has been a highly requested feature for 7 years. Any plans of implementing it? Thanks

If so… please consider existing documents (with existing code blocks) when creating this feature.

This has been a highly requested feature for 7 years. Any plans of implementing it? Thanks

If so… please consider existing documents (with existing code blocks) when creating this feature.

I can share something about it.

In windows, you can use AutoHotkey to do it. Relevant syntax is available for reference: https://clzly.xyz/Technology/a36b636c/#%E9%92%88%E5%AF%B9%E7%89%B9%E5%88%AB%E5%BA%94%E7%94%A8

In Mac, you can use Automator to do it. Unfortunately, I lost my source code and was never able to implement it again.

I still want to be able to implement this feature, whether it is a single file implementation or a software level implementation, I can live with it.

4N7 commented

This has been a highly requested feature for 7 years. Any plans of implementing it? Thanks
If so… please consider existing documents (with existing code blocks) when creating this feature.

I can share something about it.

In windows, you can use AutoHotkey to do it. Relevant syntax is available for reference: https://clzly.xyz/Technology/a36b636c/#%E9%92%88%E5%AF%B9%E7%89%B9%E5%88%AB%E5%BA%94%E7%94%A8

In Mac, you can use Automator to do it. Unfortunately, I lost my source code and was never able to implement it again.

I still want to be able to implement this feature, whether it is a single file implementation or a software level implementation, I can live with it.

This has been suggested, but I’m out of band-aids. I’m requesting native support.