Skip to content

Instantly share code, notes, and snippets.

@heavenshell
Created December 28, 2012 03:22
Show Gist options
  • Save heavenshell/4394210 to your computer and use it in GitHub Desktop.
Save heavenshell/4394210 to your computer and use it in GitHub Desktop.
" Insert sudden-death strings
" Last Change: 2012-12-28
" Maintainer: Shinya Ohyanagi <[email protected]>
" NOTE: Original code is https://github.com/supermomonga/unite-sudden-death
"
let s:save_cpo = &cpo
set cpo&vim
function! s:draw(text)
let width = strlen(substitute(substitute(a:text, "[ -~。-゚]", 's', 'g'), "[^s]", 'mm', 'g')) / 2 + 2
let top = '_' . join(map(range(width), '"人"'),'') . "_\n"
let content = '> ' . a:text . " <\n"
let bottom = ' ̄' . join(map(range(width), '"Y"'),'') . ' ̄'
return top . content . bottom
endfunction
function! suddendeath#draw(text)
let paste = &g:paste
let &g:paste = 1
let text = s:draw(a:text)
silent! execute 'normal! O' . text
let &g:paste = paste
endfunction
function! suddendeath#echo(text)
echo s:draw(a:text)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment