├── LICENSE ├── README.md ├── examples ├── vimmmex.gif └── vimmmex_cursor.gif ├── vimmmex └── vimmmex_raw /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Battelle Memorial Institute 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # _vimmmex_ : a vim execution engine 2 | 3 | ### Overview 4 | 5 | _vimmmex_ is an illustration that a turing machine can be built from 6 | copy/paste/search/replace style operations, informally showing the 7 | turing-completeness of regular vim commands. we limit ourselves to only the 8 | "normal" vim commands - that is, vim "ex" commands (those commands that begin 9 | with a colon) and vimscript are avoided, as these are already powerful, and 10 | showing their turing completeness is trivial. specifically, vimmmex implements 11 | a brainf@!# interperter with vanilla vi commands. 12 | 13 | ### Usage 14 | 15 | to use the interpreter, open the file [vimmmex](vimmmex) in vanilla vim. if 16 | possible, reduce the font size so that the entire file fits on the screen - this 17 | will make observing execution easier. press gg2yy@" to launch the interpreter. 18 | the default BF program calculates prime numbers, up to 100. the numbers will 19 | appear on the output line (below "_o:") as they are calculated. calculations 20 | are performed by copying and pasting characters while moving about the file 21 | through searches and cursor movement keys. 22 | 23 | ### Demonstration 24 | 25 | | Calculating prime numbers | 26 | |:---------------------------------------:| 27 | | ![vimmmex](examples/vimmmex.gif) | 28 | 29 | | ... while tracking the cursor movement | 30 | |:---------------------------------------:| 31 | | ![vimmmex](examples/vimmmex_cursor.gif) | 32 | 33 | ### Versions 34 | 35 | the [vimmmex_raw](vimmmex_raw) file contains (non-ascii) vim special characters, 36 | such as ^M and ^R. [vimmmex](vimmmex) provides a pure-ascii version of the 37 | interpreter, in which special characters are inserted by the execution process 38 | itself, but uses an (ideally forbidden) vim "ex" command (the first line) to 39 | perform the substitution. this may be more conducive for copying and pasting 40 | the contents of the file. 41 | 42 | ### Limitations 43 | 44 | the only non-vi compatible requirement is that "whichwrap" is set to at least 45 | "b,s" - this is the default for vim, and is automatically configured when 46 | "nocompatible" is set. this requirement is only in place for aesthetics, as it 47 | allows breaking one long line into several smaller lines. 48 | 49 | ### Author 50 | 51 | _vimmmex_ is a proof-of-concept from Christopher Domas 52 | ([@xoreaxeaxeax](https://twitter.com/xoreaxeaxeax)). 53 | -------------------------------------------------------------------------------- /examples/vimmmex.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Battelle/vimmmex/5411ca45fca913c79caa2b6acbc828adb3c24c11/examples/vimmmex.gif -------------------------------------------------------------------------------- /examples/vimmmex_cursor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Battelle/vimmmex/5411ca45fca913c79caa2b6acbc828adb3c24c11/examples/vimmmex_cursor.gif -------------------------------------------------------------------------------- /vimmmex: -------------------------------------------------------------------------------- 1 | :%s/\^A/\="\"/g|%s/\^X/\="\"/g|%s/\^R/\="\"/g|%s/\^M/\n/g|06 2 | 0f-ly$@" 3 | ### launch with gg2yy@" ### 4 | ###### @xoreaxeaxeax ###### 5 | 6 | _c: _s1-gg0mh`h/_t^Mnjmt`h/_p^Mnjmp`h/_o^Mnjmo`h/_i^Mnjmi`h/_s2^Mnf-ly$@"njmt_j 7 | _s2-`h/_a^Mnjma`h/_c^Mnf:mc`h/_f^Mnf_mf`h/_b^Mnf_mb`pyl`c/_\V^R"^Mf-ly2tX@" 8 | z_>-`twmt`p mpyl`c/_\V^R"^Mf-ly2tX@"Xs_<-`tbmt`p mpyl`c/_\V^R"^Mf-ly2tX@"X 9 | _f:_0x:-`p% mpyl`c/_\V^R"^Mf-ly2tX@"Xa_nx:-`p mpyl`c/_\V^R"^Mf-ly2tX@"Xmpyl 10 | _b:_0x:-`p mpyl`c/_\V^R"^Mf-ly2tX@"Xm_nx:-`p% mpyl`c/_\V^R"^Mf-ly2tX@"Xly2t 11 | _+-`t^A`p mpyl`c/_\V^R"^Mf-ly2tX@"Xo_--`t^X`p mpyl`c/_\V^R"^Mf-ly2tX@"X_/-- 12 | _]-`tyt `b/\(^R"\|n\)x^Mf-ly2tX@"Xd_[-`tyt `f/\(^R"\|n\)x^Mf-ly2tX@"X^$0x:- 13 | _v.$7yy_.-`tyw`a/_\(^R"\|uuu\)^Mellyl`op$mo`p mpyl`c/_\V^R"^Mf-ly2tX@"Xelly 14 | _$`p mpy`pyl`a_,-`iy mi`a/ ^R"_^MT_ye`tvt p`p mpyl`c/_\V^R"^Mf-ly2tX@"X_#- 15 | _o: 16 | 17 | 18 | _i: 19 | 100^M 20 | 21 | _t: 22 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 24 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 | 27 | _a: 28 | ___0 .___1 .___2 .___3 .___4 .___5 .___6 .___7 .___8 .___9 .__10 ^M_11 .__12 .__13 .__14 .__15 ._ 29 | __16 .__17 .__18 .__19 .__20 .__21 .__22 .__23 .__24 .__25 .__26 .__27 .__28 .__29 .__30 .__31 ._ 30 | __32 __33 !__34 "__35 #__36 $__37 %__38 &__39 '__40 (__41 )__42 *__43 +__44 ,__45 -__46 .__47 /_ 31 | __48 0__49 1__50 2__51 3__52 4__53 5__54 6__55 7__56 8__57 9__58 :__59 ;__60 <__61 =__62 >__63 ?_ 32 | __64 @__65 A__66 B__67 C__68 D__69 E__70 F__71 G__72 H__73 I__74 J__75 K__76 L__77 M__78 N__79 O_ 33 | __80 P__81 Q__82 R__83 S__84 T__85 U__86 V__87 W__88 X__89 Y__90 Z__91 [__92 \__93 ]__94 ^__95 __ 34 | __96 `__97 a__98 b__99 c_100 d_101 e_102 f_103 g_104 h_105 i_106 j_107 k_108 l_109 m_110 n_111 o_ 35 | _112 p_113 q_114 r_115 s_116 t_117 u_118 v_119 w_120 x_121 y_122 z_123 {_124 |_125 }_126 ~_127 ._ 36 | _uuu . 37 | 38 | _p: 39 | +[->,----------[<+>-------------------------------------->[>+>+<<-]>>[<<+>>-]<>>>+++++++++[<<<[>+ 40 | >+<<-]>>[<<+>>-]<[<<+>>-]>>-]<<<[-]<<[>+<-]]<]>>[<<+>>-]<<>+<-[>+[>+>+<<-]>>[<<+>>-]<>+<-->>>>>>> 41 | >+<<<<<<<<[>+<-<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<>[>>+>+<<<-]>>>[<<<+>>>-]<<<<>>>[>+>+<<-]>>[<<+>> 42 | -]<<<[>>>>>+<<<[>+>+<<-]>>[<<+>>-]<[>>[-]<<-]>>[<<<<[>+>+<<-]>>[<<+>>-]<>>>-]<<<-<<-]+>>[<<[-]>>- 43 | ]<<>[-]<[>>>>>>[-]<<<<<<-]<<>>[-]>[-]<<<]>>>>>>>>[-<<<<<<<[-]<<[>>+>+<<<-]>>>[<<<+>>>-]<<<>>[>+<- 44 | ]>[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<-> 45 | -]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<- 46 | <-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<++++++++> 47 | -]<.[-]>>>>>>>]<<<<<<<<>[-]<[-]<<-]++++++++++.[-]# 48 | -------------------------------------------------------------------------------- /vimmmex_raw: -------------------------------------------------------------------------------- 1 | 0/_s1 nf-ly$@" 2 | 3 | ### launch with ggyy@" ### 4 | ###### xoreaxeaxeax ###### 5 | 6 | _c: _s1-gg0mh`h/_t njmt`h/_p njmp`h/_o njmo`h/_i njmi`h/_s2 nf-ly$@"njmt_j 7 | _s2-`h/_a njma`h/_c nf:mc`h/_f nf_mf`h/_b nf_mb`pyl`c/_\V" f-ly2tX@" 8 | z_>-`twmt`p mpyl`c/_\V" f-ly2tX@"Xs_<-`tbmt`p mpyl`c/_\V" f-ly2tX@"X 9 | _f:_0x:-`p% mpyl`c/_\V" f-ly2tX@"Xa_nx:-`p mpyl`c/_\V" f-ly2tX@"Xmpyl 10 | _b:_0x:-`p mpyl`c/_\V" f-ly2tX@"Xm_nx:-`p% mpyl`c/_\V" f-ly2tX@"Xly2t 11 | _+-`t`p mpyl`c/_\V" f-ly2tX@"Xo_--`t`p mpyl`c/_\V" f-ly2tX@"X_/-- 12 | _]-`tyt `b/\("\|n\)x f-ly2tX@"Xd_[-`tyt `f/\("\|n\)x f-ly2tX@"X^$0x:- 13 | _v.$7yy_.-`tyw`a/_\("\|uuu\) ellyl`op$mo`p mpyl`c/_\V" f-ly2tX@"Xelly 14 | _$`p mpy`pyl`a_,-`iy mi`a/ "_ T_ye`tvt p`p mpyl`c/_\V" f-ly2tX@"X_#- 15 | _o: 16 | 17 | 18 | _i: 19 | 100 20 | 21 | _t: 22 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 24 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 | 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 | 27 | _a: 28 | ___0 .___1 .___2 .___3 .___4 .___5 .___6 .___7 .___8 .___9 .__10 _11 .__12 .__13 .__14 .__15 ._ 29 | __16 .__17 .__18 .__19 .__20 .__21 .__22 .__23 .__24 .__25 .__26 .__27 .__28 .__29 .__30 .__31 ._ 30 | __32 __33 !__34 "__35 #__36 $__37 %__38 &__39 '__40 (__41 )__42 *__43 +__44 ,__45 -__46 .__47 /_ 31 | __48 0__49 1__50 2__51 3__52 4__53 5__54 6__55 7__56 8__57 9__58 :__59 ;__60 <__61 =__62 >__63 ?_ 32 | __64 @__65 A__66 B__67 C__68 D__69 E__70 F__71 G__72 H__73 I__74 J__75 K__76 L__77 M__78 N__79 O_ 33 | __80 P__81 Q__82 R__83 S__84 T__85 U__86 V__87 W__88 X__89 Y__90 Z__91 [__92 \__93 ]__94 ^__95 __ 34 | __96 `__97 a__98 b__99 c_100 d_101 e_102 f_103 g_104 h_105 i_106 j_107 k_108 l_109 m_110 n_111 o_ 35 | _112 p_113 q_114 r_115 s_116 t_117 u_118 v_119 w_120 x_121 y_122 z_123 {_124 |_125 }_126 ~_127 ._ 36 | _uuu . 37 | 38 | _p: 39 | +[->,----------[<+>-------------------------------------->[>+>+<<-]>>[<<+>>-]<>>>+++++++++[<<<[>+ 40 | >+<<-]>>[<<+>>-]<[<<+>>-]>>-]<<<[-]<<[>+<-]]<]>>[<<+>>-]<<>+<-[>+[>+>+<<-]>>[<<+>>-]<>+<-->>>>>>> 41 | >+<<<<<<<<[>+<-<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<<<>[>>+>+<<<-]>>>[<<<+>>>-]<<<<>>>[>+>+<<-]>>[<<+>> 42 | -]<<<[>>>>>+<<<[>+>+<<-]>>[<<+>>-]<[>>[-]<<-]>>[<<<<[>+>+<<-]>>[<<+>>-]<>>>-]<<<-<<-]+>>[<<[-]>>- 43 | ]<<>[-]<[>>>>>>[-]<<<<<<-]<<>>[-]>[-]<<<]>>>>>>>>[-<<<<<<<[-]<<[>>+>+<<<-]>>>[<<<+>>>-]<<<>>[>+<- 44 | ]>[[>+>+<<-]>>[<<+>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>-]<<-<-]+++++++++>[<-> 45 | -]<[>+<-]<[>+<-]<[>+<-]>>>[<<<+>>>-]<>+++++++++<[>>>+<<[>+>[-]<<-]>[<+>-]>[<<++++++++++>>>+<-]<<- 46 | <-]>>>>[<<<<+>>>>-]<<<<>[-]<<+>]<[[>+<-]+++++++[<+++++++>-]<-><.[-]>>[<<+>>-]<<-]>++++[<++++++++> 47 | -]<.[-]>>>>>>>]<<<<<<<<>[-]<[-]<<-]++++++++++.[-]# 48 | --------------------------------------------------------------------------------