Skip to main content
added 62 characters in body
Source Link

Vimscript, 116 115 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjply4lpjy4hp"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3) in an empty buffer. To load the function, source cake.vim

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjply4lpjy4hp is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this # times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !

Vimscript, 116 115 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjply4lpjy4hp"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjply4lpjy4hp is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this # times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !

Vimscript, 116 115 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjply4lpjy4hp"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3) in an empty buffer. To load the function, source cake.vim

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjply4lpjy4hp is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this # times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !
added 9 characters in body; deleted 4 characters in body
Source Link

Vimscript, 116116 115 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjp4a-\ej4a \e"@z="Vkyjply4lpjy4hp"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjp4a-\ej4a \eVkyjply4lpjy4hp is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this (input)# times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !

Vimscript, 116 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjp4a-\ej4a \e"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjp4a-\ej4a \e is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this (input) times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !

Vimscript, 116 115 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjply4lpjy4hp"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjply4lpjy4hp is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this # times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !
added 569 characters in body; added 20 characters in body
Source Link

Vimscript, 116 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjp4a-\ej4a \e"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjp4a-\ej4a \e is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this (input) times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !

Vimscript, 116 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjp4a-\ej4a \e"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Vimscript, 116 bytes

Pretty messy but it works!

fu A(n)
let @z="Vkyjp4a-\ej4a \e"
exe "norm 2i+\e5i-\eo||\e5i \e".a:n."@zddl4xggd$i_|_|_"
exe "%ce ".(a:n*4+3)
endfu

To call it: call A(3)

Explanation

  • 2i+<Esc>5i-<Esc> writes the first line +-----+
  • o||<Esc>5i<Space><Esc> adds | | on the second line
  • Vkyjp4a-\ej4a \e is saved in the macro @z - it visually selects both lines, yanks them, pastes them under and adds 4 dashes and spaces to them.
  • #@z repeats this (input) times
  • ddl4x deletes the last lines and remove for dashes to the bottom of the cake to make it equal with the top of the bottom layer
  • ggd$i_|_|_ replaces the first line by the top of the cake
  • %ce then centers the whole cake to the width of the bottom layer! !
Source Link
Loading