Skip to content

Instantly share code, notes, and snippets.

@hzchirs
Last active August 27, 2018 06:10
Show Gist options
  • Save hzchirs/ae9797ebc752822a217480c1e81bea89 to your computer and use it in GitHub Desktop.
Save hzchirs/ae9797ebc752822a217480c1e81bea89 to your computer and use it in GitHub Desktop.
Ruby class name and method name text object for vim
" method name object, e.g. cmn (change method name), dmn (delete method name), vmn (visual select method name)
" m -> vim-ruby method text-obj n -> name
onoremap mn :<c-u>execute "normal! ?\def\\s\\l\\+\r:nohlsearch\rwviW"<CR>
vnoremap mn :<c-u>execute "normal! ?\def\\s\\l\\+\r:nohlsearch\rwviW"<CR>
" class name object, e.g. cMn, dMn, vMn
" M -> vim-ruby class text-obj n -> name
onoremap Mn :<c-u>execute "normal! ?\\(class\\\|module\\\|describe\\)\\s\\u\\l\\+\r:nohlsearch\rwviW"<CR>
vnoremap Mn :<c-u>execute "normal! ?\\(class\\\|module\\\|describe\\)\\s\\u\\l\\+\r:nohlsearch\rwviW"<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment