Skip to content

Instantly share code, notes, and snippets.

@nelstrom
Created February 5, 2014 09:18
Show Gist options
  • Save nelstrom/8819893 to your computer and use it in GitHub Desktop.
Save nelstrom/8819893 to your computer and use it in GitHub Desktop.
A Vim function to transform words to "stitch words", e.g. "Seattle" becomes "S-e-a-t-t-l-e"
function! StitchWord(word)
let word = substitute(a:word, '\v(\w)', '\1-', 'g')
let word = substitute(word, '\v(\w)-$', '\1', 'g')
return word
endfunction
inoremap <c-x>- <c-o>ciw<C-r>=StitchWord(@@)<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment