How to get indentations right
In this small page, I will explain indentation.
What is indentation?
indentation is "the action of indenting or the state of being indented"
indent is "start (a line of text) or position (a block of text, table, etc.) further from the margin than the main part of the text."
Simply, when you want to make a block of code, you need a new indentation
in programming, indentations are tabs
skript allows a variety of indentation methods
- 1 tab
- 4 spaces
- 2 spaces
it is recommended to use 1 tab but if you cant use 1 tab, use 4 spaces.
2 spaces are also valid but it is not recommended.
(in atom text editor, the tab defaults to 2 spaces. you can change this in settings)
example
set {_n} to 1
loop 10 times:
# starting a code block
add 1 to {_n}
broadcast "the current number is %{_n}%"
broadcast "the final number is %{_n}%"
because of the indentation, the code flows like this

the block inside loops and when the loop is over it goes outside and continues the code
When should I use indentation?
Every time you use a ":" at the end
except using short hand if
ex)
https://skriptlang.github.io/Skript/conditions.html
they look like these
{var} is 1
event-item is diamond pickaxe
they are a shorthand expression for
if the condition is false:
stop this code
so you don't need an indentation.
adding a ":" will allow an else(and "else if") expression
example of a valid indentation
example of an invalid indentation
# will throw an indentation error
command /test:
trigger:
tool of player is dirt
send "you have dirt"
# will suppress the error.
command /test2:
trigger:
tool of player is dirt:
send "you have dirt"
edit 19/10/20 i got 1 statement wrong.
updated the article accordingly
sorry for my mistake
edit 19/10/24
added some more information
What is indentation?
indentation is "the action of indenting or the state of being indented"
indent is "start (a line of text) or position (a block of text, table, etc.) further from the margin than the main part of the text."
Simply, when you want to make a block of code, you need a new indentation
in programming, indentations are tabs
skript allows a variety of indentation methods
- 1 tab
- 4 spaces
- 2 spaces
it is recommended to use 1 tab but if you cant use 1 tab, use 4 spaces.
2 spaces are also valid but it is not recommended.
(in atom text editor, the tab defaults to 2 spaces. you can change this in settings)
example
set {_n} to 1
loop 10 times:
# starting a code block
add 1 to {_n}
broadcast "the current number is %{_n}%"
broadcast "the final number is %{_n}%"
because of the indentation, the code flows like this

the block inside loops and when the loop is over it goes outside and continues the code
When should I use indentation?
Every time you use a ":" at the end
except using short hand if
ex)
https://skriptlang.github.io/Skript/conditions.html
they look like these
{var} is 1
event-item is diamond pickaxe
they are a shorthand expression for
if the condition is false:
stop this code
so you don't need an indentation.
adding a ":" will allow an else(and "else if") expression
example of a valid indentation
command /test:
trigger:
tool of player is dirt
send "you have dirt"
command /test2:
trigger:
tool of player is dirt:
send "you have dirt"
command /test3:
trigger:
if tool of player is dirt:
send "you have dirt"
trigger:
tool of player is dirt
send "you have dirt"
command /test2:
trigger:
tool of player is dirt:
send "you have dirt"
command /test3:
trigger:
if tool of player is dirt:
send "you have dirt"
example of an invalid indentation
# will throw an indentation error
command /test:
trigger:
tool of player is dirt
send "you have dirt"
# will suppress the error.
command /test2:
trigger:
tool of player is dirt:
send "you have dirt"
edit 19/10/20 i got 1 statement wrong.
updated the article accordingly
sorry for my mistake
edit 19/10/24
added some more information