A vim plugin for brainfuck programming language.
For an introduction to brainfuck, see https://www.muppetlabs.com/~breadbox/bf.
Including the basic commands (><+-.,[]
), comments and two extra debugger only commands (!|
).
Execute :BFRun
to run the interpreter with the current file as input.
The interpreter interprets the basic commands (><+-.,[]
) and any other characters will be ignored.
Line comments start with non-command characters (except spaces) and any valid commands in the comments are also ignored.
The input and output field is at the bottom.
+---------------------+
|Brainfuck source code|
| |
| |
| |
| |
+---------------------+
| IO field |
+---------------------+
For more features and configuration, see General Configuration.
Execute :BFDebug
to run the debugger with the current file as input.
The debugger has all the features of the interpreter.
It supports two extra commands (which are ignored in the interpreter):
!
: Pause program execution. Press any key to continue.|
: The commands between two|
will be executed one by one.
It opens a debug buffer showing the status of the array.
+---------------------+------------+
|Brainfuck source code|Debug buffer|
| | |
| | |
| | |
| | |
+---------------------+------------+
| IO field |
+---------------------+------------+
For more features and configuration, see General Configuration and Debugger Configuration.
Plug 'fruit-in/brainfuck-vim'
:PlugInstall
Plugin 'fruit-in/brainfuck-vim'
:PluginInstall
You can customize the behavior of the interpreter and debugger by setting some variables in your vimrc
. For example:
let g:bf_array_size = 3000
let g:bf_array_mode = 2
let g:bf_value_mode = 2
Set g:bf_array_size
to set the size of the array.
Optional values are > 0
. Default value is 30,000
.
Set g:bf_array_mode
to define the behavior when the pointer exceeds the array boundary.
Optional values are {0, 1, 2}
. Default value is 0
.
0
: Strict Mode. Throws an error when the pointer exceeds the array boundary.1
: Normal Mode. Saturating at the boundary when the pointer exceeds the array boundary.2
: Circular Mode. Wrapping around at the boundary when the pointer exceeds the array boundary.
Set g:bf_value_type
to set the type of the value.
Optional values are {0, 1, 2, 3, 4, 5, 6}
. Default value is 0
.
Set g:bf_value_mode
to define the behavior when the value exceeds the value boundary.
Optional values are {0, 1, 2}
. Default value is 0
.
0
: Strict Mode. Throws an error when the value exceeds the value boundary.1
: Normal Mode. Saturating at the boundary when the value exceeds the value boundary.2
: Circular Mode. Wrapping around at the boundary when the value exceeds the value boundary.
Set g:bf_value_max
to set the upper bound of the value. Works only when g:bf_value_type == 6
.
Optional values are >= 0
. Default value is 255
.
Set g:bf_value_min
to set the lower bound of the value. Works only when g:bf_value_type == 6
.
Optional values are <= 0
. Default value is 0
.
Set g:bf_debug_delay
to set the time interval between executing commands, in milliseconds. Works only in the debugger and the commands between two |
.
Optional values are > 0
. Default value is 200
.