Code blocks
Action | Hot key |
---|---|
Create code block | Start your note with ``` |
Create code block with syntax highlighting | Start your note with ```python |
Create code span | Start your note with ` |
Copy code from note | { |
Stashpad has support for code spans and code blocks, including syntax highlighting. You'll be able to copy your code out in one click or one keypress.
Code span
To create a code span, surround your text with single backticks.
Multi-line code block
To create a code block in Stashpad, wrap your text with tiple backticks. You can also specify a language for syntax highlighting.
Examples:
```
print("Hello world")
```
```python
def foo():
```
```javascript
function foo()
```
![Use backticks to write code blocks](/_next/image?url=%2Fimg%2Fdocs%2Fpower-user%2Fcode-blocks.gif&w=3840&q=75)
Tip
Each ``` needs to be on it's own line for the code block to render correctly.
// invalid syntax
```def foo()
bar
```
// valid syntax
```
def foo()
bar
```
Copy code in one click
You can then copy your code in on click. No need to drag your mouse over the text.
![One click copy an entire code block](/_next/image?url=%2Fimg%2Fdocs%2Fpower-user%2Fcopy-code-mouse-click.gif&w=3840&q=75)
Copy code in one keypress
You can also copy your code out in one keypress with {
.
![One click copy an entire code block using the keyboard shortcut](/_next/image?url=%2Fimg%2Fdocs%2Fpower-user%2Fcopy-code.gif&w=3840&q=75)