from Hacker News

Vim plugin makes Ruby blocks into text objects

by subelsky on 12/27/10, 8:05 PM with 14 comments

  • by burgerbrain on 12/27/10, 8:50 PM

    Stuff like this can usually be handled with a quick macro in Vim.

    For example, I use the macro `zEkzfggj%jzfG` (minus backticks) to fold everything above and below the current { and it's corresponding C block.

    And now that I see all of it typed out like that, I'm not sure myself if this is an argument for Vim, or a parody of an argument for it ;)

  • by austintaylor on 12/27/10, 9:09 PM

    An indentation-based text object solves the same problem in a language-agnostic way. There are several implementations out there. I maintain one that includes proper handling of languages without ending block delimiters (python, haml, sass): http://github.com/austintaylor/vim-indentobject
  • by aditya on 12/27/10, 8:41 PM

    Nifty, but this seems like plugin overkill.

    I just use matchit (http://www.vim.org/scripts/script.php?script_id=39) and then I can do v% to visually select everything to the end of a block.

  • by lemming on 12/28/10, 1:35 PM

    One of the little things that I love most about IntelliJ is its expand/shrink selection command. It's one of those things that you have no idea how useful it will be until you get used to it, then you can't live without it.
  • by wmwong on 12/27/10, 10:17 PM

    This made me smile. Such a nice Christmas gift. I just started getting into vim and things that solve little nagging annoyances really help me stick with it. Thank you!
  • by kingsidharth on 12/28/10, 8:01 AM

    Anything like this for Python? Any plug-in or built in macro?
  • by chrismealy on 12/28/10, 12:52 AM

    Anybody know an emacs equivalent?