vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

hanoi.vim (1097B)


      1 set remap
      2 set noterse
      3 set wrapscan
      4 " to set the height of the tower, change the digit in the following
      5 " two lines to the height you want (select from 1 to 9)
      6 map t 7
      7 map! t 7
      8 map L 1G/t
X/^0
$P1GJ$An$BGC0e$X0E0F$X/T
@f
@h
$A1GJ@f0l$Xn$PU
      9 map g IL
     10 
     11 map J /^0[^t]*$
     12 map X x
     13 map P p
     14 map U L
     15 map A "fyl
     16 map B "hyl
     17 map C "fp
     18 map e "fy2l
     19 map E "hp
     20 map F "hy2l
     21 
     22 " initialisations:
     23 " KM	cleanup buffer
     24 " Y	create tower of desired height
     25 " NOQ	copy it and insert a T
     26 " NO	copy this one
     27 " S	change last char into a $
     28 " R	change last char in previous line into a n
     29 " T	insert two lines containing a zero
     30 " V	add a last line containing a backslash
     31 map I KMYNOQNOSkRTV
     32 
     33 "create empty line
     34 map K 1Go
     35 
     36 "delete to end of file
     37 map M dG
     38 
     39 "yank one line
     40 map N yy
     41 
     42 "put
     43 map O p
     44 
     45 "delete more than height-of-tower characters
     46 map q tllD
     47 
     48 "create a tower of desired height
     49 map Y o0123456789Z0q
     50 
     51 "insert a T in column 1
     52 map Q 0iT
     53 
     54 "substitute last character with a n
     55 map R $rn
     56 
     57 "substitute last character with a $
     58 map S $r$
     59 
     60 "insert two lines containing a zero
     61 map T ko0
0


     62 
     63 "add a backslash at the end
     64 map V Go/