Skip to content

Instantly share code, notes, and snippets.

@humus
Created September 16, 2013 16:35
Show Gist options
  • Select an option

  • Save humus/6583081 to your computer and use it in GitHub Desktop.

Select an option

Save humus/6583081 to your computer and use it in GitHub Desktop.
Convertir último texto ingresado en una línea a camel case
fun! Camel_last() "{{{
let start_mod = getpos("'[")
let end_mod = getpos("']")
if (start_mod[1] != end_mod[1])
return
endif
let mod_line = getline(start_mod[1])
let inserted_text = mod_line[start_mod[2] - 1 :end_mod[2] - 2]
let text_replacement = substitute(inserted_text, '\v%(\S)@<=\s(\w)', '\u\1', 'g')
let prepared_line = ''
if start_mod[2] > 1
let prepared_line .= mod_line[0:start_mod[2] - 2]
endif
let prepared_line .= mod_line[end_mod[2] - 1:-1]
call setline(start_mod[1], prepared_line)
call setpos('.', start_mod)
let @z = text_replacement
let @x = inserted_text
call feedkeys('i' . text_replacement . "\<Esc>")
endfunction "}}}
command! CamelCaseLast call Camel_last()
cab lcc CamelCaseLast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment