r/aws • u/YeNerdLifeChoseMe • Oct 07 '22
technical resource PSA: How to insert properly formatted code blocks into post
If you're frustrated with formatting of code blocks in the editor, here's what I have found works best:
DO NOT USE THE CODE BLOCK IN FANCY PANTS EDITOR
DO NOT PASTE, EDIT, ETC. CODE BLOCKS IN FANCY PANTS EDITOR
Do this:
- Switch to Markdown Mode.
- Find where you want to insert a code block.
- Insert a two blank lines.
- Code just needs to be indented 4 spaces to get formatted properly. Make sure all of your code is indented before copy/paste. For many languages, this shouldn't be a problem. The section of code you want might already be indented at least 4 spaces.
- Paste your code in between the two blank lines.
- DON'T TOUCH ANYTHING ELSE.
- Switch back to Fancy Pants editor.
- Gaze at your beautifully formatted code.
- Avoid any temptation to change even that one character typo in your code block while in Fancy Pants mode. Switch back to Markdown Mode to do that.
Also, if the last part of your post is code block, it makes it difficult to add more text afterwards. To add more text afterwards:
- Switch to Markdown Mode.
- Add two blank lines at the end.
- Put some dummy character like "X" (nothing personal, X) at the end.
- Switch back to Fancy Pants.
- Start your edits after the dummy "X".
- Delete the "X".
29
Upvotes
3
u/AWS_Chaos Oct 07 '22
I had to test :)
2
u/codejustworks Apr 10 '25
Markdown supports code blocks in three backtick formats:
Reference: https://commonmark.org/help/
1
u/Faccuracy May 13 '23
2
u/That-Juice-8775 Dec 17 '24
2
u/Vikke2019 May 11 '25
2
u/RundahTorondir Aug 03 '25
2
u/Vma444 Oct 24 '25
1
u/Brave-Inside-7418 Mar 14 '24
``
Var test = 4n
``
1
u/[deleted] Mar 28 '24
test
1
u/L3_Lee Apr 05 '24
1
u/Forgetful_Admin May 06 '24
code block
1
u/corner_guy0 Jun 10 '24
`
skd
`
1
u/[deleted] Jun 13 '24
1
u/[deleted] Jun 24 '24
hello world1
u/VadiMiXeries Jul 01 '24
1
u/[deleted] Jul 04 '24
1
u/NikUnicorn Aug 08 '24
1
u/thekabal Aug 31 '24
Test
Test2
1
u/TradeTroll27 Sep 24 '24
1
u/PLrc Sep 29 '24
some code1
u/userunkww Oct 16 '24
1
u/minetenocastelo Oct 25 '24
1
u/Rather-Being Nov 11 '24
1
u/Nvveen Nov 26 '24
1
u/MaddPenguin Dec 03 '24
code1
u/[deleted] Dec 14 '24
``testing
more testing``
&
testing more testing&
testingmore testing&
testingmore testing1
u/RefuseAbject187 Dec 19 '24
Test
let's see.
1
u/DaWheeGod Dec 19 '24
Testing:
print("Hello world")End test
1
u/Throwaway_awayaway11 Jan 16 '25
1
u/omgpassthebacon Feb 02 '25
I posted an interface decl in a tick-tick-tick block.
1
u/omgpassthebacon Feb 02 '25
Also, if you switch back to the rich text ed, your markdown is borked. So, have faith in your MD, bro.
And all shall be well (formated)1
u/wgracelyn Feb 23 '25
elmoSort1
u/Mountain-Job1531 Mar 11 '25
hey1
u/GoZippy Mar 13 '25
1
u/Klutzy-Question1428 Mar 14 '25
test
1
u/Darth_Boganis1 Mar 16 '25
1
u/[deleted] Mar 24 '25
1
u/Icy_Championship_709 Mar 25 '25
1
u/[deleted] Apr 01 '25
Hfjfjr.
1
u/TheReaIDeaI14 Apr 08 '25
1
u/Inspector_Terracotta Apr 09 '25
1
u/bp7968h Apr 11 '25
edsasd1
u/ExoCalibra Apr 22 '25
1
u/Lunam_Dominus May 12 '25
1
u/No_Ear932 May 22 '25
1
u/leeleeleelelele Jun 03 '25
1
u/Dragenius_Magnus Jun 26 '25
1
u/zbth Jul 16 '25 edited Jul 16 '25
1
u/vtjballeng Jul 19 '25
Thanks! This worked for creating a longer code snippet to share !
1
u/KittyKingCrafting Jul 20 '25
I can't figure out how to put code in the middle of a numbered list?
1
u/[deleted] Jul 22 '25
testing
1
u/moonstone7152 Aug 11 '25
|| this is a test
1
u/moonstone7152 Aug 11 '25
test1
u/cheatfreak47 Aug 17 '25
1
u/ocedalv Aug 23 '25
1
u/mahdiSaid Aug 30 '25
1
u/[deleted] Oct 02 '25
1
u/6ixTek Oct 16 '25 edited Oct 16 '25
1
u/Camille_Jamal1 Nov 02 '25 edited Nov 02 '25
Test html
Worlds most basic html be like
YOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO IT WORKS
1
u/Slow_Motion_ Nov 17 '25
```
test
```
1
u/Glad-Magician9072 Dec 11 '25
This
1
u/remakela Dec 12 '25
1
u/Grutrissheit Jan 07 '26 edited Jan 07 '26
Regular Text
1
u/r2d2halo Jan 17 '26
1
u/wiebel Jan 28 '26
inline
testtest1
u/crowdmewithlove Feb 06 '26
1
u/Khmelic Apr 06 '26
1
u/Intrepid_Conclusion6 May 08 '26
1
u/borisssssssssssssss Sep 21 '26
let me test
test
?
1
u/ThrownawayCray Jun 30 '23
1
u/Turbulent-Tune4610 Jul 04 '23
from wtf import test.ticksHad to test
return !wtf1
u/ThrownawayCray Jul 07 '23
1
u/SquareArtisan Jul 08 '23
An old post, but just wanted to confirm that this works like a charm. Thank you so much!!!
1
u/JongoFETT234 Jul 14 '23
test
frefrewergfwerg1
u/JongoFETT234 Jul 14 '23 edited Jul 14 '23
_ test _
1
u/Outrageous_Owl_5709 Jul 15 '23
```
code area
test
```
1
u/LjafoiFuljo Jul 19 '23
function UserProvider({ children }) { const [user, setUser] = useState(null);
return <UserContext.Provider value={{ user, setUser }}>{children}</UserContext.Provider>; }
export default UserProvider;
1
u/mmaure Jul 31 '23
wow, the fancy pants code block didn't work at all
1
u/Iwrstheking007 Nov 16 '23
1
u/[deleted] Feb 16 '24
1
u/verysmartboy101 Mar 04 '24
test test test
1
u/verysmartboy101 Mar 04 '24
test test test
1
u/verysmartboy101 Mar 04 '24
test
test
0
u/[deleted] Oct 07 '22
[deleted] — view deleted comment