Skip to content

Instantly share code, notes, and snippets.

@awebneck
Created September 21, 2010 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awebneck/590705 to your computer and use it in GitHub Desktop.
Save awebneck/590705 to your computer and use it in GitHub Desktop.
" Normal-mode bindings for easy camelCase editing:
" cm begins at the current position and deletes until
" the end of the word or the next capital letter
" (exclusive), then places you into insert mode in the
" deleted space
nmap <silent> cm :let save_search=@/<CR>v/[A-Z]\\|\([A-Za-z0-9]\)\@<lt>=\(\W\\|_\)<CR>hx:let @/=save_search<CR>i
" cu begins at the beginning of the current word or
" previous capital letterand deletes until the end of
" the word or the next capital letter (exclusive),
" then places you into insert mode in the deleted
" space.
nmap <silent> cu :let save_search=@/<CR>/\w<CR>?[A-Z]\\|\(\W\\|_\\|\n\)\@<lt>=[A-Za-z0-9]<CR>v/[A-Z]\\|\([A-Za-z0-9]\)\@<lt>=\(\W\\|_\)<CR>hx:let @/=save_search<CR>i
" , moves you to the beginning of the next word or
" next capital letter.
nmap <silent> , :let save_search=@/<CR>/[A-Z]\\|\(\W\\|_\\|\n\)\@<lt>=[A-Za-z0-9]<CR>:let @/=save_search<CR>
" < moves you to the beginning of the current word or
" previous capital letter.
nmap <silent> < :let save_search=@/<CR>?[A-Z]\\|\(\W\\|_\\|\n\)\@<lt>=[A-Za-z0-9]<CR>:let @/=save_search<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment