A terminal command you use often, an SQL query, a Python function or a config file... These get lost in plain text, and it's hard to tell where your code starts and ends. A code block keeps your code in its own box, apart from the rest of your writing, with its lines and spaces intact.
In four steps, we'll cover how to add a code block, write your code and leave the block, pick a language to color your code, and copy your code in one click.
1
Add a code block
There are four ways to add a code block to your note:
- On an empty line, type /code and choose Code Block in the menu that opens.
- On an empty line, type three backticks (```), then press the space bar or Enter.
- While you're on the line you want to turn into a code block, use the shortcut Ctrl + Alt + C (Cmd + Option + C on a Mac).
- To turn a line you've already written into a code block, hover over the line, click the six-dot handle that appears on the left, click Turn into and choose Code Block in the list that opens.
When you turn a line into a code block, your text stays where it is, but formatting like bold, italic, links or text color is removed. You can't format text inside a code block; Pumpynotes colors it based on the code's language.
My Python notes
A function that adds up the numbers in a list:
/code
Code Block
Command menu · type /code and Code Block appears
2
Write your code and leave the block
Inside a code block, Enter starts a new line, so you can write as many lines as you like. To indent, press Tab while your cursor is at the start of a line, and the line moves two spaces in; if you select several lines and press Tab, they all move together. To undo it, press Shift + Tab. Any spaces and tabs you type or paste stay exactly as they are.
When you're done, there are two ways to leave the block:
- Press Enter three times in a row at the end of the last line. The two empty lines this creates are removed, and your cursor moves to a new line below the block.
- With your cursor at the end of the last line, press the down arrow key on your keyboard. If there's something else below the block, your cursor moves there; if not, a new line is added.
My Python notes
A function that adds up the numbers in a list:
Auto
# Add up the numbers in a list
def
total
(numbers
):
result = 0
for
number in
numbers:
result += number
return
resultAt the start of a line, Tab indents by two spaces
3
Pick a language to color your code
A code block automatically colors your code: the language's own keywords (for example import, for), text in quotes, numbers and comment lines each show in a different color. In the dark theme, the colors also switch to shades that suit the dark background.
When you hover over a code block, a language picker appears in the top left. Auto is selected at first, and Pumpynotes guesses which language your code is in. With very short snippets of just a few words, this guess can be wrong, so you'll get better results if you pick the language yourself: choose one of JavaScript, TypeScript, JSX, TSX, HTML, CSS, JSON, Python, Java, C, C++, C#, PHP, SQL, Bash, Go, Rust, YAML and Markdown, and the colors change to match that language right away.
You can also set the language as you open the block: type ```python or ```javascript at the start of a line and press Enter, and the code block opens with that language selected. Short names like ```js, ```ts and ```py work too.
My Python notes
A function that adds up the numbers in a list:
Python
# Add up the numbers in a list
def
total
(numbers
):
result = 0
for
number in
numbers:
result += number
return
resultLanguage picker · pick Python and the code is colored as Python
4
Copy your code in one click
Right next to the language picker, there's a copy icon made of two overlapping squares; when you hover over it, it says Copy. Click it, and all the code in the block is copied to your clipboard, lines and spaces included, and Copied appears at the bottom of the screen. Now you can paste the code into your terminal or code editor.
You don't need to select the code with your mouse, so you won't accidentally leave out the first or last line of a long snippet.
My Python notes
A function that adds up the numbers in a list:
Python
# Add up the numbers in a list
def
total
(numbers
):
result = 0
for
number in
numbers:
result += number
return
resultCopy icon · copies all the code to your clipboard
Frequently asked questions
What happens when I paste code I copied from VS Code?
If you paste code you copied from VS Code onto an empty line in your note, Pumpynotes automatically puts it in a code block and picks its language too. If you paste it inside an existing code block, the code is added as plain text and the block's language doesn't change.
What's the difference between a code block and inline code?
Inline code is for setting apart a single command or file name within a sentence: select the text and click the <> (Code) button in the toolbar that appears. If you want several lines of code, coloring or copying in one click, a code block is easier. We cover inline code in Format text in your note and add links.
Can I color a code block?
You can change the block's background color by choosing Color in the handle menu; only background colors are available for code blocks. Text color isn't applied in a code block, because Pumpynotes colors the code based on its language. We cover coloring blocks in Move, convert and color your blocks.
Can I add a code block on my phone too?
Yes. When you use Pumpynotes in your phone's browser, /code and three backticks work there too. On your phone, the language picker and the copy icon appear when you tap the code block.
Can people I share a note with copy the code?
Yes. Everyone who can see the note sees the code block in color and can use the copy icon. Someone with view-only access can't change the language; on their screen, the name of the selected language appears where the language picker is, or Auto if no language was selected. We cover sharing in Share notes, events and wallets.
Which plans include this feature?
Code blocks are available on all plans, including Free.